【发布时间】:2016-12-10 23:51:39
【问题描述】:
当我在 Reddit 上收到一条消息以在我的设备上显示警报并告诉它作者时,我正在尝试构建一个。像这样:
我尝试搜索 Reddit 的文档,但我没有找到任何关于此事的信息,包括 PRAW 的文档、Reddit 的 API 文档以及他们的 Subreddit。我什至尝试过messages.author,但也没有成功。我想得到的是这样的: 到目前为止代码看起来是这样的:
import praw
import time
import os
import pync
from pync import Notifier
print "Booting up..."
def Main():
print "Searching for messages..."
r = praw.Reddit(user_agent='RedditNotifier version 0.0.1')
r.login('username', 'pass')
for msg in r.get_unread(limit=None):
if not msg:
print "True"
else:
Notifier.notify('From:' + 'Author here', title='Reddit: New Message!', open='https://www.reddit.com/message/unread/')
print msg
while True:
Main()
time.sleep(5)
TL;DR 如何使用 PRAW 获取消息作者
编辑:图像仅用于显示到目前为止的进度 谢谢!
【问题讨论】:
-
你不会在 praw 或 reddit 的文档中找到消息传递实用程序——这不是他们所做的
-
所以我不能那样做。那我应该抓取数据吗?
-
不,我是说通知栏。如果我误解了你的问题,那么你应该学习How to Ask 以及如何创建minimal reproducible example。
-
Main()不是一个类,所以不要大写它的名字。它违反了 Python 的官方风格指南 PEP 8。