为信使和社交网络开发系统的图书馆
kutana的Python项目详细描述
库塔纳
英语Русский
为信使和社交网络开发系统的图书馆。伟大的 用于开发机器人。参考example 为了展示图书馆的能力。
Nice foundation for bot using kutana library - kubot.
安装
python -m pip install kutana
用法
- 创建
Kutana
应用程序并添加管理器。 - 在执行器中注册您的插件。你可以从文件夹导入插件
使用函数
load_plugins
。文件应该是有效的python模块 与插件一起使用的plugin
字段(Plugin
)或字段plugins
有Plugin
类实例的列表。 - 启动应用程序。
示例run.py
Token for VKManager is loaded from the file "configuration.json" and plugins are loaded from folder "plugins/"
fromkutanaimport*# Load configurationwithopen("configuration.json")asfh:config=json.load(fh)# Create applicationapp=Kutana()# Create and add VKManager to applicationapp.add_manager(VKManager(config["vk_token"]))# Load and register pluginsapp.register_plugins(load_plugins("plugins/"))# Run applicationapp.run()
示例插件(plugins/echo.py
)
fromkutanaimportPluginplugin=Plugin(name="Echo")@plugin.on_startswith_text("echo")asyncdef_(message,env):awaitenv.reply("{}".format(env.body))
If your function exists only to be decorated, you can use
_
to avoid unnecessary names
可用经理
- vkmanager(用于vk.com组)
- tgmanager(用于telegram.org机器人程序)
document
的类型在kutana内部命名为doc
。TGAttachmentTemp
用于在发送附件之前存储附件 使用send_message
或reply
。附件不能以其他方式上载如果你想从电报下载文件(附件),你必须使用
TGEnvironment.get_file_from_attachment
作者
- michael krukov-@michaelkrukov
- Other contributors