async def get_val(message: types.Message) -> None: date: list[str] = list((await cb.build_list_coin()).keys()) await message.reply(text=lazy_get_text( singular=lazy_get_text("доступные валюты"), enable_cache=False), reply_markup=Button.buttons(Button, text=date, call_back=date))
async def wait_language(message: types.Message, state: FSMContext, user: User) -> None: # track('command', message.from_user, command='done_language') if message.text in lang: lazy_get_text.ctx_locale.set(message.text) await message.reply(lazy_get_text('New language is: <b>English</b>'), reply_markup=types.ReplyKeyboardRemove()) await state.finish() else: await message.reply(lazy_get_text('Bad choice.'), reply_markup=keyboard.get_lang(lang))
async def search_json(message: types.Message) -> None: try: await message.reply(helps.format_dict( await io_json_box.get_data_link(url=message.reply_to_message.text)), parse_mode=types.ParseMode.MARKDOWN) except Exception: await State.search_json.set() await message.reply(lazy_get_text("send URL json"), reply_markup=keyboard.keyboard_all( text=lazy_get_text("no search")))
async def cmd_language(message: types.Message, state: FSMContext) -> None: await state.set_state('wait_language') await message.reply(lazy_get_text( 'Choose the language in which you are more comfortable to communicate' ), reply_markup=keyboard.get_lang(lang)) await detect(message.from_user.id, Command.LANGUAGE)
async def process_start_command(message: types.Message) -> None: await State.get_mail.set() await bot.send_message(message.chat.id, text=helps.mes['start'], reply_markup=keyboard.keyboard_all( lazy_get_text("отмена"))) await detect(message.from_user.id, Command.START)
async def return_paste(message: types.Message) -> None: try: await message.reply(await pastebin.send_paste( data=pastebin.generate_data(paste=message.reply_to_message.text))) except Exception as e: await State.send_paste.set() await message.reply(lazy_get_text(f"send paste"))
async def get_mail(message: types.Message, state: FSMContext) -> None: if message.text != lazy_get_text("отмена"): await message.reply("send code") print(1) mail = message.text async with state.proxy() as data: data["passcode"] = checker_mail.get_random_code() checker_mail.build_message(text=data["pass_code"], from_mail=helps.smtp_login, to=mail, subject="test") await checker_mail.async_send_message(start_tls=True) await State.mail_ver.set() await message.reply(text=lazy_get_text("ok"), reply_markup=keyboard.remove_keyboard()) await state.finish()
async def save_json(message: types.Message) -> None: try: await message.reply( await io_json_box.create_box(text=message.reply_to_message.text)) return except Exception as e: print(e) await State.save_json.set() await message.reply(lazy_get_text("send json"))
async def save_json(message: types.Message, state: FSMContext) -> None: if message.text != "no search": await message.reply(helps.format_dict( await io_json_box.get_data_link(url=message.text)), parse_mode=types.ParseMode.MARKDOWN, reply_markup=keyboard.remove_keyboard()) else: await message.reply(lazy_get_text("ok"), reply_markup=keyboard.remove_keyboard()) await state.finish()
async def make_paste(message: types.Message) -> Button.buttons: try: await postgres.connect(helps.POSTGRES) await PastebinTable.create(paste=message.reply_to_message.text, chat_id=message.chat.id) return await message.answer(text=lazy_get_text("какой формат?"), reply_markup=Button.buttons( text=["pastebin", "jsonbox"], call_back=["pastebin", "jsonbox"])) except Exception as e: await message.reply(e) return None
async def inline_echo(inline_query: InlineQuery) -> InlineQueryResultArticle: """ :param inline_query: :return: """ text = inline_query.query res = await bank_api.build_list_coin() crypto = await crypto_price.coin_list() result_id: str = hashlib.sha256(text.encode()).hexdigest() result_list: List[InlineQueryResultArticle] = [] if text in res.keys(): input_content = InputTextMessageContent( lazy_get_text("""название {name} стоимость {name} {valvue}₽ дата {date} """).format(name=text, valvue=res[text]["valvue"], date=bank_api.date)) item = InlineQueryResultArticle( id=result_id, title=lazy_get_text('{name} {valvue}').format( name=text, valvue=res[text]["valvue"]), input_message_content=input_content) elif text in crypto: id_coin = crypto[text]["id"] price = (await crypto_price.simple_price( ids=id_coin, vs_currestring="rub"))[id_coin]["rub"] input_content = InputTextMessageContent( lazy_get_text( """название {name}\nстоимость {name} {valvue}₽\nдата {date} """ ).format(name=text, valvue=price, date=bank_api.date)) item = InlineQueryResultArticle( id=result_id, title=lazy_get_text('{name} {price}').format(name=text, price=price), input_message_content=input_content) elif text == "rub": id_coin = crypto["btc"]["id"] price = (await crypto_price.simple_price( ids=id_coin, vs_currestring="rub"))[id_coin]["rub"] input_content = InputTextMessageContent( lazy_get_text( """название {name}\nстоимость 1 {name} \n{btc} btc\n$ {usd} \nдата {date} """ ).format(name=text, btc=(1 / price), usd=(1 / res["USD"]["valvue"]), date=bank_api.date)) item = InlineQueryResultArticle( id=result_id, title=lazy_get_text('{name} {price} btc ').format(name=text, price=(1 / price)), input_message_content=input_content) else: input_content = InputTextMessageContent( lazy_get_text("нет такой валюты\nдоступные {name}").format( name=list(res.keys()))) result_id: str = hashlib.md5(text.encode()).hexdigest() item = InlineQueryResultArticle( id=result_id, title=lazy_get_text("нет такой валюты"), input_message_content=input_content) result_list.append(item) return await bot.answer_inline_query(inline_query.id, results=result_list, cache_time=1)
async def remove_board(message: types.Message) -> None: await bot.send_message(message.chat.id, text=lazy_get_text("del board"), reply_markup=keyboard.remove_keyboard())
async def qr_make(message: types.Message) -> None: await State.qr.set() await message.answer(lazy_get_text("send link"))
async def got_payment(message: types.Message) -> None: await bot.send_message(message.chat.id, text=lazy_get_text(helps.mes["buy"]), parse_mode='Markdown')
await state.finish() else: await message.reply(lazy_get_text('Bad choice.'), reply_markup=keyboard.get_lang(lang)) @dp.message_handler(commands=['help']) async def process_start_command(message: types.Message) -> None: await bot.send_message( message.chat.id, text=helps.mes["help"], ) await detect(message.from_user.id, Command.HELP) @dp.message_handler(text=lazy_get_text(singular="курсы валют", enable_cache=False)) async def get_val(message: types.Message) -> None: date: list[str] = list((await cb.build_list_coin()).keys()) await message.reply(text=lazy_get_text( singular=lazy_get_text("доступные валюты"), enable_cache=False), reply_markup=Button.buttons(Button, text=date, call_back=date)) @dp.message_handler(commands=["re"]) async def remove_board(message: types.Message) -> None: await bot.send_message(message.chat.id, text=lazy_get_text("del board"), reply_markup=keyboard.remove_keyboard())