async def translateme(message: Message): text = message.filtered_input_str flags = message.flags if message.reply_to_message: text = message.reply_to_message.text or message.reply_to_message.caption if not text: await message.err( text="Give a text or reply to a message to translate!\nuse `.help tr`" ) return if len(flags) == 2: src, dest = list(flags) elif len(flags) == 1: src, dest = "auto", list(flags)[0] else: src, dest = "auto", Config.LANG text = get_emoji_regex().sub("", text) await message.edit("`Translating ...`") try: reply_text = await _translate_this(text, dest, src) except ValueError: await message.err(text="Invalid destination language.\nuse `.help tr`") return source_lan = LANGUAGES[f"{reply_text.src.lower()}"] transl_lan = LANGUAGES[f"{reply_text.dest.lower()}"] output = f"**Source ({source_lan.title()}):**`\n{text}`\n\n\ **Translation ({transl_lan.title()}):**\n`{reply_text.text}`" await message.edit_or_send_as_file(text=output, caption="translated")
async def translateme(message: Message): text = message.filtered_input_str flags = message.flags if not text: reply_ = message.reply_to_message text = reply_.text or reply_.caption if not text: await message.err( text= "Give a text or reply to a message to translate!\nuse `.help tr`") return if len(flags) == 3: if "s" in flags: src, dest = list(flags)[1], list(flags)[2] else: await message.edit("Language flags can't be more than 2...", del_in=5) return elif len(flags) == 2: if "s" not in flags: src, dest = list(flags) else: src, dest = "auto", list(flags)[1] elif len(flags) == 1: if "s" not in flags: src, dest = "auto", list(flags)[0] else: src, dest = "auto", Config.LANG else: src, dest = "auto", Config.LANG text = get_emoji_regex().sub("", text) if "s" not in flags: await message.edit("`Translating ...`") try: reply_text = await _translate_this(text, dest, src) except ValueError: await message.err(text="Invalid destination language.\nuse `.help tr`" ) if "s" not in flags else await message.delete() return if "s" not in flags: source_lan = LANGUAGES[f"{reply_text.src.lower()}"] transl_lan = LANGUAGES[f"{reply_text.dest.lower()}"] output = f"**Source ({source_lan.title()}):**`\n{text}`\n\n\ **Translation ({transl_lan.title()}):**\n`{reply_text.text}`" caption = "translated" else: output = reply_text.text caption = None await message.edit_or_send_as_file(text=output, caption=caption)
async def promote_usr(message: Message): """promote members in tg group""" chat_id = message.chat.id await message.edit("`Trying to Promote User.. Hang on!! ⏳`") user_id, custom_rank = message.extract_user_and_text if not user_id: await message.edit( text="`no valid user_id or message specified,`" "`do .help promote for more info`", del_in=5, ) return if custom_rank: custom_rank = get_emoji_regex().sub("", custom_rank) if len(custom_rank) > 15: custom_rank = custom_rank[:15] try: get_mem = await message.client.get_chat_member(chat_id, user_id) await message.client.promote_chat_member( chat_id, user_id, can_change_info=True, can_delete_messages=True, can_restrict_members=True, can_invite_users=True, can_pin_messages=True, ) if custom_rank: await asyncio.sleep(2) await message.client.set_administrator_title( chat_id, user_id, custom_rank) await message.edit("`👑 Promoted Successfully..`", del_in=5) await CHANNEL.log( "#PROMOTE\n\n" f"USER: [{get_mem.user.first_name}](tg://user?id={get_mem.user.id}) " f"(`{get_mem.user.id}`)\n" f"CUSTOM TITLE: `{custom_rank or None}`\n" f"CHAT: `{message.chat.title}` (`{chat_id}`)") except UsernameInvalid: await message.edit("`invalid username, try again with valid info ⚠`", del_in=5) except PeerIdInvalid: await message.edit( "`invalid username or userid, try again with valid info ⚠`", del_in=5) except UserIdInvalid: await message.edit("`invalid userid, try again with valid info ⚠`", del_in=5) except Exception as e_f: await message.edit(f"`something went wrong! 🤔`\n\n**ERROR:** `{e_f}`")