一个python3库,用于轻松构建devrant机器人

drbot的Python项目详细描述


drbot

python3库,用于轻松构建devrant机器人程序

使用

要创建bot,只需扩展BotBuilder类并定义onNotif()方法

fromdrbot.botbuilderimportBotBuilder,NotifType# Testing setupclassMyBot(BotBuilder):onNotif(self,type,content):# Handle notifs herepass# Create a botmy_bot=MyBot("username","password")# Set how long the bot should wait between notif queries (in seconds)interval=10# Start the botmy_bot.start(interval)

就这样!

使用API

每个BotBuilder类都有一个内置的api包装器。这可以通过self.api访问,并包含以下方法:

getUserInfo(username:str)->dictgetUsername(user_id:int)->strpostRant(body:str,tags:str)->NonepostComment(rant_id:int,content:str)->NonegetComment(comment_id:int)->dict

BotBuilder自动处理登录、会话、notif管理和一些数据解析。如果您希望覆盖这些方法,您可能会对以下api方法感兴趣:

login(username:str,password:str)->NonehasAuthExpired()->boolgetNotifs()->listclearNotifs()->NonegetUserId(username:str)->int

安装

这个库在pypi上是可用的。

安装python3.7python3-pip后,运行:

pip3 install drbot

安装drbot

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在运行Eclipse导出的jar时出现“找不到主类”错误   java GPS位置之间距离和方位的精度   java ClassLoader()与java之间的区别是什么。getResourceAsStream(“./path”)和类加载器()。getResourceAsStream(“路径”)   jdbc url中的java Set用户变量   java我不能在框架中拖放   如何在java中添加控制台输出窗口?   java如何以水平方式加载JList?   java基于Maven结果构建不同的Docker映像(与Jenkins一起)   java正在遍历一个文件   java在Eclipse中添加外部库   java Eclipse在未关闭ServletOutputStream时抱怨资源泄漏   java如何在安卓应用程序中读取弹出窗口中的文本?   java<s:if>标记不起作用   使用java中的云存储JSON API在Google云中恢复上传文本文件,面临403错误代码禁止访问的问题   java迭代快速排序步骤?   java如何使用时区ID获得GMT等效值   java如何使用junit测试@RestController的@RequestBody?   java如何在安卓中使用smack库在xmpp传入消息中获取时间戳