Add function to check and forward messages
This commit is contained in:
parent
51d6ec297f
commit
f220df12dc
|
|
@ -1,12 +1,4 @@
|
|||
import os
|
||||
|
||||
import deltachat
|
||||
from .util import (
|
||||
chat_is_active,
|
||||
get_file_path,
|
||||
get_lines_from_file,
|
||||
today_lines,
|
||||
)
|
||||
|
||||
|
||||
def setup(email: str, password: str, db: str, debug: bool) -> deltachat.Account:
|
||||
|
|
@ -60,6 +52,16 @@ def rm_keyword(msg: deltachat.Message):
|
|||
msg.account.set_config("ui.keywords", "|".join(current_words))
|
||||
|
||||
|
||||
def check_and_forward(msg: deltachat.Message, admin_chat: deltachat.Chat):
|
||||
"""Check a message for keywords, and forward it to the admin chat if one matches."""
|
||||
for word in list_keywords(msg.account):
|
||||
if word in msg.text:
|
||||
admin_chat.send_msg(msg)
|
||||
print(f"Forwarding message because of '{word}': {msg.text}")
|
||||
break
|
||||
print(f"Not forwarding message without keywords: {msg.text}")
|
||||
|
||||
|
||||
def send_help(msg: deltachat.Message):
|
||||
"""Reply to the user with a help message."""
|
||||
help_text = """
|
||||
|
|
|
|||
Loading…
Reference in a new issue