import asyncio import math import os import heroku3 import requests from ironbot.function.heroku_helper import HerokuHelper from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd Heroku = heroku3.from_key(Config.HEROKU_API_KEY) heroku_api = "https://api.heroku.com" @iron.on(iron_on_cmd(pattern="(logs$|log$)")) @iron.on(sudo_cmd(pattern="(logs|log)", allow_sudo=True)) async def giblog(event): if event.fwd_from: return herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME, Config.HEROKU_API_KEY) logz = herokuHelper.getLog() with open("logs.txt", "w") as log: log.write(logz) await event.delete() await borg.send_file(event.chat_id, "logs.txt", caption=f"**Logs Of {Config.HEROKU_APP_NAME}**") @iron.on(iron_on_cmd(pattern="usage$")) @iron.on(sudo_cmd(pattern="usage$", allow_sudo=True))
import logging from ironbot import CMD_HELP from ironbot.utils import iron_on_cmd, sudo_cmd logger = logging.getLogger(__name__) if 1 == 1: name = "Profile Photos" client = borg @iron.on(iron_on_cmd(pattern="poto(.*)")) @iron.on(sudo_cmd(pattern="poto(.*)", allow_sudo=True)) async def potocmd(event): if event.fwd_from: return """Gets the profile photos of replied users, channels or chats""" id = "".join(event.raw_text.split(maxsplit=2)[1:]) user = await event.get_reply_message() chat = event.input_chat if user: photos = await event.client.get_profile_photos(user.sender) else:
from deep_translator import GoogleTranslator from googletrans import LANGUAGES from google_trans_new import google_translator from langdetect import detect import requests from ironbot import CMD_HELP from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd @iron.on(iron_on_cmd("tr ?(.*)")) @iron.on(sudo_cmd("tr ?(.*)", allow_sudo=True)) async def _(event): if event.fwd_from: return if "trim" in event.raw_text: return input_str = event.pattern_match.group(1) if event.reply_to_msg_id: previous_message = await event.get_reply_message() text = previous_message.message lan = input_str or "id" elif "|" in input_str: lan, text = input_str.split("|") else: await edit_or_reply(event, "`.tr <Language-code>` as reply to a message") return lan = lan.strip() try: translator = google_translator()
"""Download & Upload Images on Telegram\n Syntax: `.img <Name>` or `.img (replied message)` \n Upgraded and Google Image Error Fixed """ import os import shutil from re import findall from ironbot import CMD_HELP from ironbot.googol_images import googleimagesdownload from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd @iron.on(iron_on_cmd(pattern="(img|image|googleimage|gi) ?(.*)")) @iron.on(sudo_cmd(pattern="(img|image|googleimage|gi) ?(.*)", allow_sudo=True)) async def img_sampler(event): await edit_or_reply(event, "`Processing...`") reply = await event.get_reply_message() if event.pattern_match.group(2): query = event.pattern_match.group(2) elif reply: query = reply.message else: await edit_or_reply( event, "`um, mind mentioning what I actually need to search for ;_;`") return lim = findall(r"lim=\d+", query) # lim = event.pattern_match.group(1)
"""Get ID of any Telegram media, or any user Syntax: .get_id""" from telethon.utils import pack_bot_file_id from ironbot import CMD_HELP from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd @iron.on(iron_on_cmd("get_id")) @iron.on(sudo_cmd("get_id", allow_sudo=True)) async def _(event): starkisgreat = await edit_or_reply(event, "Processing") if event.fwd_from: return if event.reply_to_msg_id: await event.get_input_chat() r_msg = await event.get_reply_message() if r_msg.media: bot_api_file_id = pack_bot_file_id(r_msg.media) await starkisgreat.edit( "Current Chat ID: `{}`\nFrom User ID: `{}`\nBot API File ID: `{}`" .format(str(event.chat_id), str(r_msg.sender_id), bot_api_file_id)) else: await starkisgreat.edit( "Current Chat ID: `{}`\nFrom User ID: `{}`".format( str(event.chat_id), str(r_msg.sender_id))) else: await starkisgreat.edit("Current Chat ID: `{}`".format( str(event.chat_id)))
KANGING_STR = [ "Wao.,Bagus Nih...Colong Dulu Yekan..", "Colong Sticker dulu yee kan", "ehh, mantep nih.....aku colong ya...", "Ini Sticker aku colong yaa\nDUARR!", "leh ugha ni Sticker\nColong ahh~", "Pim Pim Pom!!!\nni Sticker punya aing sekarang hehe", "Colong lagi yee kan.....", "COLONG TROSS!!!", "Bolehkah saya colong ni sticker\nau ah colong aja hehe", "Colong Sticker ahh.....", ] @iron.on(iron_on_cmd(pattern="kang ?(.*)")) @iron.on(sudo_cmd(pattern="kang ?(.*)", allow_sudo=True)) async def kang(args): user = await bot.get_me() if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None emojibypass = False is_anim = False emoji = None if message and message.media: if isinstance(message.media, MessageMediaPhoto): await args.edit(f"`{random.choice(KANGING_STR)}`") photo = io.BytesIO() photo = await bot.download_media(message.photo, photo)
time_list[x] = str(time_list[x]) + time_suffix_list[x] if len(time_list) == 4: ping_time += time_list.pop() + ", " time_list.reverse() ping_time += ":".join(time_list) return ping_time DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "Unknown" PM_IMG = Config.ALIVE_IMAGE @iron.on(iron_on_cmd(pattern=r"alive")) @iron.on(sudo_cmd(pattern=r"alive", allow_sudo=True)) async def ironalive(alive): if alive.fwd_from: return await alive.get_chat() uptime = get_readable_time((time.time() - Lastupdate)) repo = Repo() branch_name = repo.active_branch.name pm_caption = ("╭━━━━━━| 𝙸𝚁𝙾𝙽𝙱𝙾𝚃 |━━━━━━╮\n" f"┣[•👤 `USER :` {bot.me.first_name}\n" f"┣▰▱▰▱▰▱▰▱▰▱▰▱▰▱\n" f"┣[•🤖 `Iron Ver : {iron_version} ➰`\n" f"┣[•🐍 `Python. : v.{platform.python_version()} ➰`\n" f"┣[•⚙️ `Telethon : v.{tv} ➰`\n" f"┣[•💡 `Base on : {branch_name} ➰`\n" f"┣[•🕒 `Uptime. : {uptime} ➰`\n"
"""Get Administrators of any Chat* Syntax: .get_admin""" from telethon.tl.types import ( ChannelParticipantAdmin, ChannelParticipantCreator, ChannelParticipantsAdmins, ) from ironbot import CMD_HELP from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd @iron.on(iron_on_cmd("get_ad?(m)in ?(.*)")) @iron.on(sudo_cmd("get_ad?(m)in ?(.*)", allow_sudo=True)) async def _(event): admeme = await edit_or_reply(event, "Processing") if event.fwd_from: return mentions = "**Admins in this Channel**: \n" should_mention_admins = False reply_message = None pattern_match_str = event.pattern_match.group(1) if "m" in pattern_match_str: should_mention_admins = True if event.reply_to_msg_id: reply_message = await event.get_reply_message() input_str = event.pattern_match.group(2) to_write_chat = await event.get_input_chat() chat = None if not input_str: chat = to_write_chat
image_stream.seek(0) # finally, reply the sticker await event.client.send_file( event.chat_id, image_stream, caption="IRONBOT", reply_to=event.message.reply_to_msg_id, ) # cleanup try: os.remove(FONT_FILE) except: pass @iron.on(sudo_cmd(pattern="stcr ?(?:(.*?) \| )?(.*)", allow_sudo=True)) async def sticklet(event): R = random.randint(0, 256) G = random.randint(0, 256) B = random.randint(0, 256) reply_message = event.message # get the input text # the text on which we would like to do the magic on font_file_name = event.pattern_match.group(1) if not font_file_name: font_file_name = "" sticktext = event.pattern_match.group(2) if not sticktext and event.reply_to_msg_id: reply_message = await event.get_reply_message() sticktext = reply_message.message elif not sticktext:
try: user_obj = await event.client.get_entity(user) except (TypeError, ValueError) as err: await event.edit(str(err)) return None return user_obj # -------------------------------------------------------------------------------------------- # @register(outgoing=True, pattern="^.setevent$") @iron.on(iron_on_cmd(pattern="setgpic$")) @iron.on(sudo_cmd(pattern="setgpic$", allow_sudo=True)) async def set_group_photo(event): if event.fwd_from: return """ For .setevent command, changes the picture of a group """ if not event.is_group: poppo = await edit_or_reply(event, "`I don't think this is a group.`") return replyevent = await event.get_reply_message() chat = await event.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: poppo = await edit_or_reply(event, NO_ADMIN) return
import asyncio import io import time from ironbot import CMD_HELP from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd @iron.on(iron_on_cmd(pattern="bash ?(.*)")) @iron.on(sudo_cmd(pattern="bash ?(.*)", allow_sudo=True)) async def _(event): if event.fwd_from: return PROCESS_RUN_TIME = 100 cmd = event.pattern_match.group(1) tflyf = await edit_or_reply(event, "Processing Your Request...") reply_to_id = event.message.id if event.reply_to_msg_id: reply_to_id = event.reply_to_msg_id time.time() + PROCESS_RUN_TIME process = await asyncio.create_subprocess_shell( cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) stdout, stderr = await process.communicate() e = stderr.decode() if not e: e = "No Error" o = stdout.decode() if not o: o = "**Tip**: \n`If you want to see the results of your code, I suggest printing them to stdout.`" else: _o = o.split("\n")
) else: media = None event.message.id if event.reply_to_msg_id: event.reply_to_msg_id await event.reply(snip.reply, file=media) if event.chat_id not in last_triggered_filters: last_triggered_filters[event.chat_id] = [] last_triggered_filters[event.chat_id].append(name) await asyncio.sleep(DELETE_TIMEOUT) last_triggered_filters[event.chat_id].remove(name) @iron.on(iron_on_cmd(pattern="filter (.*)")) @iron.on(sudo_cmd(pattern="filter (.*)", allow_sudo=True)) async def on_snip_save(event): if event.fwd_from: return hitler = await edit_or_reply(event, "Processing....") name = event.pattern_match.group(1) msg = await event.get_reply_message() if msg: snip = {"type": TYPE_TEXT, "text": msg.message or ""} if msg.media: media = None if isinstance(msg.media, types.MessageMediaPhoto): media = utils.get_input_photo(msg.media.photo) snip["type"] = TYPE_PHOTO elif isinstance(msg.media, types.MessageMediaDocument): media = utils.get_input_document(msg.media.document)
loggy_grp = Config.PRIVATE_GROUP_ID from ironbot import CMD_HELP global USER_AFK # pylint:disable=E0602 global afk_time # pylint:disable=E0602 global last_afk_message # pylint:disable=E0602 global afk_start global afk_end USER_AFK = {} afk_time = None last_afk_message = {} afk_start = {} @iron.on(iron_on_cmd(pattern="invite ?(.*)")) @iron.on(sudo_cmd(pattern="invite ?(.*)", allow_sudo=True)) async def _(event): if event.fwd_from: return to_add_users = event.pattern_match.group(1) if event.is_private: await edit_or_reply( event, "`.invite` users to a chat, not to a Private Message") else: logger.info(to_add_users) if not event.is_channel and event.is_group: # https://lonamiwebs.github.io/Telethon/methods/messages/add_chat_user.html for user_id in to_add_users.split(" "): try: await borg( functions.messages.AddChatUserRequest(
if user_s.common_chats_count == 0: await event.edit("**No Chats in Common !**") return sed = await event.client( GetCommonChatsRequest(user_id=user_s.user.id, max_id=0, limit=100)) lol = f"**User-ID :** `{user_s.user.id}` \n**First-Name :** `{user_s.user.first_name}` \n**Total Groups In Common :** `{user_s.common_chats_count}` \n\n" for stark in sed.chats: try: lol += f"**Chat ID :** `{stark.id}` \n**Chat Name :** `{stark.title}` \n**Chat-UserName :** `{stark.username}` \n\n" except: lol += f"**Chat ID :** `{stark.id}` \n**Chat Name :** `{stark.title}` \n\n" await event.edit(lol) @iron.on(iron_on_cmd("info(?: |$)(.*)")) @iron.on(sudo_cmd("info(?: |$)(.*)", allow_sudo=True)) async def _(event): if event.fwd_from: return replied_user, error_i_a = await get_full_user(event) if replied_user is None: await edit_or_reply(event, str(error_i_a)) return False replied_user_profile_photos = await borg( GetUserPhotosRequest(user_id=replied_user.user.id, offset=42, max_id=0, limit=80)) replied_user_profile_photos_count = "None" try: replied_user_profile_photos_count = replied_user_profile_photos.count