def pingall(bot: BOT, message: Message): chat_members = bot.iter_chat_members(message.chat.id) tagable = [create_link(x) for x in chat_members if not x.user.is_bot] for i in range(math.ceil(len(tagable) / 10)): toTag = tagable[i * 10:(i + 1) * 10] bot.send_message(message.chat.id, " ".join(map(str, toTag))) sleep(1)
def google_sticker(bot: BOT, message: Message): cmd = message.command if len(cmd) > 1: ggl_text = " ".join(cmd[1:]) elif message.reply_to_message and len(cmd) == 1: ggl_text = message.reply_to_message.text elif not message.reply_to_message and len(cmd) == 1: message.edit("I need something to google") sleep(2) message.delete() return try: ggl_result = BOT.get_inline_bot_results("stickerizerbot", "#12" + ggl_text) BOT.send_inline_bot_result(chat_id=message.chat.id, query_id=ggl_result.query_id, result_id=ggl_result.results[0].id, reply_to_message_id=ReplyCheck(message), hide_via=False) except TimeoutError: message.edit("@StickerizerBot didn't respond in time.") sleep(2) message.delete()
def get_chats(bot: BOT, message: Message): total = 0 private = 0 channel = 0 group = 0 supergroup = 0 bots = 0 private_bots = [] start = int(time()) message.edit("Getting Chatlist...") for dialog in BOT.iter_dialogs(): total += 1 if dialog.chat.type == 'private': private_bots.append(dialog.chat.id) # Save for later parsing. elif dialog.chat.type == 'channel': channel += 1 elif dialog.chat.type == 'group': group += 1 elif dialog.chat.type == 'supergroup': supergroup += 1 message.edit("Checking for bots...") chunk_size = 200 for i in range(0, len(private_bots), chunk_size): for priv in BOT.get_users(private_bots[i:i + chunk_size]): if priv.is_bot: bots += 1 else: private += 1 message.edit( CHAT_INFO.format(total, private, bots, group, supergroup, channel, int(time()) - start))
def dice(bot: BOT, message: Message): max = int(message.command[1]) dice = randint(1, max) message.delete() max = str(max) dice = str(dice) bot.send_message(message.chat.id, "Deine Zahl aus 1 und " + max + " beträgt: " + dice)
def extend_if_players_too_less_starlightwerewolf(bot: BOT, message: Message): global messageid global players global idplayers global match int(match) if match < 5: bot.send_message(message.chat.id, "/extend@blackwerewolfbot 60")
def word_count(bot: BOT, message: Message): chat = message.chat.id check1 = str(message.command[0]) check2 = str(message.command[-1]) if message.chat.type == 'supergroup': channelname = str(message.chat.id) messageid = str(message.message_id) linkid = channelname.replace("-100", "") linkd = "https://t.me/c/" + linkid + "/" + messageid link = f"<a href='{linkd}'>{message.chat.title}</a>\n" elif message.chat.type == 'private': username = message.chat.id title = message.chat.first_name linkd = "tg://user?id=" + str(username) link = f"<a href='{linkd}'>{title}</a>\n" elif message.chat.type == 'bot': username = message.chat.id title = message.chat.first_name linkd = "tg://user?id=" + str(username) link = f"<a href='{linkd}'>{title}</a>\n" if check2 == COMMAND: bot.send_message(LOGGER_GROUP, "<b>Wrong input!</b>\nCorrect Syntax:\n.wc 100 20\nOut of <b>100</b> Posts back the Top<b>20</b>" ) message.delete() return else: limit = int(message.command[1]) message.delete() toplist = int(message.command[-1]) words = custom() progress = bot.send_message(LOGGER_GROUP, "`processed 0 messages...`") total = 0 for msg in bot.iter_history(chat, limit): total += 1 if total % 200 == 0: progress.edit_text(f"`processed {total} messages...`") if msg.text: for word in msg.text.split(): words[word.lower()] += 1 if msg.caption: for word in msg.caption.split(): words[word.lower()] += 1 freq = sorted(words, key=words.get, reverse=True) out = f"Word counter from ({link}).\nOut of {limit} Posts the Top{toplist}:\n" for i in range(toplist): out += f"{i+1}. {words[freq[i]]}: {freq[i]}\n" progress.edit_text(out)
def unban(bot: BOT, message: Message): if ReplyCheck(message) is True and AdminCheck(message) is True: try: BOT.unban_chat_member( chat_id=message.chat.id, user_id=message.reply_to_message.from_user.id) message.edit(UNBANNED.format(message)) LogMessage(UNBANNED_LOG.format( message, str(message.chat.id).replace("-100", ""))) except UserAdminInvalid: message.edit("I can't unban this user")
def get_members(bot: BOT, message: Message): if message.chat.type == 'private': message.delete() else: total = 0 admins = 0 members = 0 bots = 0 deleted = 0 for member in BOT.iter_chat_members(message.chat.id): total += 1 if member.user.is_bot: bots += 1 elif member.user.is_deleted: deleted += 1 elif member.status in ['creator', 'administrator']: admins += 1 elif not member.user.is_deleted and not member.user.is_bot: members += 1 member_count_text = MEMBER_INFO.format(message.chat.title, total, admins, members, bots, deleted) message.edit(member_count_text) LogMessage(member_count_text)
def neardc(bot: BOT, message: Message): dc = BOT.send( functions.help.GetNearestDc()) message.edit( NearestDC.format( dc.country, dc.nearest_dc, dc.this_dc))
def cc_gif(bot: BOT, message: Message): try: # delete if file still exists os.remove("animation.mp4") os.remove("animation.1.mp4") except FileNotFoundError: pass try: conv_url = message.command[1] except IndexError: message.edit("No URL to convert") return conv_ext = re.findall(r"\w+$", conv_url) try: message.edit("`Converting . . .`") process = ccapi.convert({ 'inputformat': conv_ext[0], 'outputformat': 'mp4', 'input': 'download', 'file': conv_url, 'filename': f'animation.{conv_ext[0]}', 'converteroptions': { 'command': CC_Convert } }) process.wait() message.edit("`Downloading . . .`") process.download() except cloudconvert.exceptions.APIError as e: message.edit(f"Error: {e}\n{conv_url}", disable_web_page_preview=True) return message.edit("`Uploading . . .`") try: BOT.send_animation(chat_id=message.chat.id, animation="animation.mp4") except errors.FileIdInvalid: BOT.send_animation(chat_id=message.chat.id, animation="animation.1.mp4") message.delete() try: os.remove("animation.mp4") os.remove("animation.1.mp4") except FileNotFoundError: pass
def ban_hammer(bot: BOT, message: Message): if ReplyCheck(message) is True and AdminCheck(message) is True: try: BOT.kick_chat_member( chat_id=message.chat.id, user_id=message.reply_to_message.from_user.id, until_date=Timer(message)) if len(message.command) > 1: message.edit(BANNED_TIME.format( message, TimerString(message))) else: message.edit(BANNED.format(message)) LogMessage(BANNED_LOG.format( message, str(message.chat.id).replace("-100", ""))) except UserAdminInvalid: RestrictFailed(message)