async def cmd_sub(event: Union[events.NewMessage.Event, Message], *_, lang: Optional[str] = None, chat_id: Optional[int] = None, **__): chat_id = chat_id or event.chat_id args = parse_command(event.raw_text) filtered_urls = inner.utils.filter_urls(args) allow_reply = (not event.is_channel or event.is_group) and chat_id == event.chat_id prompt = (i18n[lang]['sub_reply_feed_url_prompt_html'] if allow_reply else i18n[lang]['sub_usage_in_channel_html']) if not filtered_urls: await event.respond(prompt, parse_mode='html', buttons=(Button.force_reply(single_use=True, selective=True, placeholder='url1 url2 url3 ...') if allow_reply else None), reply_to=event.id if event.is_group else None) return msg: Message = await event.respond(i18n[lang]['processing']) sub_result = await inner.sub.subs(chat_id, filtered_urls, lang=lang) if sub_result is None: await msg.edit(prompt, parse_mode='html') return await send_success_and_failure_msg(msg, **sub_result, lang=lang, edit=True)
async def cmd_sub(event: Union[events.NewMessage.Event, Message], *_, lang: Optional[str] = None, **__): args = parse_command(event.raw_text) filtered_urls = inner.utils.filter_urls(args) if not filtered_urls: await event.respond(i18n[lang]['sub_reply_feed_url_prompt_html'] if not event.is_channel or event.is_group else i18n[lang]['sub_usage_in_channel_html'], parse_mode='html', buttons=Button.force_reply( single_use=True, selective=True, placeholder='url1 url2 url3 ...'), reply_to=event.id if event.is_group else None) return msg: Message = await event.respond(i18n[lang]['processing']) sub_result = await inner.sub.subs(event.chat_id, filtered_urls, lang=lang, bypass_url_filter=True) if sub_result is None: await msg.edit(i18n[lang]['sub_reply_feed_url_prompt_html'], parse_mode='html') return await msg.edit(sub_result["msg"], parse_mode='html')
async def cmd_import(event: Union[events.NewMessage.Event, Message], *_, lang: Optional[str] = None, **__): await event.respond( i18n[lang]['send_opml_prompt'], buttons=Button.force_reply( single_use=True, selective=True, placeholder=i18n[lang]['send_opml_reply_placeholder']), reply_to=event.id if event.is_group else None)
async def cmd_import(event: Union[events.NewMessage.Event, Message], *_, chat_id: Optional[int] = None, lang: Optional[str] = None, **__): chat_id = chat_id or event.chat_id await check_sub_limit(event, user_id=chat_id, lang=lang) await event.respond( i18n[lang]['send_opml_prompt'] + ( '\n\n' + i18n[lang]['import_for_channel_or_group_prompt'] if event.is_private else '' ), buttons=Button.force_reply(single_use=True, selective=True, placeholder=i18n[lang]['send_opml_reply_placeholder']), reply_to=event.id if event.is_group else None )
class buttons: main_menu = [[Button.text("🍕 Піца", resize=True, single_use=True), Button.text("🍕 Піца з половинок")], [Button.text("🍕 Конструктор піци"), Button.text("🍗 Снеки")], [Button.text("🍲 Соуси"), Button.text("🥤 Напої")], [Button.text("🛒 Перевірити кошик"), Button.text("📋 Оформити замовлення")], [Button.text("📩 Контактна інформація")]] @staticmethod def halfs_menu(single_click = False): if single_click: btn = Button.text(HalfNizhna.name, resize=True, single_use=True) else: btn = Button.text(HalfNizhna.name, resize=True, selective=True) return [[ btn, Button.text(HalfApetitna.name), Button.text(HalfSitna.name)], [Button.text(HalfSalyami.name), Button.text(HalfSokovita.name), Button.text(HalfFourChese.name)], [Button.text(HalfPikantna.name), Button.text(HalfFourMeat.name), Button.text(HalfNapoliPikantna.name)], [Button.text(HalfPekelna.name), Button.text("↪ Меню")]] @staticmethod def products_menu(previous, chat_id, next, curr_index, product_type = None): return [[Button.inline("⬅ Попередня", f"{product_type}|previous|{previous}".encode("utf-8")), Button.inline("↪ Меню", "back to main".encode("utf-8")), Button.inline("➡ Наступна", f"{product_type}|next|{next}".encode("utf-8"))], [Button.inline("🛒 В кошик", f"{product_type}|choice|{chat_id}|{curr_index}".encode("utf-8"))]] @staticmethod def pizza_from_scratch(previous, chat_id, next, curr_index, message_id = None): return [[Button.inline("⬅", f"i_prev|{message_id}|{previous}".encode("utf-8")), Button.inline("↪ Меню", f"back to main|{message_id}".encode("utf-8")), Button.inline("➡", f"i_next|{message_id}|{next}".encode("utf-8"))], [Button.inline("➕ Додати до піци", f"ingredient|{message_id}|{chat_id}|{curr_index}".encode("utf-8"))], [Button.inline("✅ Додати в кошик", f"pizza is ready|{message_id}|{chat_id}")]] address_buttons = [Button.text("Ввести адресу", resize=True, single_use=True), Button.request_location("Відправити геоданні")] contacts_button = [Button.text("Ввести номер телефону", resize=True, single_use=True), Button.request_phone("Використати телефон аккаунтa")] payment_button = [Button.text("💵 Оплата готівкою", resize=True, single_use=True), Button.text("💳 Оплата на картку")] pizza_basement = [Button.text("Томатний соус", resize=True, single_use=True), Button.text("Вершковий соус")] pizza_basement_cheese = [Button.text("сир Моцарелла", resize=True, single_use=True), Button.text("сир Сулугуні")] wait_for_input = Button.force_reply() clear = Button.clear() @staticmethod def accept_order(chat_id, first_name): return Button.inline("✅ Підтвердити", f"order confirmed|{chat_id}|{first_name}")