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 = get_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
async def bootleggers(client, message): cmd = message.command cmd.pop(0) if not cmd: await message.reply( plate("android_cmd_example", tmp_lang, cmd="bootleggers")) return cmd = cmd[0] # hotfix for some devices that have uppercase codenames if cmd.lower() in ["rmx1971", "x00t", "x01bd", "z01r", "rmx206x"]: cmd = cmd.upper() try: data = await cache.get( "http://downloads.bootleggersrom.xyz/api/devices.json") for codename, info in data.items(): if cmd == codename: xda = "" if info['xdathread']: xda = plate("android_bootleg_xda", tmp_lang, url=info['xdathread']) buttons = InlineKeyboardMarkup([[ InlineKeyboardButton( text=plate("android_button_download", tmp_lang), url=info['download'], ) ]]) await message.reply( plate( "android_bootleg_msgtxt", tmp_lang, name=info['fullname'], maintainer=info['maintainer'], date=info['buildate'], size=get_size(int(info['buildsize'])), folderurl=info['downloadfolder'], XDA=xda, filename=info['filename'], fileurl=info['download'], ), disable_web_page_preview=True, reply_markup=buttons, ) return await message.reply(plate("android_err_notfound", tmp_lang)) except ClientConnectionError: await message.reply(plate("android_err_api", tmp_lang))
async def lineageos(_, message): cmd = message.command cmd.pop(0) if not cmd: await message.reply( LOCAL.PLATE("android_cmd_example", LOCAL.DEFAULT_LANG, cmd=cmd)) return cmd = cmd[0] try: los = await cache.get( f'https://download.lineageos.org/api/v1/{quote_plus(cmd)}/nightly/*' ) response = los['response'] if not response: await message.reply( LOCAL.PLATE("android_err_notfound", LOCAL.DEFAULT_LANG)) return response = response[0] buttons = InlineKeyboardMarkup([[ InlineKeyboardButton( text=LOCAL.PLATE("android_button_download", LOCAL.DEFAULT_LANG), url=response['url'], ) ]]) await message.reply( LOCAL.PLATE( "android_los_msgtxt", LOCAL.DEFAULT_LANG, filename=response['filename'], url=response['url'], size=get_size(int(response['size'])), version=response['version'], ), disable_web_page_preview=True, reply_markup=buttons, ) except ClientConnectionError: await message.reply(LOCAL.PLATE("android_err_api", LOCAL.DEFAULT_LANG))
async def los(message, strings): try: device = get_arg(message) except IndexError: device = "" 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://download.lineageos.org/api/v1/{device}/nightly/*") if fetch.status_code == 200 and len(fetch.json()["response"]) != 0: usr = json.loads(fetch.content) response = usr["response"][0] filename = response["filename"] url = response["url"] buildsize_a = response["size"] buildsize_b = get_size(int(buildsize_a)) version = response["version"] text = (strings["download"]).format(url=url, filename=filename) text += (strings["build_size"]).format(size=buildsize_b) text += (strings["version"]).format(version=version) 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 else: text = strings["err_query"] await message.reply(text, disable_web_page_preview=True)
async def evolutionx(client, message): cmd = message.command cmd.pop(0) if not cmd: await message.reply(plate("android_cmd_example", tmp_lang, cmd="evo")) return cmd = cmd[0] try: # Try to do some cache magic first so we don't download tons of data all the time devices = await cache.get( "https://raw.githubusercontent.com/Evolution-X-Devices/official_devices/master/devices.json" ) if not devices: await message.reply(plate("android_err_api", tmp_lang)) return for d in devices: if d['codename'] == cmd: # find the device text so we can get the deprecated part deprecated = (d['supported_versions'][0]['deprecated'] if "deprecated" in d['supported_versions'][0] else False) evo = await cache.get( f'https://raw.githubusercontent.com/Evolution-X-Devices/official_devices/master/builds/{quote_plus(cmd)}.json' ) # someone messed up the devices.json file. if not evo: await message.reply(plate("android_err_notfound", tmp_lang)) return buttons = InlineKeyboardMarkup([[ InlineKeyboardButton( text=plate("android_button_download", tmp_lang), url=evo['url'], ) ]]) await message.reply( plate( "android_evo_msgtxt", tmp_lang, filename=evo['filename'], url=evo['url'], size=get_size(int(evo['size'])), version=evo['version'], maintainer=evo['maintainer'], telegram_username=evo['telegram_username'], maintained="No" if deprecated else "Yes", ), disable_web_page_preview=True, reply_markup=buttons, ) return # Return early to skip the not found message await message.reply(plate("android_err_notfound", tmp_lang)) except ClientConnectionError: await message.reply(plate("android_err_api", tmp_lang))