user_bio = msgRep.USR_NO_BIO if not user_bio else user_bio profile_link = f"<a href=\"tg://user?id={user_id}\">link</a>" caption = f"<b>{msgRep.USR_INFO}</b>\n\n" caption += f"{msgRep.USR_ID}: <code>{user_id}</code>\n" caption += f"{msgRep.FIRST_NAME}: {first_name}\n" if last_name: caption += f"{msgRep.LAST_NAME}: {last_name}\n" if username: caption += f"{msgRep.USERNAME}: {username}\n" caption += f"{msgRep.DCID}: {dc_id}\n" if user_pfps_count: caption += f"{msgRep.PROF_PIC_COUNT}: {user_pfps_count}\n" if not user_deleted: caption += f"{msgRep.PROF_LINK}: {profile_link}\n" caption += f"{msgRep.ISBOT}: {is_bot}\n" caption += f"{msgRep.SCAMMER}: {scam}\n" caption += f"{msgRep.ISRESTRICTED}: {restricted}\n" caption += f"{msgRep.ISVERIFIED}: {verified}\n\n" caption += f"{msgRep.BIO}:\n<code>{user_bio}</code>\n\n" if user_self: caption += f"{msgRep.COMMON_SELF}" else: caption += f"{msgRep.COMMON}: {common_chat}" return caption MODULE_DESC.update({basename(__file__)[:-3]: descRep.USER_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.USER_USAGE}) MODULE_INFO.update({basename(__file__)[:-3]: module_info(name="User", version=VERSION)})
await event.edit(msgRep.SPD_FAIL_SEND_RESULT) else: # Convert speed to Mbit/s down_in_mbits = round(result["download"] / 10**6, 2) up_in_mbits = round(result["upload"] / 10**6, 2) # Convert speed to MB/s (real speed?) down_in_mb = round(result["download"] / ((10**6) * 8), 2) up_in_mb = round(result["upload"] / ((10**6) * 8), 2) time = parse(result["timestamp"]) ping = result["ping"] isp = result["client"]["isp"] host = result["server"]["sponsor"] host_cc = result["server"]["cc"] text = "<b>Speedtest by Ookla</b>\n\n" text += f"<b>{msgRep.SPD_TIME}</b>: <code>{time.strftime('%B %d, %Y')} - {time.strftime('%H:%M:%S')} {time.tzname()}</code>\n" text += f"<b>{msgRep.SPD_DOWNLOAD}</b>: <code>{down_in_mbits}</code> {msgRep.SPD_MEGABITS} (<code>{down_in_mb}</code> {msgRep.SPD_MEGABYTES})\n" text += f"<b>{msgRep.SPD_UPLOAD}</b>: <code>{up_in_mbits}</code> {msgRep.SPD_MEGABITS} (<code>{up_in_mb}</code> {msgRep.SPD_MEGABYTES})\n" text += f"<b>{msgRep.SPD_PING}</b>: <code>{ping}</code> ms\n" text += f"<b>{msgRep.SPD_ISP}</b>: {isp}\n" text += f"<b>{msgRep.SPD_HOSTED_BY}</b>: {host} ({host_cc})\n" await event.edit(text, parse_mode="html") return MODULE_DESC.update({basename(__file__)[:-3]: descRep.WEBTOOLS_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.WEBTOOLS_USAGE}) MODULE_INFO.update( {basename(__file__)[:-3]: module_info(name="Web Tools", version=VERSION)})
reason = message gbantext = '/gkick ' + user + ' ' + reason for i in GBAN_BOT_IDS: async with tgclient.conversation(i) as conv: await conv.send_message(gbantext) x = None try: x = await conv.get_response() except Timeout: log.warning("@" + i + " took too much to respond, likely it is offline!\n") if x: response += i + ': ' + x.text.replace("**", "").replace("`", "").replace("tg://user?id=", "") + '\n\n' else: response += i + " took too much time to respond, likely it is offline!\n" await request.edit("`" + response + "`") return DESC = "nunos-private-repo modules are not for human consumption! This is the global bans module, which will redirect the gban command to group management bots (based on Marie), gbanning people on multiple bots at the same time." USAGE = "`.gban` <optional: user identifier> \ \nUsage: Globally bans a user in the specified Marie based bots. \ \n\n`.ungban` <optional: user identifier> \ \nUsage: Globally unbans a user in the specified Marie based bots. \ \n\n`.gkick` <optional: user identifier> \ \nUsage: Globally kicks a user in the specified Marie based bots. \ **ALERT**: This module is not suitable for human consumption! Please refrain from using it unless you know what you are doing!" MODULE_DESC.update({basename(__file__)[:-3]: DESC}) MODULE_DICT.update({basename(__file__)[:-3]: USAGE}) MODULE_INFO.update({basename(__file__)[:-3]: module_info(name="Global Bans Utility", version=VERSION)})
await msg.edit(msgRep.UNINSTALLING.format(modNames)) for modName in mods_uninstall: if modName not in USER_MODULES: await msg.edit(msgRep.NOT_IN_USERSPACE.format(modName)) return os.remove(USER_MODULES_DIR + modName + ".py") log.info(f"Modules '{modNames}' has been uninstalled from userspace") log.info("Rebooting userbot...") await msg.edit(msgRep.DONE_RBT) time.sleep(1) # just so we can actually see a message if LOGGING: await event_log(msg, "MODULE UNINSTALL", custom_text=msgRep.UNINSTALL_LOG.format(modNames)) await msg.edit(msgRep.REBOOT_DONE_UNINS.format(modNames)) args = [EXECUTABLE, "-m", "userbot"] os.execle(sys.executable, *args, os.environ) await msg.client.disconnect() return else: await msg.edit(msgRep.INVALID_ARG) return MODULE_DESC.update({basename(__file__)[:-3]: descRep.PACKAGE_MANAGER_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.PACKAGE_MANAGER_USAGE}) MODULE_INFO.update({ basename(__file__)[:-3]: module_info(name="Package Manager", version=VERSION) })
text += f"{msgRep.RESULT}: {is_banned}\n" if offenses: text += f"{msgRep.OFFENSES}: `{offenses}`\n" if time_banned: text += f"{msgRep.BANNED_SINCE}: `{time_banned.strftime('%b %d, %Y')} - {time_banned.time()} {time_banned.tzname()}`" except ChatAdminRequiredError: await event.edit(msgRep.NO_ADMIN) return except Exception as e: log.warning(e) await event.edit(msgRep.CAS_CHECK_FAIL) return try: if cas_count > 35: # limit list up to 35 users await casSendAsFile(event, text) else: await event.edit(text) except MessageTooLongError: await casSendAsFile(event, text) return MODULE_DESC.update({basename(__file__)[:-3]: descRep.CAS_INTERFACE_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.CAS_INTERFACE_USAGE}) MODULE_INFO.update({ basename(__file__)[:-3]: module_info(name="CAS Interface", version=VERSION) })
scale = 512 / size2 size1new = size1 * scale size2new = 512 size1new = math.floor(size1new) size2new = math.floor(size2new) sizenew = (size1new, size2new) image = image.resize(sizenew) else: image.thumbnail(maxsize) return image DESC = "Sticker Management Module - Allows you to clone or add existing stickers" USG = "`.clone`\ \nUsage: Reply .kang to a sticker or an image to add it to your userbot pack.\ \n\n`.clone [emoji('s)]`\ \nUsage: Works just like .clone but uses the emoji you picked.\ \n\n`.clone [number]`\ \nUsage: Add's the sticker/image to the specified pack but uses 🤔 as emoji.\ \n\n`.clone [emoji('s)] [number]`\ \nUsage: Add's the sticker/image to the specified pack and uses the emoji('s) you picked." MODULE_DESC.update({basename(__file__)[:-3]: DESC}) MODULE_DICT.update({basename(__file__)[:-3]: USG}) MODULE_INFO.update({ basename(__file__)[:-3]: module_info(name='Sticker Manager', version='1.0.0-debug') })
@ehandler.on(pattern=r"^\.rand(?: |$)(.*)", outgoing=True) async def randomizer(msg): limit1 = 0 limit2 = 0 arguments = msg.text.split(" ") if len(arguments) != 3: await msg.edit(msgRep.RAND_INVLD_ARGS) return try: limit1 = int(arguments[1]) except ValueError: await msg.edit(msgRep.FRST_LIMIT_INVALID) return try: limit2 = int(arguments[2]) except ValueError: await msg.edit(msgRep.SCND_LIMIT_INVALID) return if limit1 > limit2: temp = limit1 limit1 = limit2 limit2 = temp rand_num = random.randint(limit1, limit2) await msg.edit(msgRep.RAND_NUM_GEN.format(limit1, limit2, rand_num)) return MODULE_DESC.update({basename(__file__)[:-3]: descRep.MISC_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.MISC_USAGE}) MODULE_INFO.update({basename(__file__)[:-3]: module_info(name="Miscellaneous", version=VERSION)})
pass repo.remote('upstream').fetch(branch) changelog = '' counter = 1 for commit in repo.iter_commits("HEAD..upstream/" + branch): changelog += "{}. [{}] > `{}`\n".format(counter, commit.author, commit.summary) counter += 1 if not changelog: await upd.edit(msgRep.LATS_VERSION.format(PROJECT)) RAN = True return if changelog: try: retText = msgRep.UPD_AVAIL retText += changelog retText += msgRep.RUN_UPD await upd.edit(retText) except MessageTooLongError: retText = msgRep.CHLG_TOO_LONG await upd.edit(retText) RAN = True FOUND_UPD = True return MODULE_DESC.update({basename(__file__)[:-3]: descRep.UPDATER_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.UPDATER_USAGE}) MODULE_INFO.update( {basename(__file__)[:-3]: module_info(name="Updater", version=VERSION)})
caption += f"- {msgRep.ROOT_RIGHTS} {root_rights}\n\n" else: caption += f"- {msgRep.SEND_MESSAGES} {send_messages}\n" caption += f"- {msgRep.SEND_MEDIA} {send_media}\n" caption += f"- {msgRep.SEND_GIFS_STICKERS} {send_stickers_gifs}\n" caption += f"- {msgRep.SEND_POLLS} {send_polls}\n" caption += f"- {msgRep.EMBED_LINKS} {embed_links}\n" caption += f"- {msgRep.INVITE_USERS} {invite_users}\n" caption += f"- {msgRep.PIN_MESSAGES} {pin_messages}\n" caption += f"- {msgRep.CHANGE_GROUP_INFO} {change_info}\n\n" if not am_i_admeme and not member_is_self: caption += f"{warning} <i>{msgRep.WARN_ADMIN_PRIV}</i>\n\n" if is_admin and promoted_by is not None: caption += f"{msgRep.PROMOTED_BY}: {promoted_by}\n" if added_by is not None: caption += f"{msgRep.ADDED_BY}: {added_by}\n" if (not banned and not not_member) and join_date is not None: caption += f"{msgRep.JOIN_DATE}: <code>{join_date.strftime('%b %d, %Y')} - {join_date.time()} {join_date.tzinfo}</code>\n" await event.edit(caption, parse_mode="html") return MODULE_DESC.update({basename(__file__)[:-3]: descRep.MEMBERINFO_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.MEMBERINFO_USAGE}) MODULE_INFO.update({ basename(__file__)[:-3]: module_info(name="Member Info", version=VERSION) })
chat = await event.get_chat() if not isinstance(chat, (Chat, Channel)): await event.edit(msgRep.LINK_INVALID_ID_GROUP) return try: result = await event.client(ExportChatInviteRequest(chat.id)) if hasattr(result, "link"): # might return ChatInviteEmpty object text = msgRep.LINK_TEXT.format(chat.title) + ":\n" text += result.link await event.edit(text) else: await event.edit(msgRep.NO_LINK) except ChatAdminRequiredError: if chat.admin_rights and not chat.admin_rights.invite_users: await event.edit(msgRep.NO_INVITE_PERM) else: await event.edit(msgRep.NO_ADMIN_PERM) except Exception as e: log.warning(e) await event.edit(msgRep.UNABLE_GET_LINK) return MODULE_DESC.update({basename(__file__)[:-3]: descRep.CHATINFO_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.CHATINFO_USAGE}) MODULE_INFO.update( {basename(__file__)[:-3]: module_info(name="Chat Info", version=VERSION)})
except Exception as e: log.error(e, exc_info=True) await event.edit(f"`{msgRep.BASH_SEND_FILE_FAILED}`") remove(temp_file) return @ehandler.on(pattern=r"^\.shell(?: |$)(.*)", outgoing=True) async def bash(command): full_cmd_str = command.pattern_match.group(1) commandArray = command.text.split(" ") del (commandArray[0]) cmd_output = shell_runner(commandArray) if cmd_output is None: cmd_output = msgRep.BASH_ERROR output = "$ " + full_cmd_str + "\n\n" + cmd_output try: await command.edit("`" + output + "`") except MessageTooLongError: log.info( "Shell output is too large. Trying to upload output as a file...") await outputAsFile(command, output) return MODULE_DESC.update({basename(__file__)[:-3]: descRep.TERMINAL_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.TERMINAL_USAGE}) MODULE_INFO.update( {basename(__file__)[:-3]: module_info(name="Terminal", version=VERSION)})
message += msgRep.ASSET fileName = api.getReleaseFileName(asset) fileURL = api.getReleaseFileURL(asset) assetFile = "<a href='{}'>{}</a>".format(fileURL, fileName) sizeB = ((api.getSize(asset)) / 1024) / 1024 size = "{0:.2f}".format(sizeB) downloadCount = api.getDownloadCount(asset) message += assetFile + "\n" message += msgRep.SIZE + size + " MB" message += msgRep.DL_COUNT + str(downloadCount) + "\n\n" return message @ehandler.on(pattern=r"^\.git(?: |$)(.*)", outgoing=True) async def get_release(event): commandArgs = event.text.split(" ") if len(commandArgs) != 2 or not "/" in commandArgs[1]: await event.edit(msgRep.INVALID_ARGS) return index = 0 # later will support going back in time! url = commandArgs[1] text = getData(url, index) await event.edit(text, parse_mode="html") return MODULE_DESC.update({basename(__file__)[:-3]: descRep.GITHUB_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.GITHUB_USAGE}) MODULE_INFO.update( {basename(__file__)[:-3]: module_info(name="GitHub", version=VERSION)})
try: if all_msgs: await event.client.unpin_message(chat.id) await event.edit(msgRep.UNPIN_ALL_SUCCESS) log_text = f"**{msgRep.LOG_UNPIN_ALL_TEXT}**" else: await event.client.unpin_message(chat.id, msg_id) await event.edit(msgRep.UNPIN_SUCCESS) log_text = f"{msgRep.LOG_PIN_MSG_ID}: {event.reply_to_msg_id}" if LOGGING: await event_log( event, "UNPINNED MESSAGES" if all_msgs else "UNPINNED MESSAGE", chat_title=chat.title if hasattr(chat, "title") else None, chat_link=chat.username if hasattr(chat, "username") else None, chat_id=chat.id, custom_text=log_text) except ChatAdminRequiredError: await event.edit(msgRep.NO_ADMIN) except Exception as e: log.warning(e) await event.edit(msgRep.UNPIN_FAILED) return MODULE_DESC.update({basename(__file__)[:-3]: descRep.MESSAGES_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.MESSAGES_USAGE}) MODULE_INFO.update( {basename(__file__)[:-3]: module_info(name="Messages", version=VERSION)})
log.warning(e) await event.edit(msgRep.PURGE_MSG_FAILED) return try: result = await event.client.send_message( chat.id, msgRep.PURGE_COMPLETE.format(msg_count)) await sleep(2.5) await result.delete() if LOGGING: await event_log( event, "PURGE", chat_title=chat.title if hasattr(chat, "title") else None, chat_link=chat.username if hasattr(chat, "username") else None, chat_id=chat.id if hasattr(chat, "id") else None, custom_text=msgRep.LOG_PURGE.format(msg_count)) except Exception as e: log.error(e) else: await event.edit(msgRep.REPLY_PURGE_MSG) return MODULE_DESC.update({basename(__file__)[:-3]: descRep.DELETIONS_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.DELETIONS_USAGE}) MODULE_INFO.update( {basename(__file__)[:-3]: module_info(name="Deletions", version=VERSION)})
deleted_accounts, rem_del_accounts = (0,)*2 await event.edit(msgRep.TRY_DEL_ACCOUNTS) async for member in event.client.iter_participants(chat.id): if member.deleted: deleted_accounts += 1 if chat.creator or (chat.admin_rights and chat.admin_rights.ban_users): try: await event.client.kick_participant(chat.id, member.id) await sleep(0.2) rem_del_accounts += 1 except: pass if deleted_accounts > 0 and not rem_del_accounts: await event.edit(msgRep.DEL_ACCS_COUNT.format(deleted_accounts)) elif rem_del_accounts > 0 and rem_del_accounts <= deleted_accounts: await event.edit(msgRep.REM_DEL_ACCS_COUNT.format(rem_del_accounts, deleted_accounts)) if LOGGING: await event_log(event, "DELACCS", chat_title=chat.title, chat_link=chat.username if hasattr(chat, "username") else None, chat_id=chat.id) else: await event.edit(msgRep.NO_DEL_ACCOUNTS) return MODULE_DESC.update({basename(__file__)[:-3]: descRep.ADMIN_DESC}) MODULE_DICT.update({basename(__file__)[:-3]: usageRep.ADMIN_USAGE}) MODULE_INFO.update({basename(__file__)[:-3]: module_info(name="Admininstration", version=VERSION)})