new trick: leaving rooms
This commit is contained in:
parent
b6ee0f901e
commit
f19f7e8511
4 changed files with 27 additions and 0 deletions
|
|
@ -45,6 +45,11 @@ class DemoBot(SMALBot):
|
|||
self.stop()
|
||||
return
|
||||
|
||||
if msg["content"]["body"] == "!leave":
|
||||
logger.info(f"leaving room {msg['roomid']}")
|
||||
self.leaveroom(msg["roomid"])
|
||||
return
|
||||
|
||||
if msg["content"]["body"].startswith("!echo"):
|
||||
logger.error(f"reply to this: {msg}")
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ class _MXClient:
|
|||
result = checkApiError(r)
|
||||
return result
|
||||
|
||||
def leaveroom(self, roomid):
|
||||
r = lib.apiv0_leaveroom(self.client_id, roomid.encode(encoding="utf-8"))
|
||||
checkApiError(r)
|
||||
|
||||
def process_event(self, evt):
|
||||
if hasattr(self, "on_event") and callable(self.on_event):
|
||||
self.on_event(evt)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue