我正在尝试构建一个,当我在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获取消息作者
编辑:图像仅用于显示到目前为止的进度,谢谢!
发布于 2016-08-05 02:21:45
我不知道你为什么在PRAW文档中找不到它,因为在谷歌上快速搜索"praw作者“给出了这个Stack Overflow答案。
注释有一个author属性,它是一个Redditor对象。要从Redditor对象获取名称,请使用其name属性。
编辑:所以你要做的就是用msg.author.name替换'Author here'
https://stackoverflow.com/questions/38774410
复制相似问题