【问题标题】:Can PRAW tell if a poster is the moderator of a sub?PRAW 可以判断一个海报是否是一个 sub 的版主吗?
【发布时间】:2022-01-25 19:53:12
【问题描述】:

我正在尝试确定评论或帖子的所有者是否是它所在的特定 subreddit 的 mod(一般不是版主)。目前我正在使用代码:

if comment.author in self.mods:

这似乎运行,但我不知道它是否真的在做这项工作,或者我是否在这里浪费时间。有人可以确认我做对了吗,或者提出更好的方法?

【问题讨论】:

    标签: python bots reddit praw


    【解决方案1】:

    不确定 self.mods 是什么,但如果作者是版主,这将返回子版块的版主列表。 Source

    # subreddit would be a string of the subreddit you wish to look at
    def listMods(reddit, subreddit):
        return [str(moderator) for moderator in reddit.subreddit(subreddit).moderator()]
    

    然后检查作者是否是版主可能看起来像:

    mods = listMods(reddit, "dataisbeautiful")
    
    if comment.author in mods:
         # do what you need to after checking
    

    reddit 是您的 praw 实例登录到您的帐户

    【讨论】:

    • 谢谢!我会试试看! :)
    猜你喜欢
    • 2019-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多