diff --git a/.gitignore b/.gitignore index 66427ba..0fc3ef1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -yaboli/__pycache__/ +**/__pycache__/ *.db +*.cookie diff --git a/ExampleBot.py b/ExampleBot.py deleted file mode 100644 index 0a60d0b..0000000 --- a/ExampleBot.py +++ /dev/null @@ -1,21 +0,0 @@ -import asyncio -import yaboli - -class ExampleBot(yaboli.Bot): - async def send(self, room, message): - ping = "ExamplePong!" - short_help = "Example bot for the yaboli bot library" - long_help = "I'm an example bot for the yaboli bot library, which can be found at https://github.com/Garmelon/yaboli" - - await self.botrulez_ping_general(room, message, ping_text=ping) - await self.botrulez_ping_specific(room, message, ping_text=ping) - await self.botrulez_help_general(room, message, help_text=short_help) - await self.botrulez_help_specific(room, message, help_text=long_help) - await self.botrulez_uptime(room, message) - await self.botrulez_kill(room, message) - await self.botrulez_restart(room, message) - - forward = send # should work without modifications for most bots - -bot = ExampleBot("ExampleBot", "examplebot_cookies", rooms=["test", "welcome"]) -asyncio.get_event_loop().run_forever() diff --git a/examplebot.py b/examplebot.py new file mode 100644 index 0000000..01cf376 --- /dev/null +++ b/examplebot.py @@ -0,0 +1,33 @@ +import asyncio + +import yaboli +from yaboli.utils import * +from join_rooms import join_rooms # List of rooms kept in separate file, which is .gitignore'd + + +class ExampleBot(yaboli.Bot): + async def send(self, room, message): + ping = "ExamplePong!" + short_help = "Example bot for the yaboli bot library" + long_help = ( + "I'm an example bot for the yaboli bot library," + " which can be found at https://github.com/Garmelon/yaboli" + ) + + await self.botrulez_ping_general(room, message, text=ping) + await self.botrulez_ping_specific(room, message, text=ping) + await self.botrulez_help_general(room, message, text=short_help) + await self.botrulez_help_specific(room, message, text=long_help) + await self.botrulez_uptime(room, message) + await self.botrulez_kill(room, message, text="/me dies spectacularly") + await self.botrulez_restart(room, message, text="/me restarts spectacularly") + + forward = send # should work without modifications for most bots + +def main(): + bot = ExampleBot("ExampleBot", "examplebot.cookie") + join_rooms(bot) + asyncio.get_event_loop().run_forever() + +if __name__ == "__main__": + main() diff --git a/join_rooms.py b/join_rooms.py new file mode 100644 index 0000000..cd3f3c4 --- /dev/null +++ b/join_rooms.py @@ -0,0 +1,2 @@ +def join_rooms(bot): + bot.join_room("test") diff --git a/yaboli/bot.py b/yaboli/bot.py index 2f0dedf..005706c 100644 --- a/yaboli/bot.py +++ b/yaboli/bot.py @@ -80,20 +80,20 @@ class Bot(Inhabitant): # BOTRULEZ @command("ping", specific=False, args=False) - async def botrulez_ping_general(self, room, message, ping_text="Pong!"): - await room.send(ping_text, message.mid) + async def botrulez_ping_general(self, room, message, text="Pong!"): + await room.send(text, message.mid) @command("ping", specific=True, args=False) - async def botrulez_ping_specific(self, room, message, ping_text="Pong!"): - await room.send(ping_text, message.mid) + async def botrulez_ping_specific(self, room, message, text="Pong!"): + await room.send(text, message.mid) @command("help", specific=False, args=False) - async def botrulez_help_general(self, room, message, help_text="Placeholder help text"): - await room.send(help_text, message.mid) + async def botrulez_help_general(self, room, message, text="Placeholder help text"): + await room.send(text, message.mid) @command("help", specific=True, args=False) - async def botrulez_help_specific(self, room, message, help_text="Placeholder help text"): - await room.send(help_text, message.mid) + async def botrulez_help_specific(self, room, message, text="Placeholder help text"): + await room.send(text, message.mid) @command("uptime", specific=True, args=False) async def botrulez_uptime(self, room, message): @@ -104,13 +104,13 @@ class Bot(Inhabitant): await room.send(text, message.mid) @command("kill", specific=True, args=False) - async def botrulez_kill(self, room, message, kill_text="/me dies"): - await room.send(kill_text, message.mid) + async def botrulez_kill(self, room, message, text="/me dies"): + await room.send(text, message.mid) await self.part_room(room.roomname) @command("restart", specific=True, args=False) - async def botrulez_restart(self, room, message, restart_text="/me restarts"): - await room.send(restart_text, message.mid) + async def botrulez_restart(self, room, message, text="/me restarts"): + await room.send(text, message.mid) await self.part_room(room.roomname) self.join_room(room.roomname, password=room.password)