Update snekbot.

This commit is contained in:
retoor 2025-02-13 10:12:52 +01:00
parent 8aee6f360d
commit bec48eb574

View File

@ -61,7 +61,7 @@ class Bot:
self.channels = await (await rpc.get_channels())()
for channel in self.channels:
logger.debug("Found channel: " + channel["name"])
self.user = (await (await rpc.get_user(None))()).data
self.user = (await (await rpc.get_user(None))())
logger.debug("Logged in as: " + self.user["username"])
self.join_conversation = False
while True:
@ -78,21 +78,21 @@ class Bot:
except AttributeError:
continue
if data.username == self.user["username"]:
await self.on_own_message(data)
if data.username == self.user.username:
await self.on_own_message(data.channel_uid, message)
elif message.startswith("ping"):
await self.on_ping(data.username, data.user_nick, data.channel_uid, data.message.lstrip("ping ").strip())
elif any([
"@" + self.user["nick"] + " join" in data.message,
"@" + self.user["username"] + " join" in data.message]):
"@" + self.user.nick + " join" in data.message,
"@" + self.user.username + " join" in data.message]):
self.joined.add(data.channel_uid)
await self.on_join(data.channel_uid)
elif any([
"@" + self.user["nick"] + " leave" in data.message,
"@" + self.user["username"] + " leave" in data.message]):
"@" + self.user.nick + " leave" in data.message,
"@" + self.user.username + " leave" in data.message]):
self.joined.remove(data.channel_uid)
await self.on_leave(data.channel_uid)
elif "@" + self.user["nick"] in data.message or "@" + self.user["username"] in data.message:
elif "@" + self.user.nick in data.message or "@" + self.user.username in data.message:
await self.on_mention(data.username, data.user_nick, data.channel_uid, data.message)
else:
await self.on_message(data.username, data.user_nick, data.channel_uid, data.message)