WIP: Initial commit
This commit is contained in:
commit
b8739a582e
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
session.txt
|
||||||
|
venv/*
|
38
main.py
Normal file
38
main.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user