activate group join codes (text only so far)
This commit is contained in:
parent
b52be982ba
commit
4eb66abcce
|
@ -4,6 +4,7 @@ import time
|
|||
import click
|
||||
import deltachat
|
||||
from deltachat.capi import lib as dclib
|
||||
from deltachat.cutil import as_dc_charpointer
|
||||
|
||||
|
||||
def get_control_group(ac: deltachat.account.Account) -> deltachat.chat.Chat | None:
|
||||
|
@ -70,14 +71,32 @@ def init(ctx, db_path, from_backup) -> None:
|
|||
click.secho(" verificationbot run\n")
|
||||
|
||||
|
||||
def process_command(ac: deltachat.Account, command: deltachat.Message) -> deltachat.Message:
|
||||
def process_command(
|
||||
ac: deltachat.Account, command: deltachat.Message
|
||||
) -> deltachat.Message:
|
||||
"""Handle incoming commands, increment the last_command_id.
|
||||
|
||||
:param ac: deltachat account object of the bot
|
||||
:param command: the deltachat message to be handled
|
||||
:returns the reply to the command
|
||||
"""
|
||||
replytext = "reply to " + command.text
|
||||
if "/help" in command.text:
|
||||
replytext = (
|
||||
"Just send me screenshots of QR codes; "
|
||||
"I will scan them so others can join in on them."
|
||||
)
|
||||
if command.text.startswith("OPENPGP4FPR:"):
|
||||
try:
|
||||
qr = ac.check_qr(command.text)
|
||||
if qr._dc_lot.state() == 512:
|
||||
dclib.dc_set_config_from_qr(ac._dc_context, as_dc_charpointer(command.text))
|
||||
replytext = str(qr._dc_lot.state()) + ". scanned " + command.text
|
||||
except ValueError:
|
||||
replytext = "Not a valid OPENPGP4FPR code"
|
||||
if command.filename:
|
||||
with open(command.filename, "r") as f:
|
||||
ac.qr_join_chat(f)
|
||||
replytext = "scanning QR codes is not supported right now."
|
||||
reply = deltachat.Message.new_empty(ac, "text")
|
||||
reply.set_text(replytext)
|
||||
reply.quote = command
|
||||
|
@ -86,7 +105,9 @@ def process_command(ac: deltachat.Account, command: deltachat.Message) -> deltac
|
|||
assert reply
|
||||
|
||||
|
||||
def get_next_message_from_group(group: deltachat.Chat, last_message_id: int) -> deltachat.Message:
|
||||
def get_next_message_from_group(
|
||||
group: deltachat.Chat, last_message_id: int
|
||||
) -> deltachat.Message:
|
||||
"""Get next message from a Delta Chat group from the ID of the last message.
|
||||
|
||||
:param group: the specific Delta Chat group
|
||||
|
|
Loading…
Reference in a new issue