Esempio n. 1
0
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)
Esempio n. 2
0
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()
Esempio n. 3
0
def remove_unable_message(message: Message):
    if not message.service:
        return
    deletable = message.left_chat_member or message.new_chat_members
    if not deletable:
        return
    message.delete()
Esempio n. 4
0
def mention_everyone(bot: BOT, message: Message):
    mentions = "".join("[\u200E](tg://user?id={})".format(x.user.id)
                       for x in BOT.iter_chat_members(message.chat.id))
    BOT.send_message(message.chat.id,
                     message.text.replace('.m', '') + mentions,
                     reply_to_message_id=ReplyCheck(message))
    message.delete()
Esempio n. 5
0
def rotate(c: Client, msg: Message):
    targetmsg = msg.reply_to_message

    if not (targetmsg.photo or targetmsg.sticker):
        msg.edit_text("Reply to a sticker or photo!")
        return 1

    msg.delete()

    rotation = (
        180  # If rotation is 90, 180 or 270 there are constants like Image.ROTATE_180
    )

    if len(msg.command) > 1:
        try:
            rotation = int(msg.command[1])
        except ValueError:  # ValueError: invalid literal for int() with base 10
            pass

    image = get_image(targetmsg)

    rotated = image.rotate(rotation, PIL.Image.BICUBIC)

    c.send_photo(
        msg.chat.id,
        save_image(rotated),
        caption="<b>Rotated {} degrees</b>".format(rotation),
        reply_to_message_id=targetmsg.message_id,
    )
Esempio n. 6
0
def checkDatabase(client: Client, message: Message):
    global adminsIdList, constants, chatIdList
    """
		Removing the message
	"""
    message.delete(revoke=True)
    """
		Sending the output
	"""
    element = constants.admins.to_json(orient="records")
    element = element.replace(":", ": ")
    element = element.replace(",", ", ")
    print("{}".format(element))
    print("\n{}\n".format(adminsIdList))
    for j in adminsIdList:
        print("\t{} - {}".format(j, type(j)))
    element = constants.chats.to_json(orient="records")
    element = element.replace(":", ": ")
    element = element.replace(",", ", ")
    print("\n{}".format(element))
    print("\n{}\n".format(chatIdList))
    for j in chatIdList:
        print("\t{} - {}".format(j, type(j)))
    print("\n\n")
    log(
        client, "I have checked the admin and the chat list at {}.".format(
            constants.now()))
Esempio n. 7
0
def mock_people(bot: BOT, message: Message):
    cmd = message.command

    if len(cmd) > 1:
        mock_text = " ".join(cmd[1:])
    elif message.reply_to_message and len(cmd) == 1:
        mock_text = message.reply_to_message.text
    elif not message.reply_to_message and len(cmd) == 1:
        message.edit("I need something to mock")
        sleep(2)
        message.delete()
        return

    mock_results = BOT.get_inline_bot_results("stickerizerbot",
                                              "#7" + mock_text)
    try:
        BOT.send_inline_bot_result(chat_id=message.chat.id,
                                   query_id=mock_results.query_id,
                                   result_id=mock_results.results[0].id,
                                   reply_to_message_id=ReplyCheck(message),
                                   hide_via=True)
    except TimeoutError:
        message.edit("@StickerizerBot didn't respond in time.")
        sleep(2)
    message.delete()
Esempio n. 8
0
def unmute(bot: ShModBot, message: Message):
    """Removes a users mute.
    
    Parameters:
        bot (ShModBot): The bot itself
        message (Message): The message triggering the handler
    """
    message.delete()
    try:
        bot.restrict_chat_member(
            chat_id=message.chat.id,
            user_id=message.reply_to_message.from_user.id,
            permissions=ChatPermissions(
                can_send_messages=True,
                can_send_media_messages=True,
                can_send_other_messages=True,
                can_add_web_page_previews=True,
                can_send_polls=True,
                can_change_info=True,
                can_invite_users=True,
                can_pin_messages=True,
            ),
        )
    except Exception as err:
        bot.send_message(ShModBot.ADMIN_GROUP_ID, f"`{err}`")
Esempio n. 9
0
def PrivateCheck(message: Message):
    if message.chat.type == 'private':
        message.edit("Welcome messages are not supported in Private Chats.")
        sleep(2)
        message.delete()
        return None
    return True
Esempio n. 10
0
def glitch_image(bot: BOT, message: Message):
    if not message.reply_to_message:
        message.edit("`.glitch` needs to be a reply.")
        sleep(2)

    elif message.reply_to_message:
        try:
            glitch_amount = int(message.command[1])
        except (IndexError, ValueError):
            glitch_amount = 1

        glitch_this = message.reply_to_message.download()
        glitch_ext = glitch_this.split(".")[-1].lower()

        if glitch_ext in ('jpg', 'jpeg'):
            for _ in range(glitch_amount):
                glitched = glitchart.jpeg(photo=glitch_this, inplace=True)
            bot.send_photo(chat_id=message.chat.id,
                           photo=glitched,
                           caption=f"{glitch_amount} iterations"
                           if glitch_amount > 1 else "",
                           reply_to_message_id=ReplyCheck(message))

    message.delete()
    rmtree('downloads')
Esempio n. 11
0
def veg(client: Client, message: Message):
    try:
        message.delete()
    except (BadRequest, Forbidden):
        pass

    if len(message.command) < 2:
        return
    if len(message.command) < 3:
        message.reply_text('請輸入價格,或使用 `inline` 自動輸入。')
        return

    if not check_fcode(message.from_user):
        text = '請先使用 `/addfc` 來新增自己的好友代碼吧!\n'
        message.reply_text(text, parse_mode='markdown')
        return

    # 卡崩價錢
    price = int(message.command[-1])

    mongo = db_tools.use_mongo()
    mongo_query = {'chat.id': message.from_user.id}
    mongo_result = mongo.nintendo.find_one(mongo_query)
    user = from_dict(data_class=users, data=mongo_result)

    # 整理時間
    now = datetime.now(tz=timezone)
    hour = 8
    if now.hour > 12:
        # 下午惹
        hour = 12
    now = now.replace(hour=hour, minute=0, second=0, microsecond=0)
    if not user.acnh:
        message.reply_text('請先使用 /bindgame 來綁定動物森友會吧!')
        return
    if user.acnh.veg:
        for vegs in range(len(user.acnh.veg)):
            if user.acnh.veg[vegs].date == now:
                user.acnh.veg.pop(vegs)
        if len(user.acnh.veg) >= 14:
            user.acnh.veg.pop(-1)
        user.acnh.veg.append(VegData(date=now, price=price))
    else:
        user.acnh.veg = [VegData(date=now, price=price)]

    vegs = asdict(user.acnh)['veg']
    mongo_update = {'$set': {'acnh.veg': vegs}}
    mongo.nintendo.update_one(mongo_query, mongo_update)
    text = '#動物森友 #AnimalCrossing\n' \
           '大頭菜價格:`{price}` 鈴錢\n'.format(
               price=price
           )
    if not user.privacy:
        text += '好友代碼:`{fcode}`'.format(fcode=user.fcode)
    else:
        text += '因為[隱私設定]({url})因此不顯示好友代碼。'.format(
            url='t.me/NintendoFCode_bot?start=privacy')
    message.reply_text(text, reply_markup=keyboard.bindacnh(share=True),
                       disable_web_page_preview=True)
Esempio n. 12
0
def post_redpill(bot: BOT, message: Message):
    if re.match("(?i)(post|get|send) (redpill|meme|maymay)", message.text):
        image = random.choice(d['redpill_file_ids']['photo'])
        BOT.send_photo(chat_id=message.chat.id,
                       photo=image,
                       disable_notification=True)
        if message.from_user.is_self:
            message.delete()
Esempio n. 13
0
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)
Esempio n. 14
0
def send_dog(bot: BOT, message: Message):
    doggo = requests.get('https://random.dog/woof.json?filter=webm,mp4').json()
    BOT.send_photo(chat_id=message.chat.id,
                   photo=doggo['url'],
                   caption="doggo",
                   reply_to_message_id=ReplyCheck(message))
    if message.from_user.is_self:
        message.delete()
Esempio n. 15
0
def send_cat(bot: BOT, message: Message):
    doggo = requests.get('http://aws.random.cat/meow').json()
    BOT.send_photo(chat_id=message.chat.id,
                   photo=doggo['file'],
                   caption="catto",
                   reply_to_message_id=ReplyCheck(message))
    if message.from_user.is_self:
        message.delete()
Esempio n. 16
0
def send_dog(bot: BOT, message: Message):
    if re.match("(?i)(post|get|send) (dog|doggo|woof|🐶|🐕) (gif|gifs)", message.text):
        link_to_image = get_dog("webm,png,jpg,jpeg")
        BOT.send_animation(
            chat_id=message.chat.id, animation=link_to_image, disable_notification=True
        )
        if message.from_user.is_self:
            message.delete()
Esempio n. 17
0
def post_swift(bot: BOT, message: Message):
    if re.match("(?i)(post|get|send) (tay|taytay|taylor|tswift|swift|trap)",
                message.text):
        image = random.choice(d['swift_file_ids']['photo'])
        BOT.send_photo(chat_id=message.chat.id,
                       photo=image,
                       disable_notification=True)
        if message.from_user.is_self:
            message.delete()
Esempio n. 18
0
def dice_del(client: Client, message: Message):
    tg_user = message.from_user
    if message.reply_to_message:
        tg_user = message.reply_to_message.from_user

    user, _ = get_user_model(tg_user)
    today = date.today()
    DiceEvent.objects.filter(user=user, date__date=today, is_win=True).update(is_win=False)
    message.delete()
Esempio n. 19
0
def format_blank(bot: BOT, message: Message):
    try:
        cmdstr = " ".join(message.command[1:])
    except IndexError:
        message.edit("__I can't...__")
        sleep(2)
        message.delete()
        return

    message.edit(hashlib.sha384(cmdstr.encode('utf-8')).hexdigest())
Esempio n. 20
0
def format_blank(bot: BOT, message: Message):
    if message.reply_to_message:
        GiveReplyObj(message).edit(
            "󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰"
        )
        message.delete()
    else:
        message.edit(
            "󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰󠇰"
        )
Esempio n. 21
0
def format_blank(bot: BOT, message: Message):
    try:
        cmdstr = " ".join(message.command[1:])
    except IndexError:
        message.edit("__I can't...__")
        sleep(2)
        message.delete()
        return

    message.edit(' '.join(format(ord(x), 'b') for x in cmdstr))
Esempio n. 22
0
def post_sminem(bot: BOT, message: Message):
    if re.match(
            "(?i)(post|get|send) (sminem|smnem|smn|big ear (kid|guy)|chromosome)",
            message.text):
        image = random.choice(d['sminem_file_ids']['photo'])
        BOT.send_photo(chat_id=message.chat.id,
                       photo=image,
                       disable_notification=True)
        if message.from_user.is_self:
            message.delete()
Esempio n. 23
0
def post_watson(bot: BOT, message: Message):
    if re.match(
            "(?i)(post|get|send) (w***e|s**t|watson|emma|hermione|granger|harry potter girl)",
            message.text):
        image = random.choice(d['emma_file_ids']['photo'])
        BOT.send_photo(chat_id=message.chat.id,
                       photo=image,
                       disable_notification=True)
        if message.from_user.is_self:
            message.delete()
Esempio n. 24
0
def post_911(bot: BOT, message: Message):
    if re.match(
            "(?i)((post|get|send) (911|bush|twin towers|wtc)|bush did (911|9/11))",
            message.text):
        image = random.choice(d['911_file_ids']['photo'])
        BOT.send_photo(chat_id=message.chat.id,
                       photo=image,
                       disable_notification=True)
        if message.from_user.is_self:
            message.delete()
Esempio n. 25
0
def post_omdb(bot: BOT, message: Message):
    message_text = message.text.replace("!omdb ", "")
    text = get_omdb(message_text)
    BOT.send_message(
        chat_id=message.chat_id,
        text=text,
        disable_notification=True,
        reply_to_message_id=ReplyCheck(message),
    )
    if message.from_user.is_self:
        message.delete()
Esempio n. 26
0
def sleep_timeout_and_delmsg(msg: Message, timeout: int = 15) -> None:
    """
	To delete a message after a timeout.
	The timeout is 15 by default.
	This will be helpful to the response of a command and the command message itself.
	"""
    sleep(timeout)
    try:
        msg.delete()
    except:
        pass
Esempio n. 27
0
def post_trump(bot: BOT, message: Message):
    if re.match("(?i)(post|get|send) (drumpf|trump|orange man)", message.text):
        image = random.choice(d['drump_file_ids']['photo'])
        BOT.send_photo(
            chat_id=message.chat.id,
            photo=image,
            disable_notification=True,
            caption=drumpf_quote(),
        )
        if message.from_user.is_self:
            message.delete()
Esempio n. 28
0
def evaluation(bot: BOT, message: Message):
    try:
        cmdstr = " ".join(message.command[1:])
    except IndexError:
        message.edit("__I can't paste nothing sadly...__")
        sleep(2)
        message.delete()
        return

    if cmdstr:
        message.edit(post(cmdstr))  ## Making the Paste and give out the Link for the Response
Esempio n. 29
0
def send_dog_gif(bot: BOT, message: Message):
    if re.match("(?i)(post|get|send) (dog|doggo|woof|🐶|🐕)", message.text):
        if randint(0, 1) == 1:
            link_to_image = get_dog("webm,mp4")
        else:
            link_to_image = get_doggo()
        BOT.send_photo(
            chat_id=message.chat.id, photo=link_to_image, disable_notification=True
        )
        if message.from_user.is_self:
            message.delete()
Esempio n. 30
0
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)