Formatting.

This commit is contained in:
retoor 2024-12-16 23:19:22 +01:00
parent b745d310fd
commit a28df0371f
2 changed files with 17 additions and 21 deletions

View File

@ -1,7 +1,6 @@
import asyncio
import os
from nio import AsyncClient, RoomMessageText
class BooeehBot:
def __init__(self, url, username, password):
self.url = url
@ -19,7 +18,7 @@ class BooeehBot:
return None
async def handle_message(self, room, event):
specific_user_id = '@joewilliams007:matrix.org'
specific_user_id = "@joewilliams007:matrix.org"
if isinstance(event, RoomMessageText):
if event.sender == specific_user_id:
@ -28,10 +27,7 @@ class BooeehBot:
await self.client.room_send(
room.room_id,
message_type="m.room.message",
content={
"msgtype": "m.text",
"body": response_text
}
content={"msgtype": "m.text", "body": response_text},
)
print(f"Response to {event.sender}: " + response_text)
except Exception as e:
@ -48,6 +44,3 @@ class BooeehBot:
async def stop(self):
await self.client.close()

View File

@ -1,6 +1,7 @@
import asyncio
from boeh import env
from boeh import BooeehBot
from boeh import BooeehBot, env
async def main_async():
url = "https://matrix.org"
@ -13,8 +14,10 @@ async def main_async():
except KeyboardInterrupt:
await bot.stop()
def main():
asyncio.run(main_async())
if __name__ == "__main__":
main()