wohnungssuche: set admin group from verified chat

This commit is contained in:
missytake 2025-08-10 21:36:12 +02:00
parent 33f3db951a
commit 6f522b1218
Signed by: missytake
GPG key ID: 04CC6658320518DF

View file

@ -2,34 +2,35 @@ import time
import deltachat
from remember_remember_bot.commands import remind_chat, activate_chat, reply, store_file, send_help
from remember_remember_bot.util import check_new_day, update_day
from .commands import activate_chat, reply, send_help, add_keyword, list_keywords, rm_keyword, check_and_forward
def loop(ac: deltachat.Account):
current_day = 0
admin_chat = None
while not admin_chat:
for chat in ac.get_chats():
if chat.is_protected():
if "/start" in [msg.text for msg in chat.get_messages()]:
admin_chat = chat
time.sleep(3)
print(f"Selected {admin_chat.name} as admin chat")
while True:
if check_new_day(current_day):
for chat in ac.get_chats():
remind_chat(chat)
current_day = update_day()
for msg in ac.get_fresh_messages():
handle_incoming_message(msg)
time.sleep(1)
handle_incoming_message(msg, admin_chat)
time.sleep(3)
def handle_incoming_message(msg: deltachat.Message):
print(str(msg.chat.id), msg.text)
if "/start" in msg.text:
def handle_incoming_message(msg: deltachat.Message, admin_chat: deltachat.Chat):
if msg.text.startswith("/start"):
activate_chat(msg)
elif "/stop" in msg.text:
msg.chat.set_ephemeral_timer(0)
reply(msg.chat, "I will stop sending you messages now.", quote=msg)
elif "/file" in msg.text:
if msg.filename:
store_file(msg)
else:
activate_chat(msg)
else:
elif msg.text.startswith("/add"):
add_keyword(msg)
elif msg.text.startswith("/list"):
reply(msg.chat, list_keywords(), quote=msg)
elif msg.text.startswith("/remove"):
rm_keyword(msg.text)
elif msg.text.startswith("/help"):
send_help(msg)
else:
check_and_forward(msg, admin_chat)
msg.mark_seen()