示例#1
0
def runmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

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

    user_id, chat_id = extract_user_and_text(message, args)

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

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text("Chat not found! Make sure you entered a valid chat ID and I'm part of that chat.")
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("I'm sorry, but that's a private chat!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(bot.id).can_restrict_members:
        message.reply_text("I can't unrestrict people there! Make sure I'm admin and can unban users.")
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("I can't seem to find this user there")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
       if member.can_send_messages and member.can_send_media_messages \
          and member.can_send_other_messages and member.can_add_web_page_previews:
        message.reply_text("This user already has the right to speak in that chat.")
        return

    if user_id == bot.id:
        message.reply_text("I'm not gonna UNMUTE myself, I'm an admin there!")
        return

    try:
        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)
        message.reply_text("Yep, this user can talk in that chat!")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Unmuted!', quote=False)
        elif excp.message in RUNMUTE_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception("ERROR unmnuting user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id,
                             excp.message)
            message.reply_text("Well damn, I can't unmute that user.")
示例#2
0
def runmute(update: Update, context: CallbackContext):
    bot = context.bot
    args = context.args
    message = update.effective_message

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

    user_id, chat_id = extract_user_and_text(message, args)

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

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text(
                "Chat not found! Make sure you entered a valid chat ID and I'm part of that chat."
            )
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("I'm sorry, but that's a private chat!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "I can't unrestrict people there! Make sure I'm admin and can unban users."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("I can't seem to find this user there")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        if member.can_send_messages and member.can_send_media_messages \
           and member.can_send_other_messages and member.can_add_web_page_previews:
            message.reply_text(
                "This user already has the right to speak in that chat.")
            return

    if user_id == bot.id:
        message.reply_text("I'm not gonna UNMUTE myself, I'm an admin there!")
        return

    try:
        bot.restrict_chat_member(chat.id,
                                 int(user_id),
                                 permissions=ChatPermissions(
                                     can_send_messages=True,
                                     can_send_media_messages=True,
                                     can_send_other_messages=True,
                                     can_add_web_page_previews=True))
        runmuting = "Well, I will let {} speak on {}!".format(
            mention_html(member.user.id, member.user.first_name),
            (chat.title or chat.first or chat.username))
        message.reply_text(runmuting, parse_mode=ParseMode.HTML)
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Unmuted!', quote=False)
        elif excp.message in RUNMUTE_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "ERROR unmnuting user %s in chat %s (%s) due to %s", user_id,
                chat.title, chat.id, excp.message)
            message.reply_text("Well damn, I can't unmute that user.")
示例#3
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

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

    user_id, chat_id = extract_user_and_text(message, args)

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

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text(
                "Czat nie znaleziony! Sprawdź czy podałeś poprawny chat ID oraz czy w nim jestem."
            )
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Przepraszam, ale to jest prywatny czat!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "Nie mogę tutaj odograniczać futrzaków! Sprawdź czy mam prawa administratora i czy mogę odbanowywać."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("Nie mogę znaleźć tego futrzaka")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        message.reply_text(
            "Dlaczego próbujesz zdalnie futrzaka który jest już na chacie?")
        return

    if user_id == bot.id:
        message.reply_text(
            "Nie będę ODBANOWYWAŁ siebie, jestem tutaj administratorem!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Yup, ten futrzak może wrócić!")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Odbanowany!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "BŁĄD podczas odbanowania futrzaka %s na chacie %s (%s) z powodu %s",
                user_id, chat.title, chat.id, excp.message)
            message.reply_text("Cholera, nie mogę odbanować tego futrzaka.")
示例#4
0
def runmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

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

    user_id, chat_id = extract_user_and_text(message, args)

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

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text(
                "Czat nie znaleziony! Sprawdź czy podałeś poprawny chat ID oraz czy w nim jestem."
            )
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Przepraszam, ale to jest prywatny czat!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "Nie mogę tutaj odograniczać futrzaków! Sprawdź czy mam prawa administratora i czy mogę odciszać."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("Nie mogę znaleźć tego futrzaka")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        if member.can_send_messages and member.can_send_media_messages \
           and member.can_send_other_messages and member.can_add_web_page_previews:
            message.reply_text(
                "Ten futrzak ma już prawo do mówienia na tym czacie.")
            return

    if user_id == bot.id:
        message.reply_text(
            "Nie będę ODCISZAŁ siebie, jestem tutaj administratorem!")
        return

    try:
        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)
        message.reply_text("Yup, ten futrzak może mówić na tym czacie!")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Odciszony!', quote=False)
        elif excp.message in RUNMUTE_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "BŁĄD podczas odciszania futrzaka %s (%s) przez %s", user_id,
                chat.title, chat.id, excp.message)
            message.reply_text("Cholera, nie mogę odciszyć tego futrzaka.")
示例#5
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text("Bir sohbet / kullanıcıyla ilgili görünmüyorsunuz.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Bir kullanıcıyı kastediyorsunuz.")
        return
    elif not chat_id:
        message.reply_text("Bir sohbete atıfta bulunmuyorsunuz.")
        return

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text(
                "Sohbet bulunamadı! Geçerli bir sohbet kimliği girdiğinizden emin olun ve ben de o sohbetin bir parçasıyım."
            )
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Üzgünüm ama bu özel bir sohbet!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "Oradaki kişilerin kısıtlamasını kaldıramam! Yönetici olduğumdan ve kullanıcıların yasağını kaldırabildiğinden emin olun.."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("Bu kullanıcıyı orada bulamıyorum")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        message.reply_text(
            "Zaten o sohbette olan birinin yasağını neden uzaktan kaldırmaya çalışıyorsunuz?"
        )
        return

    if user_id == bot.id:
        message.reply_text(
            "Ben de YASAKLAMAYI KALDIRMAYACAĞIM , orada bir yöneticiyim!!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Evet, bu kullanıcı o sohbete katılabilir!")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('banını kaldırdım amk!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "ERROR unbanning user %s in chat %s (%s) due to %s", user_id,
                chat.title, chat.id, excp.message)
            message.reply_text(
                "Lanet olsun, bu kullanıcının yasağını kaldıramıyorum.")
示例#6
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text("ඔබ යොමු දක්වන්නේ chat/user.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

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

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text("චැට් හමු නොවීය! ඔබ වලංගු චැට් හැඳුනුම්පතක් ඇතුළත් කළ බවට වග බලා ගන්න, මම එම සංවාදයේ කොටසක් වෙමි.")
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("මට කණගාටුයි, නමුත් එය පෞද්ගලික කතාබහකි!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(bot.id).can_restrict_members:
        message.reply_text("මට එහි මිනිසුන්ව පාලනය කළ නොහැක! මම පරිපාලක බවට වග බලා ගන්න සහ පරිශීලකයින් තහනම් කළ හැකිය.")
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("මට මෙම පරිශීලකයා එහි සිටින බවක් නොපෙනේ")
            return
        else:
            raise
            
    if is_user_in_chat(chat, user_id):
        message.reply_text("එම සංවාදයේ දැනටමත් සිටින අයෙකු දුරස්ථව තහනම් කිරීමට ඔබ උත්සාහ කරන්නේ ඇයි?")
        return

    if user_id == bot.id:
        message.reply_text("මම මාවම තහනම් කරන්න යන්නේ නැහැ, මම එහි පරිපාලකයෙක්!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("ඔව්, මෙම පරිශීලකයාට එම කතාබහට සම්බන්ධ විය හැකිය!")
    except BadRequest as excp:
        if excp.message == "පිළිතුරු පණිවිඩය හමු නොවීය":
            # Do not reply
            message.reply_text('Unbanned!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception("දෝෂය තහනම් කිරීම user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id,
                             excp.message)
            message.reply_text("හොඳයි, මට එම පරිශීලකයා තහනම් කළ නොහැක.")
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text(
            "Görünür, söhbət / istifadəçi haqqında danışmırsınız.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

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

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Çat boşdur":
            message.reply_text(
                "Söhbət tapılmadı! Etibarlı bir söhbət identifikatoru daxil etdiyinizə əmin olun və bu sohbetin bir hissəsiyəm."
            )
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Bağışlayın, amma bu xüsusi söhbətdir!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "Oradakı insanları məhdudlaşdıra bilmərəm! Admin olduğuma və istifadəçiləri ləğv edə biləcəyimə əmin olun."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "İstifadəçi tapılmadı!":
            message.reply_text("Görünür bu istifadəçini orada tapa bilmirəm")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        message.reply_text(
            "Niyə onsuz da bu söhbətdə olan birini uzaqdan açmağa çalışırsınız?"
        )
        return

    if user_id == bot.id:
        message.reply_text("Mən özüm ban etməyəcəyəm, mən orada adminəm!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Yaxşı icazə verdim, qrupa qoşula bilər.")
    except BadRequest as excp:
        if excp.message == "Cavab mesajı tapılmadı":
            # Do not reply
            message.reply_text('Bandan çıxarıldı!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "ERROR %s Səbəbiylə %s (%s) bandan çıxarıla bilmədi %s",
                user_id, chat.title, chat.id, excp.message)
            message.reply_text("Lənət olsun, bandan çıxara bilmədim!")
def runmute(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

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

    user_id, chat_id = extract_user_and_text(message, args)

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

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text("චැට් හමු නොවීය! ඔබ වලංගු චැට් හැඳුනුම්පතක් ඇතුළත් කළ බවට වග බලා ගන්න, මම එම සංවාදයේ කොටසක් වෙමි.")
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("I'm sorry, but that's a private chat!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(bot.id).can_restrict_members:
        message.reply_text("මට එහි මිනිසුන්ව පාලනය කළ නොහැක! මම පරිපාලක බවට වග බලා ගන්න සහ පරිශීලකයින් තහනම් කළ හැකිය.")
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("මට මෙම පරිශීලකයා එහි සිටින බවක් නොපෙනේ")
            return
        else:
            raise
            
    if is_user_in_chat(chat, user_id):
       if member.can_send_messages and member.can_send_media_messages \
          and member.can_send_other_messages and member.can_add_web_page_previews:
        message.reply_text("මෙම කතාබහ තුළ කතා කිරීමට මෙම පරිශීලකයාට දැනටමත් අයිතියක් ඇත.")
        return

    if user_id == bot.id:
        message.reply_text("මම මාවම පාලනය කරන්න යන්නේ නැහැ, මම එහි පරිපාලකයෙක්! ”)
        return

    try:
        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)
        message.reply_text("Yep, this user can talk in that chat!")
    except BadRequest as excp:
        if excp.message == "Rපිළිතුරු පණිවිඩය හමු නොවීය":
            # Do not reply
            message.reply_text('Unmuted!', quote=False)
        elif excp.message in RUNMUTE_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception("දෝෂ ඉවත් කිරීම user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id,
                             excp.message)
            message.reply_text("හොඳයි, මට එම පරිශීලකයා ඉවත් කළ නොහැක.")
示例#9
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text("لا يبدو أنك تشير إلى دردشة / مستخدم.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("لا يبدو أنك تشير إلى مستخدم.")
        return
    elif not chat_id:
        message.reply_text("لا يبدو أنك تشير إلى دردشة.")
        return

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text("لم يتم العثور على الدردشة! تأكد من إدخال معرف دردشة صالح وأنا جزء من الدردشة.")
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("أنا آسف، لكن هذا دردشة خاصة!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(bot.id).can_restrict_members:
        message.reply_text("لا أستطيع أن أجد الناس هناك! تأكد من أنني مشرف ويمكن لمستخدمي شبان.")
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("لا أستطيع أن أجد هذا المستخدم هناك")
            return
        else:
            raise
            
    if is_user_in_chat(chat, user_id):
        message.reply_text("لماذا تحاول إلغاء حظر شخص ما في تلك الدردشة؟")
        return

    if user_id == bot.id:
        message.reply_text("أنا لن أحظر نفسي، أنا مشرف هناك!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("نعم، يمكن لهذا المستخدم الانضمام إلى الدردشة!")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('الغي حظرة!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception("ERROR unbanning user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id,
                             excp.message)
            message.reply_text("حسنا لعنة، لا أستطيع إلغاء الحظر هذا المستخدم.")
示例#10
0
def unban(update: Update, context: CallbackContext) -> Optional[str]:
    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat
    log_message = ""
    bot, args = context.bot, context.args
    if message.reply_to_message and message.reply_to_message.sender_chat:
        r = bot.unban_chat_sender_chat(
            chat_id=chat.id,
            sender_chat_id=message.reply_to_message.sender_chat.id)
        if r:
            message.reply_text(
                "Channel {} was unbanned successfully from {}".format(
                    html.escape(message.reply_to_message.sender_chat.title),
                    html.escape(chat.title)),
                parse_mode="html")
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"#UNBANNED\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"<b>Channel:</b> {html.escape(message.reply_to_message.sender_chat.title)} ({message.reply_to_message.sender_chat.id})"
            )
        else:
            message.reply_text("Failed to unban channel")
        return
    user_id, reason = extract_user_and_text(message, args)
    if not user_id:
        message.reply_text("I doubt that's a user.")
        return log_message

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message != 'User not found':
            raise
        message.reply_text("I can't seem to find this user.")
        return log_message
    if user_id == bot.id:
        message.reply_text("How would I unban myself if I wasn't here...?")
        return log_message

    if is_user_in_chat(chat, user_id):
        message.reply_text("Isn't this person already here??")
        return log_message

    chat.unban_member(user_id)
    bot.sendMessage(
        chat.id,
        "{} was unbanned by {} in <b>{}</b>\n<b>Reason</b>: <code>{}</code>".
        format(mention_html(member.user.id, member.user.first_name),
               mention_html(user.id, user.first_name), message.chat.title,
               reason),
        parse_mode=ParseMode.HTML,
    )

    log = (
        f"<b>{html.escape(chat.title)}:</b>\n"
        f"#UNBANNED\n"
        f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
        f"<b>User:</b> {mention_html(member.user.id, member.user.first_name)}")
    if reason:
        log += f"\n<b>Reason:</b> {reason}"

    return log
示例#11
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text(
            "Görünür mənə bir söhbət və ya istifadəçi vermədin.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Görünür mənə bir istifadəçi vermədin.")
        return
    elif not chat_id:
        message.reply_text("Görünür mənə bir söhbət vermədin.")
        return

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text(
                "Söhbət tapılmadı! Düzgün bir söhbət İD verdiyindən əmin ol və mən də o söhbətdə olmalıyam."
            )
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Təəssüf ki, o bir gizli qrupdur!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "Mən oradakı istifadəçilərlə bağlı tədbir görə bilmərəm! Orada admin olduğumdan əmin ol."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("İstidəçi tapılmadı")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        message.reply_text(
            "Sən niyə onsuzda söhbətdə olan birinin banını silməyə çalışırsan?"
        )
        return

    if user_id == bot.id:
        message.reply_text("Öz banımı necə silə bilərəm? Bu mümkün deyil!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Yep, İstifadəçi artıq qoşula bilər!")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Banı silindi!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "ERROR unbanning user %s in chat %s (%s) due to %s", user_id,
                chat.title, chat.id, excp.message)
            message.reply_text("Hah? Edə bilmirəm.")
示例#12
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text(
            "Görünüşe göre bir sohbetten / kullanıcıdan bahsetmiyorsunuz.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Bir kullanıcıya atıfta bulunmuyorsunuz.")
        return
    elif not chat_id:
        message.reply_text("Görünüşe göre bir sohbetten bahsetmiyorsun.")
        return

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Çet bulunamadı":
            message.reply_text(
                "Sohbet bulunamadı! Geçerli bir sohbet kimliği girdiğinizden emin olun ve ben de o sohbetin bir parçasıyım.🦍"
            )
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Üzgünüm, ama burası özel mesaj!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "Oradaki insanları kısıtlayamam! Yönetici olduğumdan ve kullanıcıların yasağını kaldırabileceğinden emin olun."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "Kullanıcı yko":
            message.reply_text("Bu kullanıcıyı orada bulamıyorum")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        message.reply_text(
            "Zaten o sohbette olan birinin yasağını neden uzaktan kaldırmaya çalışıyorsun?"
        )
        return

    if user_id == bot.id:
        message.reply_text("BUNU KALDIRMAYACAĞIM, orada bir yöneticiyim!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Kullanıcı tekrardan katılabilir!")
    except BadRequest as excp:
        if excp.message == "Yanıtlanan mesaj bulunamadı":
            # Do not reply
            message.reply_text('Yasak kaldırıldı!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "ERROR unbanning user %s in chat %s (%s) due to %s", user_id,
                chat.title, chat.id, excp.message)
            message.reply_text(
                "Lanet olsun, o kullanıcının yasağını kaldıramam.")
示例#13
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text(
            "Görünür söhbət və ya istifadəçi haqqında danışmırsız.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Bir istifadəçini seçməmisiniz.")
        return
    elif not chat_id:
        message.reply_text(
            "Görünür söhbət və ya istifadəçi haqqında danışmırsız..")
        return

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text("Qeyd qrup tapılmadı")
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Qrup gizli olduğu üçün heçnə edə bilmərəm")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "İstifadəçiləri bloklaya bilmirəm. Admin olduğumdan və istifadəçiləri qadağa etmə özəlliyimin açıq olduğuna fikir ver)"
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("Bu istifadəçini tapa bilmirəm there")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        message.reply_text(
            "Bu istifadəçinin onsuzda banı yoxdu. Banı olmayan istifadəçini necə unban edim? )"
        )
        return

    if user_id == bot.id:
        message.reply_text(
            "Bir bunu etmədiyin qalmışd)) Bunu etmiyəcəm çünki ADMİNƏM!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Uraa! Artıq istifadəçi qrupa qatıla bilər")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Unban olundu!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "ERROR unbanning user %s in chat %s (%s) due to %s", user_id,
                chat.title, chat.id, excp.message)
            message.reply_text(
                "Lənət olsun bu istifadəçinin qadağasın qaldıra bilmərəm.")
示例#14
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

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

    user_id, chat_id = extract_user_and_text(message, args)

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

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text("Chat not found! Make sure you entered a valid chat ID and I'm part of that chat.")
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("I'm sorry, but that's a private chat!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(bot.id).can_restrict_members:
        message.reply_text("I can't unrestrict people there! Make sure I'm admin and can unban users.")
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("I can't seem to find this user there")
            return
        else:
            raise
            
    if is_user_in_chat(chat, user_id):
        message.reply_text("Why are you trying to remotely unban someone that's already in that chat?")
        return

    if user_id == bot.id:
        message.reply_text("I'm not gonna UNBAN myself, I'm an admin there!")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Yep, this user can join that chat!")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Unbanned!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception("ERROR unbanning user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id,
                             excp.message)
            message.reply_text("Well damn, I can't unban that user.")
示例#15
0
def runban(update: Update, context: CallbackContext):
    bot, args = context.bot, context.args
    message = update.effective_message

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

    user_id, chat_id = 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 not chat_id:
        message.reply_text("You don't seem to be referring to a chat.")
        return

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text(
                "Chat not found! Make sure you entered a valid chat ID and I'm part of that chat."
            )
            return
        raise

    if chat.type == "private":
        message.reply_text("I'm sorry, but that's a private chat!")
        return

    if (not is_bot_admin(chat, bot.id)
            or not chat.get_member(bot.id).can_restrict_members):
        message.reply_text(
            "I can't unrestrict people there! Make sure I'm admin and can unban users."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("I can't seem to find this user there")
            return
        raise

    if is_user_in_chat(chat, user_id):
        message.reply_text(
            "Why are you trying to remotely unban someone that's already in that chat?"
        )
        return

    if user_id == bot.id:
        message.reply_text("I'm not gonna UNBAN myself, I'm an admin there!")
        return

    try:
        chat.unban_member(user_id)
        runbanning = "I am allowing {} to join {}!".format(
            mention_html(member.user.id, member.user.first_name),
            (chat.title or chat.first or chat.username),
        )
        message.reply_text(runbanning, parse_mode=ParseMode.HTML)
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text("Unbanned!", quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "ERROR unbanning user %s in chat %s (%s) due to %s",
                user_id,
                chat.title,
                chat.id,
                excp.message,
            )
            message.reply_text("Well damn, I can't unban that user.")
示例#16
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text("Try targeting something next time bud.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Try targeting a user next time bud.")
        return
    elif not chat_id:
        message.reply_text("Uhhh, which chat am I supposed to unban them from bud?")
        return

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Chat not found":
            message.reply_text("Either you f****d up typing the chat ID, or I'm not in this group.")
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Sorry fam this is a Christian group, no unbans allowed.")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(bot.id).can_restrict_members:
        message.reply_text("Yea, I can't unban people here tbh.")
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("You sure they're in this group?")
            return
        else:
            raise
            
    if is_user_in_chat(chat, user_id):
        message.reply_text("Uhh, they're already in the group... No need to unban them.")
        return

    if user_id == bot.id:
        message.reply_text("BOI! Das me ;_;")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Fine, I'll allow it this time...")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Unrekt!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception("ERROR unbanning user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id,
                             excp.message)
            message.reply_text("Well fugg, I can't unban them.")
示例#17
0
def runban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if not args:
        message.reply_text("Bir sohbete veya kişiye atıfta bulunmuyorsun.")
        return

    user_id, chat_id = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Bir kişiye atıfta bulunmuyorsun.")
        return
    elif not chat_id:
        message.reply_text("Bir sohbete atıfta bulunmuyorsun.")
        return

    try:
        chat = bot.get_chat(chat_id.split()[0])
    except BadRequest as excp:
        if excp.message == "Sohbet Bulunamadı":
            message.reply_text(
                "Sohbet bulunamadı! Geçerli bir sohbet kimliği girdiğinizden ve bu sohbetin bir parçası olduğumdan emin olun."
            )
            return
        else:
            raise

    if chat.type == 'private':
        message.reply_text("Üzgünüm, ama bu özel bir sohbet!")
        return

    if not is_bot_admin(chat, bot.id) or not chat.get_member(
            bot.id).can_restrict_members:
        message.reply_text(
            "Oradaki insanları sınırlayamıyorum! Yönetici olduğumdan ve kullanıcıların yasaklayabildiğimden emin olun."
        )
        return

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("Bu kullanıcıyı orada bulamıyorum")
            return
        else:
            raise

    if is_user_in_chat(chat, user_id):
        message.reply_text(
            "Neden o sohbette olan birinin uzaktan yasağını kaldırmaya çalışıyorsun?"
        )
        return

    if user_id == bot.id:
        message.reply_text("Hayır")
        return

    try:
        chat.unban_member(user_id)
        message.reply_text("Tamamdır. Tekrar teşrif edebilirler")
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text('Unbanned!', quote=False)
        elif excp.message in RUNBAN_ERRORS:
            message.reply_text(excp.message)
        else:
            LOGGER.warning(update)
            LOGGER.exception(
                "ERROR unbanning user %s in chat %s (%s) due to %s", user_id,
                chat.title, chat.id, excp.message)
            message.reply_text("Kahretsin, bu kullanıcıyı yasaklayamam.")