from pyrogram import Client, filters from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from kanri import LOCAL from kanri.helpers import custom_filters # Start buttons BUTTONS = [[ InlineKeyboardButton( LOCAL.PLATE("help_button_support", LOCAL.DEFAULT_LANG), url="https://t.me/KanriGroup", ), InlineKeyboardButton(LOCAL.PLATE("help_button_help", LOCAL.DEFAULT_LANG), callback_data='help_back'), ]] @Client.on_message(~filters.me & custom_filters.command('start', prefixes='/') & ~LOCAL.FLOOD_WAITED, group=8) async def start(_, message): if message.chat.type != "private": await message.reply_text(LOCAL.PLATE("start_group", LOCAL.DEFAULT_LANG)) else: await message.reply_text( LOCAL.PLATE("start_private", LOCAL.DEFAULT_LANG), reply_markup=InlineKeyboardMarkup(BUTTONS), disable_web_page_preview=True, )
from kanri import LOCAL from kanri.database import users as chats_db from pyrogram import filters, Client from kanri.helpers import custom_filters from io import BytesIO @Client.on_message( filters.user(LOCAL.OWNER_ID) & custom_filters.command("stats", prefixes='/') & ~LOCAL.FLOOD_WAITED ) async def stats_text(_, message): stats = "──「 <b>Current stats</b> 」──\n" stats += f"-> `{chats_db.num_users()}` users, across `{chats_db.num_chats()}` chats" await message.reply(stats) @Client.on_message( ~filters.me & filters.user(LOCAL.OWNER_ID) & custom_filters.command("chats", prefixes='/') & ~LOCAL.FLOOD_WAITED ) async def chat_stats(client, message): all_chats = chats_db.get_all_chats() or [] with BytesIO(b"") as output: output.write(b"List of chats.\n Chat name | Chat ID | Members count\n") for i, chat in enumerate(all_chats): chat_members = await client.get_chat_members_count(chat.chat_id) output.write( "{}. {} | {} | {}\n".format( i + 1, chat.chat_name, chat.chat_id, chat_members ).encode() ) output.name = "chats.txt"
return LOCAL.PLATE("info_status_recently", LOCAL.DEFAULT_LANG) elif user.status == 'within_week': return LOCAL.PLATE("info_status_within_week", LOCAL.DEFAULT_LANG) elif user.status == 'within_month': return LOCAL.PLATE("info_status_within_month", LOCAL.DEFAULT_LANG) elif user.status == 'long_time_ago': return LOCAL.PLATE("info_status_long_time_ago", LOCAL.DEFAULT_LANG) elif user.status == 'online': return LOCAL.PLATE("info_status_online", LOCAL.DEFAULT_LANG) elif user.status == 'offline': return datetime.fromtimestamp(user.status.date).strftime( "%a, %d %b %Y, %H:%M:%S" ) @Client.on_message(~filters.me & custom_filters.command('info') & ~LOCAL.FLOOD_WAITED) 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:
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)) @Client.on_message(~filters.me & custom_filters.command('evo') & ~LOCAL.FLOOD_WAITED) async def evolution_x(_, message): cmd = message.command cmd.pop(0) if not cmd: await message.reply( LOCAL.PLATE("android_cmd_example", LOCAL.DEFAULT_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" )