机器人程序框架!!
botje的Python项目详细描述
简介
Botje是一个python3框架,您可以使用它来编写机器人程序。
Botje使您能够编程您自己的模块以启用您自己的命令。
botje包含可用于编程的多个模块。
Botje拥有麻省理工学院无条款许可证。
安装
如果机器人不工作,您可能需要执行以下操作:
bart@okdan:~/botje$ export PYTHONPATH="." bart@okdan:~/botje$ export PYTHONIOENCODING="utf-8"
克隆源:
bart@okdan:~$ hg clone https://bitbucket.org/bthate/botje bart@okdan:~$ cd botje bart@okdan:~/botje$ ./bin/botje --shell
另一个选择是使用pip3下载并全局安装:
bart@okdan:~$ pip3 install botje --upgrade bart@okdan:~$ ./botje --shell
IRC
使用botje irc程序连接到irc服务器。
bart@okdan:~$ botje-irc -n botje -s irc.freenode.net -c \#dunkbots --shell
xmpp
使用botje xmpp连接到xmpp服务器
bart@okdan:~$ botje-xmpp -u monitor@localhost --room test@conference.localhost --shell
用户
需要添加一个用户源代码,以便能够发出bot命令。可以使用meet命令添加用户:
bart@okdan:~$ botje meet user@server user user@server created
要授予用户权限,可以使用perm命令:
bart@okdan:~$ botje perm user@server ps ok user@server
默认的shell用户是root@shell,允许访问所有可用的命令。
编程
用户编程模块是从~/.mods目录中读取的,您可以将.py文件放在那里。
示例:
def hi(event): event.reply("hi %s" % event.origin)
模块
Name | Description |
---|---|
bot | bot package. |
bot.cli | command line interface bot. |
bot.clock | timer, repeater. timed daemon. |
bot.cmds | bot commands package. |
bot.cmds.clock | clock related commands. |
bot.cmds.db | database related commands. |
bot.cmds.doc | documentation related commands. |
bot.cmds.edit | command to edit json files. |
bot.cmds.email | email commands. |
bot.cmds.input | input module. |
bot.cmds.license | license command |
bot.cmds.loader | loader related commands. |
bot.cmds.oper | none |
bot.cmds.rss | rss related commands. |
bot.cmds.test | test commands. |
bot.cmds.users | user management. |
bot.db | access saved json files. |
bot.dcc | direct client to client bot. |
bot.defines | none |
bot.event | event class. |
bot.handler | event handler based on queue.queue. |
bot.irc | irc bot. |
bot.loader | load modules. |
bot.obj | object class with save/load of json files. |
bot.raw | raw output using print. |
bot.rss | rss module (needs feedparser). |
bot.select | select based loop. |
bot.thr | threading module. |
bot.udp | relay txt through a udp port listener. |
bot.users | register an user and give them user , oper or uber permission. |
bot.utils | botje utils package. |
bot.utils.decorators | decorators module. |
bot.utils.log | log module to set standard format of logging. |
bot.utils.shell | shell related functionality. |
bot.utils.time | timed helper functions. |
bot.utils.trace | stack trace helper functions. |
bot.utils.url | functions that fetch data from url. |
bot.xmpp | xmpp bot (requires sleekxmpp). |
命令
现在在Botje有60多个命令可用。
Name | Description |
---|---|
begin | begin stopwatch. |
end | stop stopwatch. |
timer | timer command to schedule a text to be printed on a given time. stopwatch to measure elapsed time. |
attr | show attributes of an object type. |
deleted | show deleted records. |
find | present a list of objects based on prompt input. |
first | show the first record matching the given criteria. |
fix | fix a object by loading and saving it. |
last | show last objectect matching the criteria. |
ls | show subdirs in working directory. |
restore | set deleted=false in selected records. |
rm | set deleted flag on objects. |
today | show last week’s logged objects. |
week | show last week’s logged objects. |
yesterday | show last week’s logged objects. |
cmds | show list of commands. |
man | show descriptions of the available commands. |
mods | show available modules. |
modules | show available modules. |
uptime | show uptime. |
version | show version. |
edit | edit and save objects. |
mbox | convert emails to botje objects. |
log | log some text. |
rss | add a rss url. |
shop | add a shopitem to the shopping list. |
todo | log a todo item. |
tomorrow | show todo items for tomorrow. |
reload | reload a plugin. |
start | start a plugin. |
stop | stop a plugin. |
exit | stop the program. |
load | force a plugin reload. |
pid | show pid of the bot. |
ps | show running threads. |
quit | stop the program. |
reboot | reboot the ldr, allowing statefull reboot (keeping connections alive). |
test | echo origin. |
tinder | loop an command nr of times. |
delperm | delete permissions of an user. |
meet | create an user record. |
perm | add/change permissions of an user. |
permissions | show permissions granted to a user. |
perms | show permission of user. |
u | show user selected by userhost. |
w | show user data. |
联系人
你可以发邮件给我,也可以通过irc/freenode/dunkbots联系我。
在dunkbots irc.freenode.net上创建父节点