WIP: Initial commit

This commit is contained in:
Tanguy Herbron 2024-02-15 01:27:13 +01:00
commit b8739a582e
2 changed files with 40 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
session.txt
venv/*

38
main.py Normal file
View File

@ -0,0 +1,38 @@
import simplematrixbotlib as botlib
# TODO
## Add file save to keep count after reboot
## Add secret injection through environment variable
## Add time check to avoid double counts
creds = botlib.Creds("url", "user", "pass")
bot = botlib.Bot(creds)
w_counter = 0
t_counter = 0
printer = "Undskyldpenge\n\
W-{} T-{}"
@bot.listener.on_message_event
async def check_message(room, message):
global w_counter
global t_counter
print(room.room_id)
match = botlib.MessageMatch(room, message, bot)
if match.is_not_from_this_bot() and match.command("undskyldpenge") or match.command("Undskyldpenge"):
print(match.args())
if match.args()[0] == "W":
w_counter = w_counter + 1
if match.args()[0] == "T":
t_counter = t_counter + 1
global printer
await bot.api.send_text_message(room_id=room.room_id, message=printer.format(w_counter, t_counter), msgtype="m.text")
bot.run()