Пример #1
0
async def whois(client, message):
    cmd = message.command
    if not message.reply_to_message and len(cmd) == 1:
        get_user = message.from_user.id
    elif len(cmd) == 1:
        get_user = message.reply_to_message.from_user.id
    elif len(cmd) > 1:
        get_user = cmd[1]
        try:
            get_user = int(cmd[1])
        except ValueError:
            pass
    try:
        user = await client.get_users(get_user)
    except PeerIdInvalid:
        await message.reply(plate("generic_unknown_user", tmp_lang))
        return

    desc = await client.get_chat(get_user)
    desc = desc.description
    info_text = plate(
        "info_infotext",
        tmp_lang,
        user_id=user.id,
        first_name=user.first_name if user.first_name else "",
        last_name=user.last_name if user.last_name else "",
        username=user.username if user.username else "",
        last_online=last_online(user),
        seen_chats=0,
        bio=desc if desc else plate("info_no_bio", tmp_lang),
    )

    await message.reply_text(info_text, disable_web_page_preview=True)
Пример #2
0
async def help_button(_client, query):
    mod_match = re.match(r"help_module\((.+?)\)", query.data)
    back_match = re.match(r"help_back", query.data)
    if mod_match:
        module = mod_match.group(1)
        text = plate("help_module",
                     tmp_lang,
                     name=HELPABLE[module].__mod_name__)
        text += plate(HELPABLE[module].__help__, tmp_lang)

        await query.message.edit(
            text=text,
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(
                    text=plate("generic_back", tmp_lang),
                    callback_data="help_back",
                )
            ]]),
        )

    elif back_match:
        await query.message.edit(
            text=plate("help_main", tmp_lang),
            reply_markup=InlineKeyboardMarkup(
                paginate_modules(0, HELPABLE, "help")),
        )
Пример #3
0
async def lineageos(client, message):
	cmd = message.command
	cmd.pop(0)

	if not cmd:
		await message.reply(plate("android_cmd_example", tmp_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(plate("android_err_notfound", tmp_lang))
			return
		response = response[0]
		buttons = InlineKeyboardMarkup(
						[[InlineKeyboardButton(text=plate("android_button_download", tmp_lang), url=response['url'])]])
		await message.reply(plate("android_los_msgtxt", tmp_lang,
							filename=response['filename'],
							url=response['url'],
							size=sizee(int(response['size'])),
							version=response['version']
							), disable_web_page_preview=True, reply_markup=buttons)
	except ClientConnectionError:
		await message.reply(plate("android_err_api", tmp_lang))
Пример #4
0
async def start(_, message):
    if message.chat.type != "private":
        await message.reply_text(plate("start_group", tmp_lang))
    else:
        await message.reply_text(
            plate("start_private", tmp_lang),
            reply_markup=InlineKeyboardMarkup(BUTTONS),
            disable_web_page_preview=True,
        )
Пример #5
0
async def help_command(client, message):
    if message.chat.type != "private":
        username = (await client.get_me()).username
        buttons = InlineKeyboardMarkup([[
            InlineKeyboardButton(text=plate("help_button_help", tmp_lang),
                                 url=f"t.me/{username}?start=help")
        ]])
        await message.reply(plate("help_group", tmp_lang),
                            reply_markup=buttons)
    else:
        await help_parser(client, message.chat.id,
                          plate("help_main", tmp_lang))
Пример #6
0
async def start(client, message):
    if message.chat.type != "private":
        await message.reply_text(plate("start_group", tmp_lang))
        return
    else:
        buttons = [[
            InlineKeyboardButton(plate("help_button_support", tmp_lang),
                                 url="https://t.me/HarukaAyaGroup"),
            InlineKeyboardButton(plate("help_button_help", tmp_lang),
                                 callback_data='help_back')
        ]]
        await message.reply_text(plate("start_private", tmp_lang),
                                 reply_markup=InlineKeyboardMarkup(buttons),
                                 disable_web_page_preview=True)
Пример #7
0
async def phhusson(client, message):
	try:
		data = await cache.get("https://api.github.com/repos/phhusson/treble_experimentations/releases/latest")
		reply_text = plate("android_phh_msgtxt", tmp_lang)
		for i in range(len(data)):
			try:
				name = data['assets'][i]['name']
				url = data['assets'][i]['browser_download_url']
				reply_text += f"[{name}]({url})\n"
			except IndexError:
				continue
		await message.reply(reply_text)
	except ClientConnectionError:
		await message.reply(plate("android_err_api", tmp_lang))
Пример #8
0
async def magisk(client, message):
    url = 'https://raw.githubusercontent.com/topjohnwu/magisk_files/'
    try:
        stable, beta, canary = await asyncio.gather(
            cache.get(url + "master/stable.json"),
            cache.get(url + "master/beta.json"),
            cache.get(url + "canary/canary.json"),
        )
        if not stable and not beta and not canary:
            await message.reply(plate("android_err_api", tmp_lang))
            return

        await message.reply(
            plate(
                "android_magisk_msgtxt",
                tmp_lang,
                # Generics
                uninstalltxt=plate("android_magisk_uninstaller", tmp_lang),
                changelogtxt=plate("android_magisk_changelog", tmp_lang),
                # Stable text
                stablezip="ZIP v" + stable['magisk']['version'],
                stablezipurl=stable['magisk']['link'],
                stableapk="APK v" + stable['app']['version'],
                stableapkurl=stable['app']['link'],
                stableuninstallurl=stable['uninstaller']['link'],
                stablechangelogurl=
                f"https://topjohnwu.github.io/Magisk/releases/{stable['magisk']['versionCode']}.html",
                # Beta text
                betazip="ZIP v" + beta['magisk']['version'],
                betazipurl=beta['magisk']['link'],
                betaapk="APK v" + beta['app']['version'],
                betaapkurl=beta['app']['link'],
                betauninstallurl=beta['uninstaller']['link'],
                betachangelogurl=
                f"https://topjohnwu.github.io/Magisk/releases/{beta['magisk']['versionCode']}.html",
                # Canary text
                canaryzip="ZIP v" + canary['magisk']['version'],
                canaryzipurl=url + "canary/canary/" + canary['magisk']['link'],
                canaryapk="APK v" + canary['app']['version'],
                canaryapkurl=url + "canary/" + canary['app']['link'],
                canaryuninstallurl=url + "canary/" +
                canary['uninstaller']['link'],
                canarychangelogurl=url + "canary/" + canary['magisk']['note'],
            ),
            disable_web_page_preview=True,
        )

    except ClientConnectionError:
        await message.reply(plate("android_err_api", tmp_lang))
Пример #9
0
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))
Пример #10
0
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=sizee(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))
Пример #11
0
def LastOnline(user: User):
    if user.is_bot:
        return plate("info_status_online", tmp_lang) # bots are always online
    elif user.status == 'recently':
        return plate("info_status_recently", tmp_lang)
    elif user.status == 'within_week':
        return plate("info_status_within_week", tmp_lang)
    elif user.status == 'within_month':
        return plate("info_status_within_month", tmp_lang)
    elif user.status == 'long_time_ago':
        return plate("info_status_long_time_ago", tmp_lang)
    elif user.status == 'online':
        return plate("info_status_online", tmp_lang)
    elif user.status == 'offline':
        return datetime.fromtimestamp(user.status.date).strftime("%a, %d %b %Y, %H:%M:%S")
Пример #12
0
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from haruka import plate, tmp_lang, app
from haruka.helpers import custom_filters

# Start buttons
BUTTONS = [[
    InlineKeyboardButton(
        plate("help_button_support", tmp_lang),
        url="https://t.me/HarukaAyaGroup",
    ),
    InlineKeyboardButton(plate("help_button_help", tmp_lang),
                         callback_data='help_back'),
]]


@Client.on_message(~filters.me & custom_filters.command('start', prefixes='/'),
                   group=8)
async def start(_, message):
    if message.chat.type != "private":
        await message.reply_text(plate("start_group", tmp_lang))
    else:
        await message.reply_text(
            plate("start_private", tmp_lang),
            reply_markup=InlineKeyboardMarkup(BUTTONS),
            disable_web_page_preview=True,
        )