small refactoring
This commit is contained in:
parent
09feb1a61c
commit
e5aa04fada
|
@ -38,16 +38,6 @@ def activate_chat(msg: deltachat.Message):
|
||||||
remind_user(msg.get_sender_contact())
|
remind_user(msg.get_sender_contact())
|
||||||
|
|
||||||
|
|
||||||
def handle_incoming_message(msg: deltachat.Message):
|
|
||||||
print(str(msg.chat.id), msg.text)
|
|
||||||
if "/start" in msg.text:
|
|
||||||
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)
|
|
||||||
msg.mark_seen()
|
|
||||||
|
|
||||||
|
|
||||||
def reply(
|
def reply(
|
||||||
chat: deltachat.Chat,
|
chat: deltachat.Chat,
|
||||||
text: str,
|
text: str,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import time
|
||||||
|
|
||||||
import deltachat
|
import deltachat
|
||||||
|
|
||||||
from remember_remember_bot.commands import remind_user, handle_incoming_message
|
from remember_remember_bot.commands import remind_user, activate_chat, reply
|
||||||
from remember_remember_bot.util import check_new_day, update_day
|
from remember_remember_bot.util import check_new_day, update_day
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,3 +19,15 @@ def loop(ac: deltachat.Account):
|
||||||
for msg in ac.get_fresh_messages():
|
for msg in ac.get_fresh_messages():
|
||||||
handle_incoming_message(msg)
|
handle_incoming_message(msg)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_incoming_message(msg: deltachat.Message):
|
||||||
|
print(str(msg.chat.id), msg.text)
|
||||||
|
if "/start" in msg.text:
|
||||||
|
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)
|
||||||
|
msg.mark_seen()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue