Пример #1
0
def lock(bot, update, args):
    chat = update.effective_chat
    message = update.effective_message
    if can_delete(chat, bot.id):
        if len(args) >= 1:
            if args[0] in LOCK_TYPES:
                sql.update_lock(chat.id, args[0], locked=True)
                message.reply_text("Locked {} messages for all non-admins!".format(args[0]))

            elif args[0] in RESTRICTION_TYPES:
                sql.update_restriction(chat.id, args[0], locked=True)
                members = users_sql.get_chat_members(chat.id)
                if args[0] == "messages":
                    restr_members(bot, chat.id, members)

                elif args[0] == "media":
                    restr_members(bot, chat.id, members, messages=True)

                elif args[0] == "other":
                    restr_members(bot, chat.id, members, messages=True, media=True)

                elif args[0] == "previews":
                    restr_members(bot, chat.id, members, messages=True, media=True, other=True)

                elif args[0] == "all":
                    restr_members(bot, chat.id, members)

                message.reply_text("Locked {} for all non-admins!".format(args[0]))

            else:
                message.reply_text("What are you trying to lock...? Try /locktypes for the list of lockables")

    else:
        message.reply_text("I'm not an administrator, or haven't got delete rights.")
Пример #2
0
def rest_msg(bot, update):
    msg = update.effective_message
    chat = update.effective_chat
    if sql.is_restr_locked(chat.id, "messages") \
            and can_delete(chat, bot.id) \
            and not is_user_admin(chat, msg.from_user.id):
        msg.delete()
        bot.restrict_chat_member(chat.id, msg.from_user.id,
                                 can_send_messages=False)
Пример #3
0
def purge(bot, update):
    curr_message = update.effective_message
    chat = update.effective_chat
    if can_delete(chat, bot.id):
        message_id = curr_message.reply_to_message.message_id
        curr_message_id = curr_message.message_id
        for m_id in range(message_id, curr_message_id + 1):  # +1 to include curr message
            try:
                bot.deleteMessage(chat.id, m_id)
            except BadRequest as err:
                print(err)
        bot.send_message(chat.id, "Purge complete, *Master*.", 'Markdown')
Пример #4
0
def rest_previews(bot, update):
    msg = update.effective_message
    chat = update.effective_chat
    if sql.is_restr_locked(chat.id, "previews") \
            and can_delete(chat, bot.id) \
            and not is_user_admin(chat, msg.from_user.id):
        msg.delete()
        bot.restrict_chat_member(chat.id, msg.from_user.id,
                                 can_send_messages=True,
                                 can_send_media_messages=True,
                                 can_send_other_messages=True,
                                 can_add_web_page_previews=False)
Пример #5
0
def del_message(bot, update):
    chat = update.effective_chat
    if can_delete(chat, bot.id):
        update.effective_message.reply_to_message.delete()
        update.effective_message.delete()
Пример #6
0
def del_gif(bot, update):
    chat = update.effective_chat
    if sql.is_locked(chat.id, "gif") and can_delete(chat, bot.id):
        update.effective_message.delete()