async def orangefox(message, strings): API_HOST = "https://api.orangefox.download/v3/" try: args = message.text.split() codename = args[1].lower() except BaseException: codename = "" try: build_type = args[2].lower() except BaseException: build_type = "" if build_type == "": build_type = "stable" if codename in ("devices", ""): text = strings["of_available"].format(build_type=build_type) data = await http.get( API_HOST + f"devices/?release_type={build_type}&sort=device_name_asc" ) devices = json.loads(data.text) try: for device in devices["data"]: text += ( f"\n - {device['full_name']} (<code>{device['codename']}</code>)" ) except BaseException: await message.reply( strings["of_invalid_type"].format(build_type=build_type) ) return if build_type == "stable": text += "\n\n" + strings["of_stable_ex"] elif build_type == "beta": text += "\n\n" + strings["of_beta_ex"] await message.reply(text) return data = await http.get(API_HOST + f"devices/get?codename={codename}") device = json.loads(data.text) if data.status_code == 404: await message.reply(strings["err_query"]) return data = await http.get( API_HOST + f"releases/?codename={codename}&type={build_type}&sort=date_desc&limit=1" ) if data.status_code == 404: btn = strings["of_device_page"] url = f"https://orangefox.download/device/{device['codename']}" button = InlineKeyboardMarkup().add(InlineKeyboardButton(text=btn, url=url)) await message.reply( "⚠️ " + strings["of_no_releases"].format( build_type=build_type, device=device["full_name"] ), reply_markup=button, disable_web_page_preview=True, ) return find_id = json.loads(data.text) for build in find_id["data"]: file_id = build["_id"] data = await http.get(API_HOST + f"releases/get?_id={file_id}") release = json.loads(data.text) if data.status_code == 404: await message.reply(strings["err_query"]) return text = strings["of_header"].format(build_type=build_type) text += (strings["of_device"]).format( fullname=device["full_name"], codename=device["codename"] ) text += (strings["of_version"]).format(version=release["version"]) text += (strings["of_release_date"]).format( date=time.strftime("%d/%m/%Y", time.localtime(release["date"])) ) text += (strings["of_maintainer"]).format(name=device["maintainer"]["name"]) changelog = release["changelog"] try: text += strings["of_changelog"] for entry_num in range(len(changelog)): if entry_num == 10: break text += f" - {changelog[entry_num]}\n" except BaseException: pass btn = strings["dl_btn"] url = release["mirrors"]["DL"] button = InlineKeyboardMarkup().add(InlineKeyboardButton(text=btn, url=url)) await message.reply(text, reply_markup=button, disable_web_page_preview=True) return
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from aiogram.utils.callback_data import CallbackData add_phrase_menu_callback = CallbackData("confirm_burn_menu", "action") add_phrase_menu = InlineKeyboardMarkup( inline_keyboard=[ [ InlineKeyboardButton( "Добавить☑️", callback_data=add_phrase_menu_callback.new(action="add") ), InlineKeyboardButton( "Отменить🔻", callback_data=add_phrase_menu_callback.new(action="cancel") ) ] ] )
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from aiogram.utils.callback_data import CallbackData from loader import db sets_menu_callback = CallbackData("sets_menu", "action", "set_id", "set_name") next_page_btn = InlineKeyboardButton("➡️", callback_data=sets_menu_callback.new( action="next_page", set_id=0, set_name=0)) previous_page_btn = InlineKeyboardButton("⬅️", callback_data=sets_menu_callback.new( action="previous_page", set_id=0, set_name=0)) async def get_sets_menu(user_id: int, page: int = 1): sets_menu = InlineKeyboardMarkup(row_width=2) word_sets = await db.get_sets(user_id, page) for num, word_set in enumerate(word_sets, start=1): sets_menu.insert( InlineKeyboardButton("[{}] {}".format(num, word_set["name"]), callback_data=sets_menu_callback.new( action="open_set", set_name=word_set["name"], set_id=word_set["id"])))
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton back_list = InlineKeyboardMarkup( inline_keyboard=[ [ InlineKeyboardButton(text="Вернуться к списку", callback_data='backlist') ] ] )
from aiogram.types import (InlineKeyboardButton, InlineKeyboardMarkup) from core.strings import LANGUAGE_MAPPING from core.reply_markups.callbacks.language_choice import language_callback available_languages = InlineKeyboardMarkup() available_languages.add(*list( InlineKeyboardButton(lang_name, callback_data=language_callback.new(user_locale=lang)) for lang, lang_name in LANGUAGE_MAPPING.items())) __all__ = ['available_languages']
async def handle_link(message): chat_id = message.chat.id text_link = message.text user_name = message.from_user.first_name user_id = message.from_user.id res_id = 0 for i in text_link.split('/'): try: if float(i) and math.floor(float(i)) == int(i): res_id = int(i) break except BaseException: pass logging.info( f'Receive text from user_name = {user_name}, user_id = {user_id},item_id = {res_id}' ) if not os.path.isfile(f'./df/{user_id}.csv') or res_id != 0: text_template = r'wildberries\.ru\/catalog\/\d*' result = re.findall(text_template, text_link) if len(result) == 1: final_link = f'https://www.{result[0]}/otzyvy' if requests.get(''.join(final_link)).status_code != 200: user_name = message.from_user.first_name user_id = message.from_user.id text = NOT_RESPONSE_LINK % user_name logging.info(f'{user_name, user_id} send not found link') await message.reply(text) else: user_name = message.from_user.first_name user_id = message.from_user.id message_id = message.message_id text = WAITING_TEXT % user_name logging.info(f'{user_name, user_id} is knocking to our bot') await bot.send_message(chat_id, text) # sku из html кода sku_html = final_link[35:-7] file_name = f'./input/file_{sku_html}_{user_id}_{message_id}.jl' parser(final_link, file_name) text = FINAL_TEXT await bot.send_message(chat_id, text) get_df(file_name, user_id) if not os.path.isfile(f'./df/{user_id}.csv'): text = SMALL_COMMENTS % user_name logging.info( f'{user_name, user_id} semd link with small count of comments' ) await message.reply(text, reply_markup=ReplyKeyboardRemove()) else: text, tf_idf_indexes = tf_idf(file_name, user_id) output_name = f'./output/plot_{file_name[8:-2]}.jpg' word_cloud_output(tf_idf_indexes, output_name) await bot.send_photo(chat_id, photo=open(output_name, 'rb')) if os.path.isfile(output_name): os.remove(output_name) if text[0] != 'Мало комментариев': buttons_k = [] for i in range(len(text)): buttons_k.append(KeyboardButton(text[i])) markup = ReplyKeyboardMarkup(row_width=1, resize_keyboard=True) markup.add(*buttons_k) await message.answer( 'Нажми на слово или напиши что-то своё', reply_markup=markup) else: await message.reply(text, reply_markup=ReplyKeyboardRemove()) else: text = NOT_TARGET_TEXT_LINK % user_name await message.reply(text) else: chat_id = message.chat.id user_name = message.from_user.first_name user_id = message.from_user.id message_id = message.message_id word = message.text.lower() # сохраняем датафрейм комментов по топикам similar_comments_(word, nlp, user_id) if not os.path.isfile(f'./similarity/{user_id}_{word}.csv'): await message.reply(CHANGE_QUERY_TEXT) word_pos = word + 'p' word_neg = word + 'n' word_neu = word + 'a' # кнопки sentiments button_sent_p = InlineKeyboardButton('Положительные отзывы', callback_data=f'sent_{word_pos}') button_sent_n = InlineKeyboardButton('Отрицательные отзывы', callback_data=f'sent_{word_neg}') button_sent_all = InlineKeyboardButton( 'Все отзывы', callback_data=f'sent_{word_neu}') markup_sent = InlineKeyboardMarkup(row_width=1) markup_sent.add(button_sent_p, button_sent_n, button_sent_all) await message.answer('Какие отзывы тебе нужны?', reply_markup=markup_sent)
from aiogram import types from aiogram.dispatcher import FSMContext from aiogram.dispatcher.filters import Text from aiogram.dispatcher.filters.state import StatesGroup, State from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup, ParseMode from aiogram.utils.emoji import emojize import aiogram.utils.markdown as md from telegram_bot.misc import dp, bot, ids, admin import telegram_bot.handlers.count_engine as count_engine bt_right = InlineKeyboardButton(text='Right?', callback_data='right') bt_start = InlineKeyboardButton(text='No, again.', callback_data='not_right') kb = InlineKeyboardMarkup().add(bt_right, bt_start) class Form(StatesGroup): gas_num = State() gas_rub = State() water = State() el1 = State() el2 = State() class AddForm(StatesGroup): add_mouth = State() add_gas = State() def is_number(msg): ''' check is number
def menu_profile_history(user:User) -> InlineKeyboardMarkup: """Возвращает кнопку "Назад" в истории платежей пользователя""" keyboard = InlineKeyboardMarkup() keyboard.add(InlineKeyboardButton(text=get_text_but(user, 'profile_menu_back'), callback_data="menu_profile_history_back")) return keyboard
def course_back_in_list(user: User) -> InlineKeyboardMarkup: """Вовзращает кнопку "Назад" при выборе какого-либо курса""" keyboard = InlineKeyboardMarkup() keyboard.add(InlineKeyboardButton(text=get_text_but(user, 'profile_menu_back'), callback_data="course_back_in_list")) return keyboard
from aiogram.types import ReplyKeyboardRemove, \ ReplyKeyboardMarkup, KeyboardButton, \ InlineKeyboardMarkup, InlineKeyboardButton inline_btn_reg = InlineKeyboardButton('Регистрация!', callback_data='button_reg') inline_btn_auth = InlineKeyboardButton('Аунтефикация!', callback_data='button_auth') inline_btn_battle = InlineKeyboardButton('В БОЙ!', callback_data='button_battle') inline_btn_quit = InlineKeyboardButton('Выйти', callback_data='button_quit') # Move button inline_btn_up = InlineKeyboardButton('Вверх', callback_data='button_up') inline_btn_down = InlineKeyboardButton('Вниз', callback_data='button_down') inline_btn_left = InlineKeyboardButton('Влево', callback_data='button_left') inline_btn_right = InlineKeyboardButton('Вправо', callback_data='button_right') inline_kb_start = InlineKeyboardMarkup().add(inline_btn_reg, inline_btn_auth) inline_kb_re_auth = InlineKeyboardMarkup(row_width=2).add(inline_btn_auth) inline_kb_battle = InlineKeyboardMarkup(row_width=1).add( inline_btn_battle, inline_btn_quit) inline_kb_move = InlineKeyboardMarkup(row_width=2).add(inline_btn_up, inline_btn_down, inline_btn_left, inline_btn_right)
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from keyboards.inline.callback_data import html_customization_callback html_customizations_keyboard = InlineKeyboardMarkup( row_width=1, inline_keyboard=[[ InlineKeyboardButton( text="Default", callback_data=html_customization_callback.new(type="default")), InlineKeyboardButton( text="Presets", callback_data=html_customization_callback.new(type="presets")), InlineKeyboardButton( text="Set", callback_data=html_customization_callback.new(type="set")), ]])
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from keyboards.inline.callback_data import settings_callback bot_settings = InlineKeyboardMarkup(row_width=1, inline_keyboard=[ [ InlineKeyboardButton(text="Обратить перевод 🔁", callback_data=settings_callback.new( settings_item="reverse_translate")) ], [ InlineKeyboardButton(text="Рекомендации ✅", callback_data=settings_callback.new( settings_item="recommendation" )) ], [ InlineKeyboardButton(text="Полная инструкция 📄", callback_data=settings_callback.new( settings_item="instruction" )) ] ] )
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from keyboards.inline_keyboards.callbacks_data import menu_callback instructions_main_buttons = InlineKeyboardMarkup(inline_keyboard=[ [ InlineKeyboardButton(text='Инструкции для асфальта', callback_data=menu_callback.new( button_name='instruction_asphalt', type='simple')) ], [ InlineKeyboardButton(text='Инструкции для щебня', callback_data=menu_callback.new( button_name='instruction_sheben', type='simple')) ], [ InlineKeyboardButton(text='Инструкции для ПГС', callback_data=menu_callback.new( button_name='instruction_pgs', type='simple')) ], [ InlineKeyboardButton(text='Инструкции для грунта', callback_data=menu_callback.new( button_name='instruction_grunt', type='simple')) ], [ InlineKeyboardButton(text='Инструкции для бетона', callback_data=menu_callback.new( button_name='instruction_beton',
async def evo(message, strings): try: device = get_arg(message) except IndexError: device = "" if device == "x00t": device = "X00T" if device == "x01bd": device = "X01BD" if device == "": text = strings["cmd_example"].format(cmd=get_cmd(message)) await message.reply(text, disable_web_page_preview=True) return fetch = await http.get( f"https://raw.githubusercontent.com/Evolution-X-Devices/official_devices/master/builds/{device}.json" ) if fetch.status_code in [500, 504, 505]: await message.reply(strings["err_github"]) return if fetch.status_code == 200: try: usr = json.loads(fetch.content) filename = usr["filename"] url = usr["url"] version = usr["version"] maintainer = usr["maintainer"] maintainer_url = usr["telegram_username"] size_a = usr["size"] size_b = convert_size(int(size_a)) text = (strings["download"]).format(url=url, filename=filename) text += (strings["build_size"]).format(size=size_b) text += (strings["android_version"]).format(version=version) text += (strings["maintainer"]).format( name=f"<a href='{maintainer_url}'>{maintainer}</a>" ) btn = strings["dl_btn"] keyboard = InlineKeyboardMarkup().add( InlineKeyboardButton(text=btn, url=url) ) await message.reply( text, reply_markup=keyboard, disable_web_page_preview=True ) return except ValueError: text = strings["err_ota"] await message.reply(text, disable_web_page_preview=True) return elif fetch.status_code == 404: text = strings["err_query"] await message.reply(text, disable_web_page_preview=True) return
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup from keyboards.callbackdatas.subscription_preferences_callbackdata import subscription_preferences_callback keyboard = InlineKeyboardMarkup(inline_keyboard=[ [ InlineKeyboardButton( text="На следующий день", callback_data=subscription_preferences_callback.new( type="daily", subtype="next", time="none", group="none", set=0)) ], [ InlineKeyboardButton(text="На текущий день", callback_data=subscription_preferences_callback. new(type="daily", subtype="current", time="none", group="none", set=0)) ], [ InlineKeyboardButton(text="Отменить настройку подписки", callback_data='cancel_subscription_setup') ] ])
def create(Info: str, info_message: int): add_typing_button = InlineKeyboardButton('Ввести вручную', callback_data=f'add_product_typing_{Info}') add_photo_button = InlineKeyboardButton('Сфотографировать', callback_data=f'add_product_photo_choice_{Info}') return InlineKeyboardMarkup(inline_keyboard=[[add_typing_button, add_photo_button]])
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from aiogram.utils import executor from aiogram.utils.markdown import text from STEP.config import TOKEN bot = Bot(token=TOKEN) dp = Dispatcher(bot) init_list = [] # В этот список записываем инициалы start_text = text( "Приветствую.\nЭто бот для добавления инициалов и их вывода.", "\nДля добавления или показа инициалов воспользуйтесь кнопками ниже:") # Инлайн кнопки btn_add_fn = InlineKeyboardButton("Добавить инициал имени", callback_data='btnf') # fn - first name btn_add_ln = InlineKeyboardButton("Добавить инициал фамилии", callback_data='btnl') # ln - last name btn_show = InlineKeyboardButton("Показать инициалы", callback_data='btns') markup = InlineKeyboardMarkup().add(btn_add_fn, btn_add_ln).row(btn_show) markup2 = InlineKeyboardMarkup().row(btn_add_fn, btn_add_ln, btn_show) # Команда "Старт" @dp.message_handler(commands='start') async def start(message: types.Message): await bot.send_message(message.from_user.id, start_text, reply_markup=markup)
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup from keyboards.inline.callback_datas import movie_callback # Кнопки для выбора способа публикации на сайте run_choice = InlineKeyboardMarkup( inline_keyboard=[[ InlineKeyboardButton(text="📄 Добавить описание и опубликовать 📄", callback_data="add_text"), ], [ InlineKeyboardButton(text="📺 Опубликовать на сайте 📺", callback_data="run_sender") ]]) # Отображает начало публикации running = InlineKeyboardMarkup(inline_keyboard=[[ InlineKeyboardButton(text="⏳ Публикую ⏳", callback_data="running"), ]]) # Создает кнопку с ссылкой на опупликованный фильм def url_movies(url): url_movie = InlineKeyboardMarkup(inline_keyboard=[[ InlineKeyboardButton(text="✅ Опубликовано ✅", url=url) ]]) return url_movie # Кнопки выбора типа данных type_choice = InlineKeyboardMarkup(inline_keyboard=[[ InlineKeyboardButton(text="Фильм 👈", callback_data="movies"),
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton choose_language = InlineKeyboardMarkup(inline_keyboard=[ [InlineKeyboardButton(text="Українська", callback_data="lang_uk")], [ InlineKeyboardButton(text="Русский", callback_data="lang_ru"), InlineKeyboardButton(text="English", callback_data="lang_en"), ] ])
def url_movies(url): url_movie = InlineKeyboardMarkup(inline_keyboard=[[ InlineKeyboardButton(text="✅ Опубликовано ✅", url=url) ]]) return url_movie
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from keyboards.inline.callback_datas import direction_callback directions_keyboard = InlineKeyboardMarkup() to_metro_button = InlineKeyboardButton( 'К метро', callback_data=direction_callback.new(direction='to')) from_metro_button = InlineKeyboardButton( 'В потапово', callback_data=direction_callback.new(direction='from')) directions_keyboard.add(to_metro_button) directions_keyboard.add(from_metro_button)
async def check(message): try: msg_args = message.text.split() temp = msg_args[1] csc = msg_args[2] except IndexError: m = f"Please type your device <b>MODEL</b> and <b>CSC</b> into it!\ni.e <code>/{get_cmd(message)} SM-J710MN ZTO</code>!" await message.reply(m) return model = "sm-" + temp if not temp.upper().startswith("SM-") else temp async with httpx.AsyncClient(http2=True) as http: fota = await http.get( f"http://fota-cloud-dn.ospserver.net/firmware/{csc.upper()}/{model.upper()}/version.xml" ) test = await http.get( f"http://fota-cloud-dn.ospserver.net/firmware/{csc.upper()}/{model.upper()}/version.test.xml" ) await http.aclose() if test.status_code != 200: m = f"Couldn't find any firmwares for {temp.upper()} - {csc.upper()}, please refine your search or try again later!" await message.reply(m) return page1 = BeautifulSoup(fota.content, "lxml") page2 = BeautifulSoup(test.content, "lxml") os1 = page1.find("latest").get("o") os2 = page2.find("latest").get("o") if page1.find("latest").text.strip(): pda1, csc1, phone1 = page1.find("latest").text.strip().split("/") m = f"<b>MODEL:</b> <code>{model.upper()}</code>\n<b>CSC:</b> <code>{csc.upper()}</code>\n\n" m += "<b>Latest available firmware:</b>\n" m += f"• PDA: <code>{pda1}</code>\n• CSC: <code>{csc1}</code>\n" if phone1: m += f"• Phone: <code>{phone1}</code>\n" if os1: m += f"• Android: <code>{os1}</code>\n" m += "\n" else: m = f"<b>No public release found for {model.upper()} and {csc.upper()}.</b>\n\n" m += "<b>Latest test firmware:</b>\n" if len(page2.find("latest").text.strip().split("/")) == 3: pda2, csc2, phone2 = page2.find("latest").text.strip().split("/") m += f"• PDA: <code>{pda2}</code>\n• CSC: <code>{csc2}</code>\n" if phone2: m += f"• Phone: <code>{phone2}</code>\n" if os2: m += f"• Android: <code>{os2}</code>\n" else: md5 = page2.find("latest").text.strip() m += f"• Hash: <code>{md5}</code>\n• Android: <code>{os2}</code>\n" if get_cmd(message) == "samcheck": await message.reply(m) elif get_cmd(message) == "samget": m += "\n<b>Download from below:</b>\n" buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton( "SamMobile", url="https://www.sammobile.com/samsung/firmware/{}/{}/".format( model.upper(), csc.upper() ), ), InlineKeyboardButton( "SamFw", url="https://samfw.com/firmware/{}/{}/".format( model.upper(), csc.upper() ), ), InlineKeyboardButton( "SamFrew", url="https://samfrew.com/model/{}/region/{}/".format( model.upper(), csc.upper() ), ), ) await message.reply(m, reply_markup=buttons)
def create_kb_current_requests(processing_req, ready_req): keyboard = InlineKeyboardMarkup() current_date = datetime.today().strftime('%d.%m') if len(processing_req) != 0: for request in processing_req: if not current_date == request[0]: date_request = '(' + request[0] + ') ' else: date_request = '' type_operation = all_emoji[request[3]] number_request = request[2] request_id = request[1] status_operation = all_emoji[request[11]] # добавляем плюсы только для отображения rub, usd, eur = set_minus_and_plus_currences.set_minus_and_plus(request) if (rub != '' and usd != '') or (rub != '' and eur != ''): rub = rub + ', ' if usd != '' and eur != '': usd = usd + ', ' keyboard.add ( InlineKeyboardButton ( text = '{}{} N{} {} {}{}{}'.format(date_request, type_operation, number_request, status_operation, rub, usd, eur), callback_data = cb_current_requests.new ( id=request_id, type_btn='get_request' ) ) ) if len(ready_req) != 0: for request in ready_req: if not current_date == request[0]: date_request = '(' + request[0] + ') ' else: date_request = '' type_operation = all_emoji[request[3]] number_request = request[2] request_id = request[1] status_operation = all_emoji[request[11]] # добавляем плюсы только для отображения rub, usd, eur = set_minus_and_plus_currences.set_minus_and_plus(request) if (rub != '' and usd != '') or (rub != '' and eur != ''): rub = rub + ', ' if usd != '' and eur != '': usd = usd + ', ' keyboard.add ( InlineKeyboardButton ( text = '{}{} N{} {} {}{}{}'.format(date_request, type_operation, number_request, status_operation, rub, usd, eur), callback_data = cb_current_requests.new ( id=request_id, type_btn='get_request' ) ) ) back__main_menu = all_emoji['back__main_menu'] keyboard.add ( InlineKeyboardButton ( text=f'назад {back__main_menu} главное меню', callback_data=cb_current_requests.new ( id='-', type_btn='exit' ) ) ) return keyboard
async def orangefox(message): API_HOST = "https://api.orangefox.download/v3/" try: args = message.text.split() codename = args[1].lower() except BaseException: codename = "" try: build_type = args[2].lower() except BaseException: build_type = "" if build_type == "": build_type = "stable" if codename == "devices" or codename == "": reply_text = ( f"<b>OrangeFox Recovery <i>{build_type}</i> is currently avaible for:</b>" ) async with httpx.AsyncClient(http2=True) as http: data = await http.get( API_HOST + f"devices/?release_type={build_type}&sort=device_name_asc" ) devices = json.loads(data.text) await http.aclose() try: for device in devices["data"]: reply_text += ( f"\n - {device['full_name']} (<code>{device['codename']}</code>)" ) except BaseException: await message.reply( f"'<b>{build_type}</b>' is not a type of build available, the types are just '<b>beta</b>' or '<b>stable</b>'." ) return if build_type == "stable": reply_text += ( "\n\n" + f"To get the latest Stable release use <code>/ofox (codename)</code>, for example: <code>/ofox raphael</code>" ) elif build_type == "beta": reply_text += ( "\n\n" + f"To get the latest Beta release use <code>/ofox (codename) beta</code>, for example: <code>/ofox raphael beta</code>" ) await message.reply(reply_text) return async with httpx.AsyncClient(http2=True) as http: data = await http.get(API_HOST + f"devices/get?codename={codename}") device = json.loads(data.text) await http.aclose() if data.status_code == 404: await message.reply("Device is not found!") return async with httpx.AsyncClient(http2=True) as http: data = await http.get( API_HOST + f"releases/?codename={codename}&type={build_type}&sort=date_desc&limit=1" ) if data.status_code == 404: btn = "Device's page" url = f"https://orangefox.download/device/{device['codename']}" button = InlineKeyboardMarkup().add(InlineKeyboardButton(text=btn, url=url)) await message.reply( f"⚠️ There is no '<b>{build_type}</b>' releases for <b>{device['full_name']}</b>.", reply_markup=button, disable_web_page_preview=True, ) return find_id = json.loads(data.text) await http.aclose() for build in find_id["data"]: file_id = build["_id"] async with httpx.AsyncClient(http2=True) as http: data = await http.get(API_HOST + f"releases/get?_id={file_id}") release = json.loads(data.text) await http.aclose() if data.status_code == 404: await message.reply("Release is not found!") return reply_text = f"<u><b>OrangeFox Recovery <i>{build_type}</i> release</b></u>\n" reply_text += (" <b>Device:</b> {fullname} (<code>{codename}</code>)\n").format( fullname=device["full_name"], codename=device["codename"] ) reply_text += (" <b>Version:</b> {}\n").format(release["version"]) reply_text += (" <b>Release date:</b> {}\n").format( time.strftime("%d/%m/%Y", time.localtime(release["date"])) ) reply_text += (" <b>Maintainer:</b> {name}\n").format( name=device["maintainer"]["name"] ) changelog = release["changelog"] try: reply_text += " <u><b>Changelog:</b></u>\n" for entry_num in range(len(changelog)): if entry_num == 10: break reply_text += f" - {changelog[entry_num]}\n" except BaseException: pass btn = "⬇️ Download" url = release["mirrors"]["DL"] button = InlineKeyboardMarkup().add(InlineKeyboardButton(text=btn, url=url)) await message.reply(reply_text, reply_markup=button, disable_web_page_preview=True) return
def create_inline_callback_button(text, callback_data): return InlineKeyboardButton(text=text, callback_data=callback_data)
@dp.message_handler(commands=['corm']) async def kz(message: types.Message): await bot.send_message(message.from_user.id, text="Выберите тип измельчителя кормов", reply_markup=inline_corm) @dp.message_handler(commands=['divide']) async def kz(message: types.Message): await bot.send_message(message.from_user.id, text="🔌/🚜", reply_markup=inline_divide) @dp.message_handler(commands=['elec']) async def kz(message: types.Message): await bot.send_message(message.from_user.id, text="У нас есть много типов электрических дробилок. Выбирайте по мощности!", reply_markup=inline_elec) #choose inline_drobilka_ru = InlineKeyboardMarkup() inline_zhem = InlineKeyboardButton("торговля кормами🌾", callback_data='zh') inline_mal = InlineKeyboardButton("домашний скот🐑", callback_data='mall_ru') inline_drobilka_ru.insert(inline_zhem) inline_drobilka_ru.insert(inline_mal) #end #corm inline_corm = InlineKeyboardMarkup() uni_zhem_shop11 = InlineKeyboardButton("Подача 11кВт при ~ 380 вольт🔌 ", callback_data='uni_zh11') uni_zhem_shop15 = InlineKeyboardButton("Подача 15кВт при ~ 380 вольт 🔌 ", callback_data='uni_zh15') uni_zhem_shop18_5 = InlineKeyboardButton("Подача 18.5кВт при ~ 380 вольт🔌 ", callback_data='uni_zh18_5') uni_zhem_shop22 = InlineKeyboardButton("Подача 22кВт при ~ 380 вольт 🔌", callback_data='uni_zh22') inline_corm.insert(uni_zhem_shop11) inline_corm.insert(uni_zhem_shop15) inline_corm.insert(uni_zhem_shop18_5)
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton edit = InlineKeyboardButton(text='Редактировать профиль', callback_data='edit_diesel') cancel = InlineKeyboardButton(text='Отмена', callback_data='cancel') edit_diesel_profiles = InlineKeyboardMarkup().add(edit).add(cancel)
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton canteen_quantity_all_panel = InlineKeyboardMarkup( inline_keyboard=[ [ InlineKeyboardButton(text='Все', callback_data='canteen_quantity_all'), InlineKeyboardButton(text='Выйти', callback_data='canteen_write_food_exit') ] ] )
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from keyboards.inline.callback_datas import buy_callback choice = InlineKeyboardMarkup( row_width=2, inline_keyboard=[[ InlineKeyboardButton(text="Beer", callback_data="buy:Beer:1"), InlineKeyboardButton(text="Cola", callback_data="buy:Cola:1") ], [InlineKeyboardButton(text="Close", callback_data="cancel")]]) beer_keyboard = InlineKeyboardMarkup() BEER_LINK = "https://hoegaarden.com/" beer_link = InlineKeyboardButton(text="Buy here", url=BEER_LINK) beer_keyboard.insert(beer_link)
async def check(message, strings): try: msg_args = message.text.split() temp = msg_args[1] csc = msg_args[2] except IndexError: text = strings["sam_cmd_example"].format(cmd=get_cmd(message)) await message.reply(text) return model = "sm-" + temp if not temp.upper().startswith("SM-") else temp fota = await http.get( f"http://fota-cloud-dn.ospserver.net/firmware/{csc.upper()}/{model.upper()}/version.xml" ) test = await http.get( f"http://fota-cloud-dn.ospserver.net/firmware/{csc.upper()}/{model.upper()}/version.test.xml" ) if test.status_code != 200: text = strings["err_sam"].format(model=temp.upper(), csc=csc.upper()) await message.reply(text) return page1 = BeautifulSoup(fota.content, "lxml") page2 = BeautifulSoup(test.content, "lxml") os1 = page1.find("latest").get("o") os2 = page2.find("latest").get("o") if page1.find("latest").text.strip(): pda1, csc1, phone1 = page1.find("latest").text.strip().split("/") text = f"<b>MODEL:</b> <code>{model.upper()}</code>\n<b>CSC:</b> <code>{csc.upper()}</code>\n\n" text += strings["sam_latest"] text += f"• PDA: <code>{pda1}</code>\n• CSC: <code>{csc1}</code>\n" if phone1: text += f"• Phone: <code>{phone1}</code>\n" if os1: text += f"• Android: <code>{os1}</code>\n" text += "\n" else: text = strings["err_sam_pub"].format(model=model.upper(), csc=csc.upper()) text += strings["sam_test"] if len(page2.find("latest").text.strip().split("/")) == 3: pda2, csc2, phone2 = page2.find("latest").text.strip().split("/") text += f"• PDA: <code>{pda2}</code>\n• CSC: <code>{csc2}</code>\n" if phone2: text += f"• Phone: <code>{phone2}</code>\n" if os2: text += f"• Android: <code>{os2}</code>\n" else: md5 = page2.find("latest").text.strip() text += f"• Hash: <code>{md5}</code>\n• Android: <code>{os2}</code>\n" if get_cmd(message) == "samcheck": await message.reply(text) elif get_cmd(message) == "samget": text += strings["sam_down_from"] buttons = InlineKeyboardMarkup() buttons.insert( InlineKeyboardButton( "SamMobile", url="https://www.sammobile.com/samsung/firmware/{}/{}/".format( model.upper(), csc.upper() ), ) ) buttons.insert( InlineKeyboardButton( "SamFw", url="https://samfw.com/firmware/{}/{}/".format( model.upper(), csc.upper() ), ) ) buttons.insert( InlineKeyboardButton( "SamFrew", url="https://samfrew.com/model/{}/region/{}/".format( model.upper(), csc.upper() ), ) ) await message.reply(text, reply_markup=buttons)