Use config files for bots
This commit is contained in:
parent
a78f57db7a
commit
8cd2c8d125
6 changed files with 36 additions and 29 deletions
5
examples/echo/bot.conf
Normal file
5
examples/echo/bot.conf
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[basic]
|
||||
name = EchoBot
|
||||
|
||||
[rooms]
|
||||
test
|
||||
26
examples/echo/echobot.py
Normal file
26
examples/echo/echobot.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import asyncio
|
||||
|
||||
import yaboli
|
||||
|
||||
|
||||
class EchoBot(yaboli.Bot):
|
||||
HELP_GENERAL = "/me echoes back what you said"
|
||||
HELP_SPECIFIC = [
|
||||
"This bot only has one command:",
|
||||
"!echo <text> – reply with exactly <text>",
|
||||
]
|
||||
|
||||
def __init__(self, config_file):
|
||||
super().__init__(config_file)
|
||||
self.register_botrulez()
|
||||
self.register_general("echo", self.cmd_echo)
|
||||
|
||||
async def cmd_echo(self, room, message, args):
|
||||
await message.reply(args.raw)
|
||||
|
||||
async def main():
|
||||
bot = EchoBot("bot.conf")
|
||||
await bot.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue