Implement !kill
This commit is contained in:
parent
a0f7c8e84a
commit
3255ea770e
3 changed files with 18 additions and 4 deletions
|
|
@ -49,7 +49,6 @@ i. e. the text between the end of the "!echo" and the end of the whole message.
|
|||
|
||||
## TODOs
|
||||
|
||||
- [ ] implement !kill
|
||||
- [ ] implement !restart and add an easier way to run bots
|
||||
- [ ] untruncate LiveMessage-s
|
||||
- [ ] config file support for bots, used by default
|
||||
|
|
@ -63,3 +62,4 @@ i. e. the text between the end of the "!echo" and the end of the whole message.
|
|||
- [ ] write project readme
|
||||
- [ ] write examples
|
||||
- [x] implement !uptime for proper botrulez conformity
|
||||
- [x] implement !kill
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class Bot(Client):
|
|||
PING_REPLY: str = "Pong!"
|
||||
HELP_GENERAL: Optional[str] = None
|
||||
HELP_SPECIFIC: Optional[List[str]] = None
|
||||
KILL_REPLY: str = "/me dies"
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
|
@ -79,7 +80,8 @@ class Bot(Client):
|
|||
def register_botrulez(self,
|
||||
ping: bool = True,
|
||||
help_: bool = True,
|
||||
uptime: bool = True
|
||||
uptime: bool = True,
|
||||
kill: bool = False,
|
||||
) -> None:
|
||||
if ping:
|
||||
self.register_general("ping", self.cmd_ping, args=False)
|
||||
|
|
@ -95,6 +97,9 @@ class Bot(Client):
|
|||
if uptime:
|
||||
self.register_specific("uptime", self.cmd_uptime, args=False)
|
||||
|
||||
if kill:
|
||||
self.register_specific("kill", self.cmd_kill, args=False)
|
||||
|
||||
async def cmd_ping(self,
|
||||
room: Room,
|
||||
message: LiveMessage,
|
||||
|
|
@ -127,3 +132,11 @@ class Bot(Client):
|
|||
delta = format_delta(datetime.datetime.now() - self.start_time)
|
||||
text = f"/me has been up since {time} UTC ({delta})"
|
||||
await message.reply(text)
|
||||
|
||||
async def cmd_kill(self,
|
||||
room: Room,
|
||||
message: LiveMessage,
|
||||
args: SpecificArgumentData
|
||||
) -> None:
|
||||
await message.reply(self.KILL_REPLY)
|
||||
await self.part(room)
|
||||
|
|
|
|||
|
|
@ -438,10 +438,11 @@ class Connection:
|
|||
# to http://api.euphoria.io/#packets.
|
||||
|
||||
# First, notify whoever's waiting for this packet
|
||||
packet_id = packet.get("id", None)
|
||||
packet_id = packet.get("id")
|
||||
if packet_id is not None and self._awaiting_replies is not None:
|
||||
future = self._awaiting_replies.get(packet_id, None)
|
||||
future = self._awaiting_replies.get(packet_id)
|
||||
if future is not None:
|
||||
del self._awaiting_replies[packet_id]
|
||||
future.set_result(packet)
|
||||
|
||||
# Then, send the corresponding event
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue