36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
import logging
|
||
|
|
||
|
from convopyro import listen_message
|
||
|
from pyrogram import filters
|
||
|
from pyrogram.client import Client
|
||
|
from pyrogram.types import ForceReply, Message, ReplyKeyboardRemove
|
||
|
|
||
|
from modules.utils import string, userSet
|
||
|
|
||
|
logger = logging.getLogger(__name__)
|
||
|
|
||
|
|
||
|
@Client.on_message(
|
||
|
~filters.scheduled
|
||
|
& filters.command(["setcard", "задать карту"], prefixes=["/", ""]) # type: ignore
|
||
|
)
|
||
|
async def command_setcard(app: Client, msg: Message):
|
||
|
await msg.reply_text(
|
||
|
await string("send_number"),
|
||
|
reply_markup=ForceReply(placeholder=await string("enter_number")),
|
||
|
)
|
||
|
answer = await listen_message(app, msg.chat.id, timeout=None)
|
||
|
if answer is None:
|
||
|
return
|
||
|
elif answer.text.strip() in ["/cancel", "cancel", "/відміна", "відміна"]:
|
||
|
await msg.reply_text(await string("cancel"), reply_markup=ReplyKeyboardRemove())
|
||
|
return
|
||
|
userSet(answer.from_user.id, "card", answer.text)
|
||
|
logger.info(f"User {str(msg.from_user.id)} set card id to {answer.text}")
|
||
|
await msg.reply_text(
|
||
|
(await string("card_linked")).format(answer.text),
|
||
|
reply_markup=ReplyKeyboardRemove(),
|
||
|
)
|