This commit is contained in:
retoor 2025-02-01 16:16:25 +01:00
parent 8f891f7d80
commit 9cb2630e41

View File

@ -6,13 +6,13 @@ from snekbot.bot import Bot
class ExampleBot(Bot):
async def on_join(self, data):
print(f"I joined f{data.channel_uid}!")
print(f"I joined {data.channel_uid}!")
async def on_leave(self, data):
print(f"I left f{data.channel_uid}!")
print(f"I left {data.channel_uid}!")
async def on_ping(self, data):
print(f"Ping from f{data.user_nick}")
print(f"Ping from {data.user_nick}")
await self.send_message(
data.channel_uid,
"I should respond with Bong according to BordedDev. So here, bong!",
@ -24,7 +24,7 @@ class ExampleBot(Bot):
async def on_mention(self, data):
message = data.message[len(self.username) + 2 :]
print(f"Mention from f{data.user_nick}: {message}")
print(f"Mention from {data.user_nick}: {message}")
result = f'Hey {data.user_nick}, Thanks for mentioning me "{message}".'
if "source" in message:
@ -41,7 +41,7 @@ class ExampleBot(Bot):
await self.send_message(data.channel_uid, result)
async def on_message(self, data):
print(f"Message from f{data.user_nick}: {data.message}")
print(f"Message from {data.user_nick}: {data.message}")
message = data.message.lower()
result = None
if "hey" in message or "hello" in message:
@ -53,5 +53,5 @@ class ExampleBot(Bot):
await self.send_message(data.channel_uid, result)
bot = ExampleBot(username="example", password="xxxxxx")
bot = ExampleBot(username="example", password="example")
asyncio.run(bot.run())