Made random boehh generator.

This commit is contained in:
retoor 2024-12-16 23:25:59 +01:00
parent a28df0371f
commit cc2268afd8

View File

@ -1,7 +1,18 @@
from nio import AsyncClient, RoomMessageText from nio import AsyncClient, RoomMessageText
import random
class BooeehBot: class BooeehBot:
def generate_boeh(self):
boeh = "b"
for _ in range(random.randint(1, 10)):
boeh += "o"
for _ in range(random.randint(1, 5)):
boeh += "e"
for _ in range(random.randint(1, 3)):
boeh += "e"
return boeh
def __init__(self, url, username, password): def __init__(self, url, username, password):
self.url = url self.url = url
self.username = username self.username = username
@ -11,7 +22,7 @@ class BooeehBot:
async def login(self): async def login(self):
try: try:
response = await self.client.login(self.password) response = await self.client.login(self.password)
print(f"User logged in: {self.username}") print(f"Logged in. Serving {self.username}.")
return response return response
except Exception as e: except Exception as e:
print(f"Login error: {e}") print(f"Login error: {e}")
@ -22,7 +33,7 @@ class BooeehBot:
if isinstance(event, RoomMessageText): if isinstance(event, RoomMessageText):
if event.sender == specific_user_id: if event.sender == specific_user_id:
response_text = "booeeeh" response_text = self.generate_boeh()
try: try:
await self.client.room_send( await self.client.room_send(
room.room_id, room.room_id,