fix: add super calls and fix on_own_message signature in ExampleBot
- Add missing `await super().on_join(channel_uid)` and `await super().on_leave(channel_uid)` calls to ensure parent class lifecycle hooks execute - Update `on_own_message` method signature to include `channel_uid` parameter, aligning with the expected interface
This commit is contained in:
parent
4cbb7d17e3
commit
eeb4593854
@ -40,6 +40,7 @@ from snekbot.bot import Bot
|
|||||||
class ExampleBot(Bot):
|
class ExampleBot(Bot):
|
||||||
|
|
||||||
async def on_join(self, channel_uid):
|
async def on_join(self, channel_uid):
|
||||||
|
await super().on_join(channel_uid)
|
||||||
print(f"I joined!")
|
print(f"I joined!")
|
||||||
await self.send_message(
|
await self.send_message(
|
||||||
channel_uid,
|
channel_uid,
|
||||||
@ -47,6 +48,7 @@ class ExampleBot(Bot):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def on_leave(self, channel_uid):
|
async def on_leave(self, channel_uid):
|
||||||
|
await super().on_leave(channel_uid)
|
||||||
print(f"I left!!")
|
print(f"I left!!")
|
||||||
await self.send_message(
|
await self.send_message(
|
||||||
channel_uid, "I stop actively being part of the conversation now. Bye!"
|
channel_uid, "I stop actively being part of the conversation now. Bye!"
|
||||||
@ -56,7 +58,7 @@ class ExampleBot(Bot):
|
|||||||
print(f"Ping from {user_nick} in channel {channel_uid}: {message}")
|
print(f"Ping from {user_nick} in channel {channel_uid}: {message}")
|
||||||
await self.send_message(channel_uid, "pong " + message)
|
await self.send_message(channel_uid, "pong " + message)
|
||||||
|
|
||||||
async def on_own_message(self, data):
|
async def on_own_message(self, channel_uid, data):
|
||||||
print(f"Received my own message: {data.message}")
|
print(f"Received my own message: {data.message}")
|
||||||
|
|
||||||
async def on_mention(self, username, user_nick, channel_uid, message):
|
async def on_mention(self, username, user_nick, channel_uid, message):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user