Change botrulez arguments and update examplebot
This commit is contained in:
parent
943537b57a
commit
d9761008f6
5 changed files with 49 additions and 34 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
yaboli/__pycache__/
|
||||
**/__pycache__/
|
||||
*.db
|
||||
*.cookie
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
33
examplebot.py
Normal file
33
examplebot.py
Normal file
|
|
@ -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()
|
||||
2
join_rooms.py
Normal file
2
join_rooms.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
def join_rooms(bot):
|
||||
bot.join_room("test")
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue