Add !restart command to botrulez
This commit is contained in:
parent
b7579b5b78
commit
b726d8f9f0
4 changed files with 20 additions and 3 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
## Next version
|
||||
|
||||
- add !restart to botrulez
|
||||
|
||||
## 0.2.0 (2019-04-12)
|
||||
|
||||
- change config file format
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ i. e. the text between the end of the "!echo" and the end of the whole message.
|
|||
|
||||
## TODOs
|
||||
|
||||
- [ ] implement !restart
|
||||
- [ ] document yaboli (markdown files in a "docs" folder?)
|
||||
- [ ] cookie support
|
||||
- [ ] fancy argument parsing
|
||||
|
|
@ -74,3 +73,4 @@ i. e. the text between the end of the "!echo" and the end of the whole message.
|
|||
- [x] make it easier to run bots
|
||||
- [x] package in a distutils-compatible way (users should be able to install
|
||||
yaboli using `pip install git+https://github.com/Garmelon/yaboli`)
|
||||
- [x] implement !restart
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ def run(
|
|||
config_file: str = "bot.conf"
|
||||
) -> None:
|
||||
async def _run() -> None:
|
||||
while True:
|
||||
client_ = client(config_file)
|
||||
await client_.run()
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class Bot(Client):
|
|||
HELP_GENERAL: Optional[str] = None
|
||||
HELP_SPECIFIC: Optional[List[str]] = None
|
||||
KILL_REPLY: str = "/me dies"
|
||||
RESTART_REPLY: str = "/me restarts"
|
||||
|
||||
GENERAL_SECTION = "general"
|
||||
ROOMS_SECTION = "rooms"
|
||||
|
|
@ -102,6 +103,7 @@ class Bot(Client):
|
|||
help_: bool = True,
|
||||
uptime: bool = True,
|
||||
kill: bool = False,
|
||||
restart: bool = False,
|
||||
) -> None:
|
||||
if ping:
|
||||
self.register_general("ping", self.cmd_ping, args=False)
|
||||
|
|
@ -120,6 +122,9 @@ class Bot(Client):
|
|||
if kill:
|
||||
self.register_specific("kill", self.cmd_kill, args=False)
|
||||
|
||||
if restart:
|
||||
self.register_specific("restart", self.cmd_restart, args=False)
|
||||
|
||||
async def cmd_ping(self,
|
||||
room: Room,
|
||||
message: LiveMessage,
|
||||
|
|
@ -161,3 +166,12 @@ class Bot(Client):
|
|||
logger.info(f"Killed in &{room.name} by {message.sender.atmention}")
|
||||
await message.reply(self.KILL_REPLY)
|
||||
await self.part(room)
|
||||
|
||||
async def cmd_restart(self,
|
||||
room: Room,
|
||||
message: LiveMessage,
|
||||
args: SpecificArgumentData
|
||||
) -> None:
|
||||
logger.info(f"Restarted in &{room.name} by {message.sender.atmention}")
|
||||
await message.reply(self.RESTART_REPLY)
|
||||
await self.stop()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue