没有项目描述
botovod的Python项目详细描述
波托沃德
说明 这是一个简单易用的与Instagram交互的库。图书馆工作
通过Instagram的Web界面,不依赖于官方API内容
- botovod
- botovod.agentdict
- botovod.botovod
- botovod.agents
- botovod.agents.agent
- botovod.agents.entity
- botovod.agents.chat
- botovod.agents.message
- botovod.agents.attachment
- botovod.agents.image
- botovod.agents.audio
- botovod.agents.video
- botovod.agents.document
- botovod.agents.location
- botovod.agents.keyboard
- botovod.agents.keyboardbutton
- botovod.agents.telegram
- botovod.agents.telegram.telegramagent
- botovod.agents.telegram.telegramattachment
- botovod.agents.telegram.telegramessage
- botovod.agents.telegram.telegramaudio
- botovod.agents.telegram.telegramdocument
- botovod.agents.telegram.telegramphotosize
- botovod.agents.telegram.telegram视频
- botovod.agents.telegram.telegramlocation
- botovod.agents.vk
- botovod.dbdrivers
- botovod.对话框
发行说明
0.1.4版
- 添加新的dbdriver-gino
- 修复错误
开始
从PIP安装
要从pip安装botovod库,应该使用pip和python(首选python3.6或 后来)
pip install botovod
从Github安装
要从github存储库进行基本安装,您应该拥有git、python3(更喜欢python3.6或 稍后),pip(可选)在您的系统中
git clone https://github.com/OlegYurchik/botovod.git
cd botovod
pip install .
或
git clone https://github.com/OlegYurchik/botovod.git
cd botovod
python setup.py install
快速启动
安装后,可以在代码中使用库。下面是使用 图书馆
frombotovodimportBotovodfrombotovod.agents.telegramimportTelegramAgentdefecho(agent,chat,messsage):agent.send_message(chat,text=message.text)botovod=Botovod()botovod.handlers.append(echo)telegram_agent=TelegramAgent(token="your-telegram-token",method="polling)botovod.agents["telegram"]=telegram_agentbotovod.start()
此代码通过轮询设置并运行telegram echo bot
frombotovodimportBotovodfrombotovod.agents.telegramimportTelegramAgentfrombotovod.dbdrivers.sqlalchemyimportDBDriverfrombotovod.dialogsimportDialogclassRegisterDialog(Dialog):defstart(self):self.reply(text="Hello, my friend!")self.reply(text="What is your name?")self.set_next_step(self.what_name)defwhat_name(self):name=self.message.textself.follower.set_value("name",name)self.reply(text="Nice to meet you, %s. What would you want?"%name)self.set_next_step(self.menu)defmenu(self):pass# your codebotovod=Botovod(DBDriver(engine="sqlite",database="file.mdb"))botovod.handlers.append(RegisterDialog)telegram_agent=TelegramAgent(token="your-telegram-token")botovod.agents["telegram"]=telegram_agentbotovod.start()
此代码设置并运行与数据库和关注者一起工作的电报代码
文档
波托沃德
包装箱
botovod.agentdict
botovod.agentDist类
属性
- 波托沃德:波托沃德。波托沃德
botovod对象
方法
- _初始化(self,botovod:botovod.botovod)
agentDist的构造函数
- _设置项(self,key:str,value:botovod.agents.agent)
像dict那样设置代理
- _ Delitem_uuu(自我,密钥:str)
删除像dict这样的代理
波托沃德。波托沃德
BOTOVOD.BOTOVOD类
属性
- dbdriver:botovod.dbdrivers.dbdriver或none
用于处理数据库的驱动程序(用于保存关注者和对话框的数据)
- 代理:botovod.agentdict
机器人程序代理词典
- 处理程序:列表
带有消息和事件处理程序的列表
- logger:日志记录。logger 记录器< /LI>
方法
- _初始化(self,dbdriver:(dbdriver,none)=无,记录器: logging.logger=logging.getlogger(name)
此方法初始化botovod对象
- 开始(自行)
启动Botovod中的所有代理
- A_开始(自我)
协同旅行。启动Botovod中的所有代理
- 停止(自行)
停止Botovod中的所有代理
- 自动停止
协同旅行。停止Botovod中的所有代理
- listen(selfname:str,headers:dict,body:string)->;(int,dict,str)或none
方法,为Web服务器提供侦听和处理来自信使服务器的请求的功能。
- 听(self,name:str,headers:dict,body:string)->;(int,dict,str}或none
协同路由,为Web服务器提供侦听和处理来自信使服务器的请求的功能。
Botovod.代理
打包botovod.agents
botovod.agents.agent
botovod.agent.agent类
属性
- 波托沃德:波托沃德。波托沃德
botovod对象
- 姓名:str
Botovod中的代理名称
- 跑步:布尔
变量如果代理正在运行else false,则哪个为true
- logger:logging.logger
记录器
方法
- _初始化(self,logger:logging.logger=logging.getlogger(name)):
代理构造函数
- _重复(自我)->;str
返回类的名称
- 听(self,headers:dict,body:string)->;(int,dict,str)或none:
从代理Messenger获取请求并处理它的方法
- 听(self,headers:dict,body:string)->;(int,dict,str)或none:
用于从代理Messenger获取请求并处理它的协同程序
- 开始(自我):
运行代理的抽象方法
- A_开始(自我):
运行代理的抽象协同程序
- 停止(自行):
停止代理的抽象方法
- 自动停止:
停止代理的抽象协同程序
- 解析器(self,headers:dict,body:str)->;list[元组(聊天,消息))
解析请求和返回列表的抽象方法[元组(聊天,消息))
- 语法分析器(self,headers:dict,body:str)->;list[元组(聊天,消息)]
解析请求和返回列表的抽象协同程序[元组(聊天,消息)]
- 应答器(self,headers:dict,body:str)->;(int,dict,str)
返回包含信息的元组以响应Messenger的抽象方法
- 应答器(self,headers:dict,body:str)->;(int,dict,str)
返回带有信息的元组以响应Messenger的抽象协同程序
- 发送消息(self,chat:botovod.agents.chat,text:str或none=none,images:iterator of botovod.agents.image=[],audios:botovod.agents.audio的迭代器]=[],documents:iterator of botovod.agents.document=[],videos:botovod.agents.video=[],locations:iterator的迭代器 botovod.agents.location=[],keyboard:botovod.agents.keyboard or none=none,raw:dict or none=none)
发送消息的抽象方法
- 发送消息(self,chat:botovod.agents.chat,text:str或none=none,images:iterator of botovod.agents.image=[],audios:botovod.agents.audio的迭代器]=[],documents:iterator of botovod.agents.document=[],videos:botovod.agents.video=[],locations:iterator的迭代器 botovod.agents.location=[],keyboard:botovod.agents.keyboard or none=none,raw:dict or none=none)
发送消息的抽象协同程序
botovod.agents.entity
类botovod.agents.entity
属性
- 原始:dict
带附加信息的听写
方法
- _初始(自我)
实体的构造函数
botovod.agents.chat
类botovod.agents.chat(botovod.agents.entity)
属性
- 代理:botovod.agents.agent
此聊天的代理
- id:str
此信使的聊天ID
网络方法
- _初始化(self,agent:botovod.agents.agent,id:str)
聊天构造函数
botovod.agents.message
类botovod.agents.message(botovod.agents.entity)
属性
- 文本:str或none
消息文本
- 图片:botovod.agents.image的列表
消息图像
- audios:botovod.agents.audio的列表
消息音频
- 视频:botovod.agents.video的列表
消息视频
- 文档:botovod.agents.document的列表
消息文档
- 位置:botovod.agents.location的列表
消息位置
- 日期:datetime.datetime
收到消息的日期和时间
方法
- _初始(自我)
消息构造函数
botovod.agents.attachment
botovod.agents.attachment类(botovod.agents.entity)
属性
- url:str或none
附件的URL
- 文件:str或none
硬盘中到附件的文件路径
botovod.agents.image
botovod.agents.image类(botovod.agents.attachment)
botovod.agents.audio
botovod.agents.audio类(botovod.agents.attachment)
botovod.agents.video
botovod.agents.video类(botovod.agents.attachment)
botovod.agents.document
botovod.agents.document类(botovod.agents.attachment)
botovod.agents.location
分类botovod.agents.location(botovod.agents.entity)
属性
- 纬度:浮动
位置纬度
- 经度:浮点
位置经度
方法
- _初始(自身,纬度:浮动,经度:浮动)
位置构造函数
botovod.agents.keyboard
类botovod.agents.keyboard(botovod.agents.entity)
属性
- 按钮:botovod.agents.keyboardbutton的迭代器
键盘按钮
方法
- _初始化(self,*butons:botovod.agents.keyboardbutton的迭代器)
键盘构造器
botovod.agents.keyboard按钮
类botovod.agents.keyboard按钮
属性
- 文本:str
按钮文本
方法
- _初始化(自我,文本:str)
键盘按钮构造器
botovod.dbdrivers
打包botovod.dbdrivers
botovod.dbdrivers.dbdriver
类botovod.dbdrivers.dbdriver
botovod.dbdrivers.follower
类botovod.dbdrivers.follower
botovod.对话框
模块按钮对话框
botovod.dialogs.dialog
类botovod.dialogs.dialog
属性
- 代理:botovod.agents.agent
获取消息的代理
- 聊天:botovod.agents.chat
- 消息:botovod.agents.message
消息
- follower:botovod.dbdrivers.folower
跟随者
方法
- _初始化(self,agent:botovod.agents.agent,chat:botovod.agents.chat,消息: botovod.agents.message)
用于创建对话框对象的构造函数
- _新建(self,agent:botovod.agents.agent,chat:botovod.agents.chat,消息: botovod.agents.message)
处理请求的方法
- 回复(self,text:str或none=none,images:botovod.agents的迭代器,image=[], audios:botovod.agents.audio=[],documents:botovod.agents.document=[]的迭代器, videos:botovod.agents.video=[],locations:botovod.agents.location=[]的迭代器, 键盘:botovod.agents.keyboard或none=none,raw=none)
回复消息的方法
- 回答(self,text:str或none=none,images:botovod.agents的迭代器,image=[], audios:botovod.agents.audio=[],documents:botovod.agents.document=[]的迭代器, videos:botovod.agents.video=[],locations:botovod.agents.location=[]的迭代器, 键盘:botovod.agents.keyboard或none=none,raw=none)
用于回复消息的Corotuine
- 设置下一步(自我,功能:可调用)
在对话框中设置下一个消息处理函数的方法
- a_set_next_step(self,函数:可调用)