From bec48eb574765233048f0eddc20bd70999b4eeb7 Mon Sep 17 00:00:00 2001 From: retoor Date: Thu, 13 Feb 2025 10:12:52 +0100 Subject: [PATCH] Update snekbot. --- src/snekbot/bot.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/snekbot/bot.py b/src/snekbot/bot.py index 1245b8a..5533b43 100644 --- a/src/snekbot/bot.py +++ b/src/snekbot/bot.py @@ -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)