Ejemplo n.º 1
0
def ungmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id = extract_user(message, args)
    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    user_chat = bot.get_chat(user_id)
    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if not sql.is_user_gmuted(user_id):
        message.reply_text("This user is not gmuted!")
        return

    muter = update.effective_user  # type: Optional[User]

    message.reply_text("I'll give {} a second chance, globally.".format(
        user_chat.first_name))

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} has ungmuted user {}".format(
                     mention_html(muter.id, muter.first_name),
                     mention_html(user_chat.id, user_chat.first_name)),
                 html=True)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            member = bot.get_chat_member(chat_id, user_id)
            if member.status == 'muted':
                bot.unmute_chat_member(chat_id, user_id)

        except BadRequest as excp:
            if excp.message in UNGMUTE_ERRORS:
                pass
            else:
                message.reply_text("Could not un-gmute due to: {}".format(
                    excp.message))
                bot.send_message(
                    OWNER_ID,
                    "Could not un-gmute due to: {}".format(excp.message))
                return
        except TelegramError:
            pass

    sql.ungmute_user(user_id)

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "un-gmute complete!")

    message.reply_text("Person has been un-gmuted.")
Ejemplo n.º 2
0
def gmutestat(bot: Bot, update: Update, args: List[str]):
    if len(args) > 0:
        if args[0].lower() in ["on", "yes"]:
            sql.enable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text("Qlobal susdurmuanı bu qrupda aktiv elədim.")
        elif args[0].lower() in ["off", "no"]:
            sql.disable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text("Qlobal susdurmanı bu qrupda deaktiv elədim.")
    else:
        update.effective_message.reply_text("Mənə arqument verməlisən! on/off, yes/no!\n\n"
                                            "Sənin hazırki seçimin: {}\n"
                                            "Aktiv olduqda qrupda qlobal susdurma işləyəcək. "
                                            "Deaktiv olduqda isə əksinə.".format(sql.does_chat_gmute(update.effective_chat.id)))
Ejemplo n.º 3
0
def gmutestat(bot: Bot, update: Update, args: List[str]):
    if len(args) > 0:
        if args[0].lower() in ["on", "yes"]:
            sql.enable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text("   Games   .     "
                                                "      .")
        elif args[0].lower() in ["off", "no"]:
            sql.disable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text("   Gotsung   . Gathes Wont   "
                                                " .       !")
    else:
        update.effective_message.reply_text("      !on/off, yes/no!\n\n"
                                            "    : {}\n"
                                            "        ."
                                            "      "
                                            "spammers.".format(sql.does_chat_gmute(update.effective_chat.id)))
Ejemplo n.º 4
0
def gmutestat(bot: Bot, update: Update, args: List[str]):
    if len(args) > 0:
        if args[0].lower() in ["on", "yes"]:
            sql.enable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text("I've enabled gmutes in this group. This will help protect you "
                                                "from spammers, unsavoury characters, and Anirudh.")
        elif args[0].lower() in ["off", "no"]:
            sql.disable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text("I've disabled gmutes in this group. GMutes wont affect your users "
                                                "anymore. You'll be less protected from Anirudh though!")
    else:
        update.effective_message.reply_text("Give me some arguments to choose a setting! on/off, yes/no!\n\n"
                                            "Your current setting is: {}\n"
                                            "When True, any gmutes that happen will also happen in your group. "
                                            "When False, they won't, leaving you at the possible mercy of "
                                            "spammers.".format(sql.does_chat_gmute(update.effective_chat.id)))
Ejemplo n.º 5
0
def gmutestat(bot: Bot, update: Update, args: List[str]):
    if len(args) > 0:
        if args[0].lower() in ["on", "yes"]:
            sql.enable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text("මම මෙම කණ්ඩායමේ gmutes සක්‍රීය කර ඇත. මෙය ඔබව ආරක්ෂා කිරීමට උපකාරී වේ "
                                                "අයාචිත තැපැල්, අප්‍රසන්න චරිත සහ අනිරුද් වෙතින්.")
        elif args[0].lower() in ["off", "no"]:
            sql.disable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text("මම මෙම කණ්ඩායමේ gmutes අක්‍රීය කර ඇත. GMutes ඔබේ පරිශීලකයින්ට බලපාන්නේ නැත"
                                                "තවදුරටත්. ඔබට අඩු ආරක්ෂාවක් ලැබෙනු ඇත!")
    else:
        update.effective_message.reply_text("පසුබිමක් තෝරා ගැනීමට මට තර්ක කිහිපයක් දෙන්න! on/off, yes/no!\n\n"
                                            "ඔබගේ වර්තමාන සැකසුම: {}\n"
                                            "සත්‍ය වූ විට, සිදුවන ඕනෑම විකාරයක් ඔබගේ කණ්ඩායම තුළ ද සිදුවනු ඇත. "
                                            "අසත්‍ය වූ විට, ඔවුන් එසේ නොකරනු ඇත"
                                            "spammers.".format(sql.does_chat_gmute(update.effective_chat.id)))
Ejemplo n.º 6
0
def enforce_gmute(bot: Bot, update: Update):
    # Not using @restrict handler to avoid spamming - just ignore if cant gmute.
    if sql.does_chat_gmute(update.effective_chat.id) and update.effective_chat.get_member(bot.id).can_restrict_members:
        user = update.effective_user  # type: Optional[User]
        chat = update.effective_chat  # type: Optional[Chat]
        msg = update.effective_message  # type: Optional[Message]

        if user and not is_user_admin(chat, user.id):
            check_and_mute(bot, update, user.id, should_message=True)
        if msg.new_chat_members:
            new_members = update.effective_message.new_chat_members
            for mem in new_members:
                check_and_mute(bot, update, mem.id, should_message=True)
        if msg.reply_to_message:
            user = msg.reply_to_message.from_user  # type: Optional[User]
            if user and not is_user_admin(chat, user.id):
                check_and_mute(bot, update, user.id, should_message=True)
Ejemplo n.º 7
0
def gmutestat(bot: Bot, update: Update, args: List[str]):
    if len(args) > 0:
        if args[0].lower() in ["on", "yes"]:
            sql.enable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text(
                "I've enabled gmutes in this group. This will help protect you "
                "from spammers, unsavoury characters, and Anirudh.")
        elif args[0].lower() in ["off", "no"]:
            sql.disable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text(
                "I've disabled gmutes in this group. GMutes wont affect your users "
                "anymore. You'll be less protected from Anirudh though!")
    else:
        update.effective_message.reply_text(
            "ഒരു ക്രമീകരണം തിരഞ്ഞെടുക്കാൻ എനിക്ക് കുറച്ച് ആർഗ്യുമെന്റുകൾ നൽകുക! on/off, yes/no!\n\n"
            "നിങ്ങളുടെ നിലവിലെ ക്രമീകരണം ഇതാണ്: {}\n"
            "ശരിയാണെങ്കിൽ, സംഭവിക്കുന്ന ഏത് gmutes ഉം നിങ്ങളുടെ ഗ്രൂപ്പിൽ സംഭവിക്കും. "
            "തെറ്റാണെങ്കിൽ‌, അവർ‌ സമ്മതിക്കില്ല, സ്പാമർ‌മാരുടെ കാരുണ്യത്തിൽ‌ നിങ്ങളെ ഒഴിവാക്കും."
            "spammers.".format(sql.does_chat_gmute(update.effective_chat.id)))
Ejemplo n.º 8
0
def gmutestat(bot: Bot, update: Update, args: List[str]):
    if len(args) > 0:
        if args[0].lower() in ["on", "yes"]:
            sql.enable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text(
                "I've enabled gmutes in this group. This will help protect you "
                "from spammers, unsavoury characters, and Anirudh.")
        elif args[0].lower() in ["off", "no"]:
            sql.disable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text(
                "I've disabled gmutes in this group. GMutes wont affect your users "
                "anymore. You'll be less protected from Anirudh though!")
    else:
        update.effective_message.reply_text(
            "Nipe hoja chache kuchagua mpangilio! on/off, yes/no!\n\n"
            "Huu ni mpangilio wako wa sasa: {}\n"
            "Ikiwa ni kweli, chochote kinachotokea gmutes Na hiyo hufanyika katika kikundi chako. "
            "Ikiwa ni makosa, hawatakubali na watakuokoa huruma ya spammers."
            "spammers.".format(sql.does_chat_gmute(update.effective_chat.id)))
Ejemplo n.º 9
0
def gmutestat(bot: Bot, update: Update, args: List[str]):
    if len(args) > 0:
        if args[0].lower() in ["on", "yes"]:
            sql.enable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text(
                "I've enabled gmutes in this group. This will help protect you "
                "from spammers, unsavoury characters, and Anirudh.")
        elif args[0].lower() in ["off", "no"]:
            sql.disable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text(
                "I've disabled gmutes in this group. GMutes wont affect your users "
                "anymore. You'll be less protected from Anirudh though!")
    else:
        update.effective_message.reply_text(
            "Give me a few arguments to choose a setting! on/off, yes/no!\n\n"
            "This is your current setting: {}\n"
            "If so, which happens gmutes And will happen in your group. "
            "If wrong, they will not agree, You will be spared at the mercy of spammers."
            "spammers.".format(sql.does_chat_gmute(update.effective_chat.id)))
Ejemplo n.º 10
0
def gmutestat(bot: Bot, update: Update, args: List[str]):
    if len(args) > 0:
        if args[0].lower() in ["on", "yes"]:
            sql.enable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text(
                "Bu grupta küresel susturmaları etkinleştirdim. Bu sizi spam gönderenlerden  "
                "hoş olmayan karakterlerden ve en büyük trollerden korumaya yardımcı olacak."
            )
        elif args[0].lower() in ["off", "no"]:
            sql.disable_gmutes(update.effective_chat.id)
            update.effective_message.reply_text(
                "Bu grupta gbaları devre dışı bıraktım. Küresel susturmalar, kullanıcılarınızı etkilemez "
                "Herhangi bir troll veya spam göndericiden daha az korunacaksınız!"
            )
    else:
        update.effective_message.reply_text(
            "Etkinleştirmek için on/yes veya devre dışı bırakmak için off/no kullanabilirsin\n\n"
            "Şu anki ayar: {}\n"
            "Açık olduğunda, Tüm küreseler susturmalar grubunuza da etki eder. "
            "Kapalı olduğunda sizi spammerlerin muhtemel merhametine "
            "bırakacağım.".format(sql.does_chat_gmute(
                update.effective_chat.id)))
Ejemplo n.º 11
0
def __chat_settings__(chat_id, user_id):
    return "   * Gamutes *: `{}`.".format(sql.does_chat_gmute(chat_id))
Ejemplo n.º 12
0
def __chat_settings__(chat_id, user_id):
    return "Czat używa *globalnych wyciszeń*: `{}`.".format(
        sql.does_chat_gmute(chat_id))
Ejemplo n.º 13
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gmute a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- So funny, lets gmute myself why don't I? Nice try.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text(
                "This user is already gmuted; I'd change the reason, but you haven't given me one..."
            )
            return

        success = sql.update_gmute_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text(
                "This user is already gmuted; I've gone and updated the gmute reason though!"
            )
        else:
            message.reply_text(
                "Do you mind trying again? I thought this person was gmuted, but then they weren't? "
                "Am very confused")

        return

    message.reply_text("*Gets duct tape ready* 😉")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gmuting user {} "
                 "because:\n{}".format(
                     mention_html(muter.id, muter.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Group chat was deactivated":
                pass
            elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            elif excp.message == "Only the creator of a basic group can kick group administrators":
                pass
            elif excp.message == "Method is available only for supergroups":
                pass
            elif excp.message == "Can't demote chat creator":
                pass
            else:
                message.reply_text("Could not gmute due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gmute due to: {}".format(excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gmute complete!")
    message.reply_text("Person has been gmuted.")
Ejemplo n.º 14
0
def ungmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id = extract_user(message, args)
    if not user_id:
        message.reply_text("Bir istifadəçiyə istinad etmirsiniz.")
        return

    user_chat = bot.get_chat(user_id)
    if user_chat.type != 'private':
        message.reply_text("BU bir istifadəçi deyil!")
        return

    if not sql.is_user_gmuted(user_id):
        message.reply_text("Bu istifadəçi qlobal olaraq susdurulmayıb!")
        return

    muter = update.effective_user  # type: Optional[User]

    message.reply_text("{} istifadəçisini əfv elədim. O artıq qlobal olaraq danışa bilər.".format(user_chat.first_name))

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "{} istifadəçisi {} istifadəçisinin qlobal olaraq səsini açdı.".format(mention_html(muter.id, muter.first_name),
                                                   mention_html(user_chat.id, user_chat.first_name)),
                 html=True)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            member = bot.get_chat_member(chat_id, user_id)
            if member.status == 'restricted':
                bot.restrict_chat_member(chat_id, int(user_id),
                                     can_send_messages=True,
                                     can_send_media_messages=True,
                                     can_send_other_messages=True,
                                     can_add_web_page_previews=True)

        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Method is available for supergroup and channel chats only":
                pass
            elif excp.message == "Not in the chat":
                pass
            elif excp.message == "Channel_private":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            else:
                message.reply_text("Could not un-gmute due to: {}".format(excp.message))
                bot.send_message(OWNER_ID, "Could not un-gmute due to: {}".format(excp.message))
                return
        except TelegramError:
            pass

    sql.ungmute_user(user_id)

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "un-gmute tamamlandı!")

    message.reply_text("İstifadəçi qlobal olaraq danışa bilər.")
Ejemplo n.º 15
0
         message.reply_text("Do you mind trying again? I thought this person was gmuted, but then they weren't? "
                            "Am very confused")
      return
  message.reply_text("*Gets duct tape ready* 😉")
  muter = update.effective_user  # type: Optional[User]
 send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
              "{} is gmuting user {} "
              "because:\n{}".format(mention_html(muter.id, muter.first_name),
                                    mention_html(user_chat.id, user_chat.first_name), reason or "No reason given"),
              html=True)
  sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)
  chats = get_all_chats()
 for chat in chats:
     chat_id = chat.chat_id
      # Check if this group has disabled gmutes
     if not sql.does_chat_gmute(chat_id):
         continue
      try:
         bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
     except BadRequest as excp:
         if excp.message == "User is an administrator of the chat":
             pass
         elif excp.message == "Chat not found":
             pass
         elif excp.message == "Not enough rights to restrict/unrestrict chat member":
             pass
         elif excp.message == "User_not_participant":
             pass
         elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
             pass
         elif excp.message == "Group chat was deactivated":
Ejemplo n.º 16
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Bir istifadəçiyə istinad etmirsiniz.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Mən öz balaca gözlərim ilə ağlayıram... bir sudo istifadəçi müharibəsi! Siz niyə bir birinizə bumu edirsiniz?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("OOOH! kimsə bir suppport isitfadəçisini global olaraq susdurmaq istəyir *popcorn alıb izləyirəm*")
        return

    if user_id == bot.id:
        message.reply_text("-_- Çox əyləncəlidir, gəl özümü qlobal olaaq susdurum? Gözəl cəhd.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("Bu bir istifadəçi deyil!")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text("Bu istifadəçi onsuz da qlobal olaraq susdurulub; Səbəbi dəyişərdim amma bir səbəb verməmisən...")
            return

        success = sql.update_gmute_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text("Bu istifadəçi onsuz da qlobal olaraq susdurulub; Köhnə səbəbi yenisi ilə əvəz etdim!")
        else:
            message.reply_text("Yenidən cəhd etməyi düşünmürsən? Bu adamın qlobal olaraq susdurulduğunu düşünürdüm, amma sonra deyildilər? "
                               "Çox qarışıqam")

        return

    message.reply_text("Yapışqan lenti hazır vəziyyətə gətirdim 😉")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "{} {} istifadəçisini qlobal olaraq susdurur "
                 "çünki:\n{}".format(mention_html(muter.id, muter.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or "Səbəb verilməyib"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Group chat was deactivated":
                pass
            elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            elif excp.message == "Only the creator of a basic group can kick group administrators":
                pass
            elif excp.message == "Method is available only for supergroups":
                pass
            elif excp.message == "Can't demote chat creator":
                pass
            else:
                message.reply_text("Could not gmute due to: {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Could not gmute due to: {}".format(excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gmute tamamlandı!")
    message.reply_text("İstifadəçi qlobal olaraq susduruldu.")
Ejemplo n.º 17
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("ඔබ පරිශීලකයෙකු වෙත යොමු වන බවක් නොපෙනේ.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("මම ඔත්තු බැලුවෙමි, මගේ කුඩා ඇසෙන් ... සුඩෝ පරිශීලක යුද්ධයක්! ඇයි ඔයාලා එකිනෙකාට හරවන්නේ?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("OOOH යමෙක් ආධාරක පරිශීලකයෙකු මැඩපැවැත්වීමට උත්සාහ කරයි! *පොප්කෝන් අල්ලා ගනී😎😎*")
        return

    if user_id == bot.id:
        message.reply_text("-_- හරිම විහිලුයි, ඇයි මම නැත්තේ? හොඳයි උත්සාහ කරන්න.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text("මෙම පරිශීලකයා දැනටමත් gmuted; මම හේතුව වෙනස් කරන්නම්, නමුත් ඔබ මට එකක් දුන්නේ නැහැ ...🥺🥺")
            return

        success = sql.update_gmute_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text("මෙම පරිශීලකයා දැනටමත් gmuted; මම ගොස් gmute හේතුව යාවත්කාලීන කර ඇත!")
        else:
            message.reply_text("නැවත උත්සාහ කිරීමට ඔබට අවශ්‍යද? මම හිතුවේ මේ පුද්ගලයා gmuted ඇති, නමුත් පසුව ඔවුන් එසේ නොවේ? "
                               "Am very confused")

        return

    message.reply_text("*ඩක් ටේප් සූදානම්* 😉")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "{} is gmuting user {} "
                 "because:\n{}".format(mention_html(muter.id, muter.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or "කිසිදු හේතුවක් දක්වා නැත"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "පරිශීලකයා චැට් හි පරිපාලකයෙකි":
                pass
            elif excp.message == "චැට් හමු නොවීය":
                pass
            elif excp.message == "චැට් සාමාජිකයාව සීමා කිරීමට / සීමා කිරීමට ප්‍රමාණවත් අයිතිවාසිකම් නොමැත":
                pass
            elif excp.message == "සහභාගිවන්නා_භාවිතා_කරන්න":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "කණ්ඩායම් කතාබහ අක්‍රිය කරන ලදි":
                pass
            elif excp.message == "මූලික කණ්ඩායමකින් එය පයින් ගැසීමට පරිශීලකයෙකුගේ ආරාධිතයා විය යුතුය":
                pass
            elif excp.message == "චැට්_පරිපාලක_අවශ්‍යයි":
                pass
            elif excp.message == "කණ්ඩායම් පරිපාලකයින්ට kick ගැසිය හැක්කේ මූලික කණ්ඩායමක නිර්මාතෘට පමණි":
                pass
            elif excp.message == "ක්‍රමය ලබා ගත හැක්කේ සුපිරි කණ්ඩායම් සඳහා පමණි":
                pass
            elif excp.message == "චැට් නිර්මාතෘ පහත් කළ නොහැක":
                pass
            else:
                message.reply_text("නිසා gmute කිරීමට නොහැකි විය: {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "නිසා gmute කිරීමට නොහැකි විය: {}".format(excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gmute complete!")
    message.reply_text("පුද්ගලයා gmute කර ඇත.")
Ejemplo n.º 18
0
def ungmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id = extract_user(message, args)
    if not user_id:
        message.reply_text("ඔබ පරිශීලකයෙකු වෙත යොමු වන බවක් නොපෙනේ.")
        return

    user_chat = bot.get_chat(user_id)
    if user_chat.type != 'private':
        message.reply_text("එය පරිශීලකයෙකු නොවේ!")
        return

    if not sql.is_user_gmuted(user_id):
        message.reply_text("මෙම පරිශීලකයා gmuted නොවේ!")
        return

    muter = update.effective_user  # type: Optional[User]

    message.reply_text("මම ඉඩ දෙන්නම් {} ගෝලීයව නැවත කතා කරන්න.".format(user_chat.first_name))

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "{} ඉවත් නොකළ පරිශීලකයෙකු ඇත {}".format(mention_html(muter.id, muter.first_name),
                                                   mention_html(user_chat.id, user_chat.first_name)),
                 html=True)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            member = bot.get_chat_member(chat_id, user_id)
            if member.status == 'restricted':
                bot.restrict_chat_member(chat_id, int(user_id),
                                     can_send_messages=True,
                                     can_send_media_messages=True,
                                     can_send_other_messages=True,
                                     can_add_web_page_previews=True)

        except BadRequest as excp:
            if excp.message == "පරිශීලකයා චැට් හි පරිපාලකයෙකි":
                pass
            elif excp.message == "චැට් හමු නොවීය":
                pass
            elif excp.message == "චැට් සාමාජිකයාව සීමා කිරීමට / සීමා නොකිරීමට ප්‍රමාණවත් අයිතිවාසිකම් නොමැත":
                pass
            elif excp.message == "පරිශීලකයා_සහභාගී_නොවෙ":
                pass
            elif excp.message == "සුපිරි කණ්ඩායම් සහ නාලිකා කතාබස් සඳහා පමණක් ක්‍රමය තිබේ":
                pass
            elif excp.message == "චැට් එකේ නැහැ":
                pass
            elif excp.message == "නාලිකාව_පුද්ගලිකයි:
                pass
            elif excp.message == "චැට්_පරිපාලක_අවශ්‍යයි":
                pass
            else:
                message.reply_text("මේ නිසා ඉවත් කිරීමට නොහැකි විය: {}".format(excp.message))
                bot.send_message(OWNER_ID, "මේ නිසා ඉවත් කිරීමට නොහැකි විය: {}".format(excp.message))
                return
        except TelegramError:
            pass

    sql.ungmute_user(user_id)

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "un-gmute complete!")

    message.reply_text("පුද්ගලයා නිරුපද්‍රිතව ඇත.")
Ejemplo n.º 19
0
def __chat_settings__(chat_id, user_id):
    return "Bu qrupdakı ayar: `{}`.".format(sql.does_chat_gmute(chat_id))
Ejemplo n.º 20
0
def ungmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id = extract_user(message, args)
    if not user_id:
        message.reply_text("Deyəsən bir istifadəçiyə istinad etmirsiniz.")
        return

    user_chat = bot.get_chat(user_id)
    if user_chat.type != 'private':
        message.reply_text("Bu istifadəçi deyil!")
        return

    if not sql.is_user_gmuted(user_id):
        message.reply_text("Bu istifadəçi qlobalda onsuz rahat danışa bilir.")
        return

    muter = update.effective_user  # type: Optional[User]

    message.reply_text(
        "Yaxşı {} sənə ikici şans verirəm qlobalda danışa bilərsən.".format(
            user_chat.first_name))

    send_to_list(
        bot,
        SUDO_USERS + SUPPORT_USERS,
        "{} adlı istifadəçi  {}-nin qlobalda danışmasına icazə verdi".format(
            mention_html(muter.id, muter.first_name),
            mention_html(user_chat.id, user_chat.first_name)),
        html=True)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            member = bot.get_chat_member(chat_id, user_id)
            if member.status == 'restricted':
                bot.restrict_chat_member(chat_id,
                                         int(user_id),
                                         can_send_messages=True,
                                         can_send_media_messages=True,
                                         can_send_other_messages=True,
                                         can_add_web_page_previews=True)

        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Method is available for supergroup and channel chats only":
                pass
            elif excp.message == "Not in the chat":
                pass
            elif excp.message == "Channel_private":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            else:
                message.reply_text(
                    "Bu istifadəçini ungmute etmək olmur {}".format(
                        excp.message))
                bot.send_message(
                    OWNER_ID,
                    "Bu Səbəbə görə səssizləşdirilə bilmədi: {}".format(
                        excp.message))
                return
        except TelegramError:
            pass

    sql.ungmute_user(user_id)

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Əməliyyatlar bitdi")

    message.reply_text("İstifadəçi qlobalda danışa bilər.")
Ejemplo n.º 21
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("     .")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("I spy, with my little eye... a sudo user war! Why are you guys turning on each other?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("      ! *    *")
        return

    if user_id == bot.id:
        message.reply_text("-_-    Geat Pri      .")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("  !")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text("          ...")
            return

        success = sql.update_gmute_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text("           !")
        else:
            message.reply_text("                "
                               "  ")

        return

    message.reply_text("*                         *")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "{} is gmuting user {} "
                 "because:\n{}".format(mention_html(muter.id, muter.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or "No reason given"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Group chat was deactivated":
                pass
            elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            elif excp.message == "Only the creator of a basic group can kick group administrators":
                pass
            elif excp.message == "Method is available only for supergroups":
                pass
            elif excp.message == "Can't demote chat creator":
                pass
            else:
                message.reply_text("   : {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Could not gmute due to: {}".format(excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gmute complete!")
    message.reply_text(" gmputed .")
Ejemplo n.º 22
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gmute a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- So funny, lets gmute myself why don't I? Nice try.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text(
                "This user is already gmuted; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gmute_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "This user is already gmuted, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "This user is already gmuted, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text("*Blows dust off of mutehammer* 😉")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gmuting user {} "
                 "because:\n{}".format(
                     mention_html(muter.id, muter.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.mute_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GMUTE_ERRORS:
                pass
            else:
                message.reply_text("Could not gmute due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gmute due to: {}".format(excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gmute complete!")
    message.reply_text("Person has been gmuted.")
Ejemplo n.º 23
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text(
            "നിങ്ങൾ ഒരു യൂസേറിനെ റെഫർ ചെയ്യുന്നതായി തോന്നുന്നില്ല.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gmute a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- ആഹ് നല്ല കോമഡി😂 നിനക്കു ഞാൻ മിണ്ടുന്നത് കൊണ്ടെന്താ കൊഴപ്പം?.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("അതൊരു യൂസർ അല്ല !")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text(
                "ഈ യൂസേറിനെ മുന്നേ തന്നെ gmute ചെയ്തതാണ്; ഞാൻ വേണേൽ gmute ചെയ്യാനുള്ള കാരണം മാറ്റാം, പക്ഷേ നിങ്ങൾ ഒരു കാരണവും തന്നിട്ടില്ലല്ലോ..."
            )
            return

        success = sql.update_gmute_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text(
                "This user is already gmuted; I've gone and updated the gmute reason though!"
            )
        else:
            message.reply_text(
                "Do you mind trying again? I thought this person was gmuted, but then they weren't? "
                "Am very confused")

        return

    message.reply_text("*Gets duct tape ready* 😉")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gmuting user {} "
                 "because:\n{}".format(
                     mention_html(muter.id, muter.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Group chat was deactivated":
                pass
            elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            elif excp.message == "Only the creator of a basic group can kick group administrators":
                pass
            elif excp.message == "Method is available only for supergroups":
                pass
            elif excp.message == "Can't demote chat creator":
                pass
            else:
                message.reply_text("Could not gmute due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gmute due to: {}".format(excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gmute complete!")
    message.reply_text("Person has been gmuted.")
Ejemplo n.º 24
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Deyəsən bir istifadəçiyə istinad etmirsiniz.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "Mən kiçik gözümlə casusluq edirəm ... sudo istifadəçiləri müharibəsi! Uşaqlar niyə bir-birinizlə dalaşırsız?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "AHAHAH Kimsə Support İstifadəçini Qlobal Mute etmək istiyir *popcorn gətirim gəlirəm*"
        )
        return

    if user_id == bot.id:
        message.reply_text("Çox gülməli idi birdə yoxla.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("Bu istifadəçi deyil!")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text(
                "Bu istifadəçi artıq səssizləşdirilib səbəb bildirilməyib")
            return

        success = sql.update_gmute_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text("İstifadəçisi onsuz da səssizdir!")
        else:
            message.reply_text("İstifadəçisi onsuz da səssizdir! "
                               "Başım çox qarışdı")

        return

    message.reply_text("*Hazırlaşın qlobal mute gəlir* 😉")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} adlı istifadəçi {}-ni susturdu "
                 "Səbəb:\n{}".format(
                     mention_html(muter.id, muter.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Group chat was deactivated":
                pass
            elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            elif excp.message == "Only the creator of a basic group can kick group administrators":
                pass
            elif excp.message == "Method is available only for supergroups":
                pass
            elif excp.message == "Can't demote chat creator":
                pass
            else:
                message.reply_text("Could not gmute due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gmute due to: {}".format(excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Əməliyyatlar bitdi")
    message.reply_text("İstifadəçi qlobalda susturldu.")
Ejemplo n.º 25
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gmute a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- So funny, lets gmute myself why don't I? Nice try.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text(
                "This user is already gmuted; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gmute_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        user_id, new_reason = extract_user_and_text(message, args)
        if old_reason:
            muter = update.effective_user  # type: Optional[User]
            send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                     "<b>Emendation of Global Mute</b>" \
                     "\n#GMUTE" \
                     "\n<b>Status:</b> <code>Amended</code>" \
                     "\n<b>Sudo Admin:</b> {}" \
                     "\n<b>User:</b> {}" \
                     "\n<b>ID:</b> <code>{}</code>" \
                     "\n<b>Previous Reason:</b> {}" \
                     "\n<b>Amended Reason:</b> {}".format(mention_html(muter.id, muter.first_name),
                                              mention_html(user_chat.id, user_chat.first_name or "Deleted Account"),
                                                           user_chat.id, old_reason, new_reason),
                    html=True)

            message.reply_text(
                "This user is already gmuted, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            muter = update.effective_user  # type: Optional[User]
            send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                     "<b>Emendation of Global Mute</b>" \
                     "\n#GMUTE" \
                     "\n<b>Status:</b> <code>New reason</code>" \
                     "\n<b>Sudo Admin:</b> {}" \
                     "\n<b>User:</b> {}" \
                     "\n<b>ID:</b> <code>{}</code>" \
                     "\n<b>New Reason:</b> {}".format(mention_html(muter.id, muter.first_name),
                                              mention_html(user_chat.id, user_chat.first_name or "Deleted Account"),
                                                           user_chat.id, new_reason),
                    html=True)
            message.reply_text(
                "This user is already gmuted, but had no reason set; I've gone and updated it!"
            )

        return

    starting = "Initiating global mute for {}...".format(
        mention_html(user_chat.id, user_chat.first_name or "Deleted Account"))
    keyboard = []
    message.reply_text(starting,
                       reply_markup=keyboard,
                       parse_mode=ParseMode.HTML)

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Mute</b>" \
                 "\n#GMUTE" \
                 "\n<b>Status:</b> <code>Enforcing</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Reason:</b> {}".format(mention_html(muter.id, muter.first_name),
                                              mention_html(user_chat.id, user_chat.first_name or "Deleted Account"),
                                                           user_chat.id, reason or "No reason given"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Group chat was deactivated":
                pass
            elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            elif excp.message == "Only the creator of a basic group can kick group administrators":
                pass
            elif excp.message == "Method is available only for supergroups":
                pass
            elif excp.message == "Can't demote chat creator":
                pass
            else:
                message.reply_text("Could not gmute due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gmute due to: {}".format(excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} has been successfully gmuted!".format(
                     mention_html(user_chat.id, user_chat.first_name
                                  or "Deleted Account")),
                 html=True)

    message.reply_text("Person has been gmuted.")
Ejemplo n.º 26
0
def ungmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id = extract_user(message, args)
    if not user_id:
        message.reply_text("Wygląda na to, że nie odnosisz się do futrzaka.")
        return

    user_chat = bot.get_chat(user_id)
    if user_chat.type != 'private':
        message.reply_text("To nie jest futrzak!")
        return

    if not sql.is_user_gmuted(user_id):
        message.reply_text("Ten futrzak nie jest globalnie wyciszony!")
        return

    muter = update.effective_user  # type: Optional[User]

    message.reply_text(
        "Pozwolę tobie ponownie globalnie rozmawiać, {}.".format(
            user_chat.first_name))

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} globalnie odciszył {}".format(
                     mention_html(muter.id, muter.first_name),
                     mention_html(user_chat.id, user_chat.first_name)),
                 html=True)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            member = bot.get_chat_member(chat_id, user_id)
            if member.status == 'restricted':
                bot.restrict_chat_member(chat_id,
                                         int(user_id),
                                         can_send_messages=True,
                                         can_send_media_messages=True,
                                         can_send_other_messages=True,
                                         can_add_web_page_previews=True)

        except BadRequest as excp:
            if excp.message == "Futrzak jest administratorem czatu":
                pass
            elif excp.message == "Nie znaleziono czatu":
                pass
            elif excp.message == "Brak wystarczających uprawnień do ograniczenia/odgraniczenia futrzaka tego czatu":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Metoda jest dostępna tylko dla supergrup oraz kanałów":
                pass
            elif excp.message == "Nie na czacie":
                pass
            elif excp.message == "Channel_private":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            else:
                message.reply_text(
                    "Nie mogę globalnie odciszyć z powodu: {}".format(
                        excp.message))
                bot.send_message(
                    OWNER_ID,
                    "Nie mogę globalnie odciszyć z powodu: {}".format(
                        excp.message))
                return
        except TelegramError:
            pass

    sql.ungmute_user(user_id)

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "pomyślnie globalnie odciszono!")

    message.reply_text("Futrzak został globalnie odciszony.")
Ejemplo n.º 27
0
def ungmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id = extract_user(message, args)
    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    user_chat = bot.get_chat(user_id)
    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if not sql.is_user_gmuted(user_id):
        message.reply_text("This user is not gmuted!")
        return

    muter = update.effective_user  # type: Optional[User]

    message.reply_text("I'll let {} speak again, globally.".format(
        user_chat.first_name))

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} has ungmuted user {}".format(
                     mention_html(muter.id, muter.first_name),
                     mention_html(user_chat.id, user_chat.first_name)),
                 html=True)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            member = bot.get_chat_member(chat_id, user_id)
            if member.status == 'restricted':
                bot.restrict_chat_member(chat_id,
                                         int(user_id),
                                         can_send_messages=True,
                                         can_send_media_messages=True,
                                         can_send_other_messages=True,
                                         can_add_web_page_previews=True)

        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Method is available for supergroup and channel chats only":
                pass
            elif excp.message == "Not in the chat":
                pass
            elif excp.message == "Channel_private":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            else:
                message.reply_text("Could not un-gmute due to: {}".format(
                    excp.message))
                bot.send_message(
                    OWNER_ID,
                    "Could not un-gmute due to: {}".format(excp.message))
                return
        except TelegramError:
            pass

    sql.ungmute_user(user_id)

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "un-gmute complete!")

    message.reply_text("Person has been un-gmuted.")
Ejemplo n.º 28
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Wygląda na to, że nie odnosisz się do futrzaka.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "Będę go śledził moim małym oczkiem... Wojna sudo futrzaków! Dlaczego odwracacie się od siebie nawzajem?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OHO! któś próbuje globalnie wyciszyć futrzaka od supportu! *bierze popcorn*"
        )
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- Bardzo śmieszne... Globalnie wycisz mnie, dlaczego by nie? Niezła próba."
        )
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("To nie jest futrzak!")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text(
                "Ten futrzak jest już globalnie wyciszony. Mogę zmienić powód ale nie podałeś mi żadnego..."
            )
            return

        success = sql.update_gmute_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text(
                "Ten futrzak jest już globalnie wyciszony ale nie ma ustawionego powodu. Ale już to zostało poprawione!"
            )
        else:
            message.reply_text(
                "Czy możesz spróbować ponownie? Myślałem, że ta osoba była globalnie wyciszona, ale tak nie było? "
                "Jestem bardzo zdezorientowany")

        return

    message.reply_text("*bierze taśmę klejącą* 😉")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gmuting user {} "
                 "Ponieważ:\n{}".format(
                     mention_html(muter.id, muter.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "Futrzak jest administratorem czatu":
                pass
            elif excp.message == "Nie znaleziono czatu":
                pass
            elif excp.message == "Brak wystarczających uprawnień do ograniczenia/odgraniczenia futrzaka tego czatu":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Czat grupy został zdeaktywowany":
                pass
            elif excp.message == "Trzeba być zapraszającym futrzaka, aby wyciszyć go na grupie":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            elif excp.message == "Tylko twórca grupy może wyciszać administratorów grupy":
                pass
            elif excp.message == "Metoda jest dostępna tylko dla supergrup oraz kanałów":
                pass
            elif excp.message == "Nie można zdegradować twórcy czatu":
                pass
            else:
                message.reply_text(
                    "Nie mogę globalnie wyciszyć z powodu: {}".format(
                        excp.message))
                send_to_list(
                    bot, SUDO_USERS + SUPPORT_USERS,
                    "Nie mogę globalnie wyciszyć z powodu: {}".format(
                        excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "pomyślnie globalnie wyciszono!")
    message.reply_text("Futrzak został globalnie wyciszony.")
Ejemplo n.º 29
0
def __chat_settings__(chat_id, user_id):
    return "This chat is enforcing *gmutes*: `{}`.".format(
        sql.does_chat_gmute(chat_id))
Ejemplo n.º 30
0
def gmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Gelecek sefer birisini hedef almaya çalış.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Sakin ol adamım, böyle bir şey olmayacak!")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH Birisi destek kullanıcımı gmutelemeye çalışıyor.")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- Çok eğlenceli. Kendimi küresel olarak susturmalıyım, neden olmasın? Güzel deneme."
        )
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("Bu bir kullanıcı değil!")
        return

    if sql.is_user_gmuted(user_id):
        if not reason:
            message.reply_text(
                "Bu kullanıcı zaten gmuteli; Sebebini değiştirebilirdim ama, ama bana sebep vermedin..."
            )
            return

        success = sql.update_gmute_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text(
                "Bu kullanıcı zaten gmuteli. Sebebini gittim ve güncelledim!")
        else:
            message.reply_text(
                "Yeniden düşünmeme izin ver. Bu kullanıcı zaten gmuteliydi. Yoksa değilmiydi? "
                "Kafam karıştı")

        return

    message.reply_text("Kapa çeneni 🤐")

    muter = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Mute</b>" \
                 "\n#GMUTE" \
                 "\n<b>Durum:</b> <code>Etkin</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>Kullanıcı:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Sebep:</b> {}".format(mention_html(muter.id, muter.first_name),
                                              mention_html(user_chat.id, user_chat.first_name),
                                                           user_chat.id, reason or "Sebep belirtmedi"),
                 html=True)

    sql.gmute_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gmutes
        if not sql.does_chat_gmute(chat_id):
            continue

        try:
            bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Group chat was deactivated":
                pass
            elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                pass
            elif excp.message == "Chat_admin_required":
                pass
            elif excp.message == "Only the creator of a basic group can kick group administrators":
                pass
            elif excp.message == "Method is available only for supergroups":
                pass
            elif excp.message == "Can't demote chat creator":
                pass
            else:
                message.reply_text(
                    "Şu sebepten dolayı gmuteleyemedim: {}".format(
                        excp.message))
                send_to_list(
                    bot, SUDO_USERS + SUPPORT_USERS,
                    "Şu sebepten dolayı gmuteleyemedim: {}".format(
                        excp.message))
                sql.ungmute_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} Küresel olarak susturuldu!".format(
                     mention_html(user_chat.id, user_chat.first_name)),
                 html=True)

    message.reply_text("Yakın bir zamanda bir daha konuşamayacaksın.")