appudiscordbot.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Discord-Reddit-Bot 作者: appu1232 项目源码 文件源码
def unfollow(ctx):
    f = open('%susers/allusers.txt' % path, 'r+')
    all = f.read().strip()
    if all:
        users = all.split(',')
    else:
        users = []
    if ctx.message.author.id in users:
        users.remove(ctx.message.author.id)
        f.seek(0)
        f.truncate()
        if users != ['']:
            for i in users:
                if i:
                    f.write(i + ',')
        else:
            pass
        os.remove('%susers/user%s.txt' % (path, ctx.message.author.id))
        await bot.send_message(ctx.message.channel, 'You have unsubscribed from the reddit notifier feed. Use ``ap:follow`` to resubscribe if you\'d like. **Note: your list has been deleted** so if you subscribe again, you must remake your list.')
        await bot.send_message(discord.Object(id=config["log_location"]), 'User: ' + str(ctx.message.author) + '\nCmd: ' + str(ctx.message.content))
    else:
        await bot.send_message(ctx.message.channel, 'You are already unsubscribed from the notifier.')
    f.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号