Example #1
0
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text("Şimdi, /setlog'u bu kanalı bağlamak istediğiniz gruba iletin!")

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception("Error deleting message in log channel. Should work anyway though.")

            try:
                bot.send_message(message.forward_from_chat.id,
                                 "Bu kanal için günlük kanalı olarak ayarlanmış {}.".format(
                                     chat.title or chat.first_name))
            except Unauthorized as excp:
                if excp.message == "Forbidden: bot is not a member of the channel chat":
                    bot.send_message(chat.id, "Günlük kanalını başarıyla ayarlayın!")
                else:
                    LOGGER.exception("ERROR in setting the log channel.")

            bot.send_message(chat.id, "Günlük kanalı başarıyla ayarlayın!")

        else:
            message.reply_text("Günlük kanalı ayarlamak için adımlar şunlardır:\n"
                               " - istenilen kanala bot ekleyin\n"
                               " - kanala /setlog gönder\n"
                               " - /setlog'u gruba ilet\n")
Example #2
0
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text("Now, forward the /setlog to the group you want to tie this channel to!")

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception("Error deleting message in log channel. Should work anyway though.")

            try:
                bot.send_message(message.forward_from_chat.id,
                                 "This channel has been set as the log channel for {}.".format(
                                     chat.title or chat.first_name))
            except Unauthorized as excp:
                if excp.message == "Forbidden: bot is not a member of the channel chat":
                    bot.send_message(chat.id, "Successfully set log channel!")
                else:
                    LOGGER.exception("ERROR in setting the log channel.")

            bot.send_message(chat.id, "Successfully set log channel!")

        else:
            message.reply_text("The steps to set a log channel are:\n"
                               " - add bot to the desired channel\n"
                               " - send /setlog to the channel\n"
                               " - forward the /setlog to the group\n")
Example #3
0
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text("Now, forward the /setlog to the group you want to tie this channel to!")

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            bot.send_message(message.forward_from_chat.id,
                             "This channel has been set as the log channel for {}.".format(
                                 chat.title or chat.first_name))
            message.delete()
            bot.send_message(chat.id, "Successfully set log channel!")

        else:
            message.reply_text("The steps to set a log channel are:\n"
                               " - add bot to the desired channel\n"
                               " - send /setlog to the channel\n"
                               " - forward the /setlog to the group\n")
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text(
                "Ora, inoltra il /setlog al gruppo che vuoi collegare a questo canale."
            )

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception(
                        "Error deleting message in log channel. Should work anyway though."
                    )

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    "Il log-channel di questo gruppo è impostato a: {}.".
                    format(chat.title or chat.first_name),
                )
            except Unauthorized as excp:
                if excp.message == "Forbidden: bot is not a member of the channel chat":
                    bot.send_message(chat.id,
                                     "log-channel impostato correttamente!")
                else:
                    LOGGER.exception("ERROR in setting the log channel.")

            bot.send_message(chat.id, "log-channel impostato correttamente!")

        else:
            message.reply_text(
                "Segui i seguenti passi per creare il log-channel:\n"
                " - aggiungi il bot al canale di log\n"
                " - invia /setlog nel canale\n"
                " - inoltra /setlog al gruppo che vuoi loggare\n")
    def setlog(bot: Bot, update: Update):

        message = update.effective_message
        chat = update.effective_chat
        if chat.type == chat.CHANNEL:
            message.reply_text(
                "Sekarang, teruskan /setlog ke grup yang ingin Anda kaitkan dengan saluran ini!"
            )

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception(
                        "Error deleting message in log channel. Should work anyway though."
                    )

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    f"Saluran ini telah ditetapkan sebagai saluran log untuk {chat.title or chat.first_name}.",
                )
            except Unauthorized as excp:
                if excp.message == "Forbidden: bot is not a member of the channel chat":
                    bot.send_message(chat.id, "Berhasil menyetel saluran log!")
                else:
                    LOGGER.exception("ERROR in setting the log channel.")

            bot.send_message(chat.id, "Berhasil menyetel saluran log!")

        else:
            message.reply_text(
                "Langkah-langkah untuk mengatur saluran log adalah:\n"
                " - tambahkan bot ke saluran yang diinginkan\n"
                " - kirim /setlog ke saluran\n"
                " - meneruskan /setlog ke grup\n"
            )
Example #6
0
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text(
                "Teraz, prześlij /setlog do grupy którą chcesz podpiąć!")

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception(
                        "Błąd w usuwaniu wiadomości do log channelu. Powinno działać mimo wszystko."
                    )

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    "Ten kanał ma ustawiony log channel dla {}.".format(
                        chat.title or chat.first_name))
            except Unauthorized as excp:
                if excp.message == "Forbidden: Nie jestem członkiem kanału":
                    bot.send_message(chat.id,
                                     "Pomyślnie ustawiono log channel!")
                else:
                    LOGGER.exception("BŁĄD w ustawianiu log channela.")

            bot.send_message(chat.id, "Pomyślnie ustawiono log channel!")

        else:
            message.reply_text(
                "Kroki do ustawienia log channelu są następujące:\n"
                " - dodaj mnie do wybranego kanału\n"
                " - wyślij wiadomość /setlog na kanał\n"
                " - prześlij wiadomość /setlog na grupę\n")
Example #7
0
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text(
                "Şimdi /gunlukekle'yi, bu kanalı bağlamak istediğiniz gruba iletin.!"
            )

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception(
                        "Error deleting message in log channel. Should work anyway though."
                    )

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    "Bu kanal, {} için günlük kanalı olarak ayarlandı.".format(
                        chat.title or chat.first_name))
            except Unauthorized as excp:
                if excp.message == "Forbidden: bot is not a member of the channel chat":
                    bot.send_message(chat.id, "Günlük başarıyla ayarlandı!")
                else:
                    LOGGER.exception("Günlük ayarlarken HATA.")

            bot.send_message(chat.id, "Günlük başarıyla ayarlandı!")

        else:
            message.reply_text(
                "Bir günlük kanalı belirleme adımları şunlardır:\n"
                " - botu istenen kanala yönetici olarak ekleyin\n"
                " - kanala /gunlukekle gönder\n"
                " - gunlukekle'yi gruba ilet\n")
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text(
                "දැන්, ඔබට මෙම නාලිකාව සම්බන්ධ කිරීමට අවශ්‍ය කණ්ඩායමට / setlog යොමු කරන්න!"
            )

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "මැකීමට පණිවිඩය හමු නොවීය":
                    pass
                else:
                    LOGGER.exception(
                        "ලොග් නාලිකාවේ පණිවිඩය මැකීමේ දෝෂයකි. කෙසේ වෙතත් වැඩ කළ යුතුය."
                    )

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    "මෙම නාලිකාව ලොග් නාලිකාව ලෙස සකසා ඇත {}.".format(
                        chat.title or chat.first_name))
            except Unauthorized as excp:
                if excp.message == "තහනම්: බොට් නාලිකා සංවාදයේ සාමාජිකයෙක් නොවේ":
                    bot.send_message(chat.id, "ලොග් නාලිකාව සාර්ථකව සකසන්න!")
                else:
                    LOGGER.exception("ලොග් නාලිකාව සැකසීමේදී දෝෂයකි.")

            bot.send_message(chat.id, "ලොග් නාලිකාව සාර්ථකව සකසන්න!")

        else:
            message.reply_text("ලොග් නාලිකාවක් සැකසීමේ පියවර:\n"
                               " - අපේක්ෂිත නාලිකාවට බොට් එක් කරන්න\n"
                               " - යවන්න /setlog නාලිකාවට\n"
                               " - ඉදිරියට /setlog කණ්ඩායමට\n")
Example #9
0
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text(
                "خب ف لطفا حالا پیام /setlog رو فوروارد کن به گپی که میخوای لینک شه!"
            )

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception(
                        "Error deleting message in log channel. Should work anyway though."
                    )

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    "این کانال تنطیم شده برای اخبار گپ {}.".format(
                        chat.title or chat.first_name))
            except Unauthorized as excp:
                if excp.message == "Forbidden: bot is not a member of the channel chat":
                    bot.send_message(chat.id, "متصل شدیم😎")
                else:
                    LOGGER.exception("ERROR in setting the log channel.")

            bot.send_message(chat.id, "متصل شدیم😎")

        else:
            message.reply_text("مراحل لینک کردن من و کانال:\n"
                               " - منو ادد کن تو چنلت\n"
                               " - دستور /setlog رو داخل چنل بفرس\n"
                               " - پیام /setlog رو فوروارد کن تو گپت\n")
Example #10
0
    def setlog(update: Update, context: CallbackContext):
        bot = context.bot
        message = update.effective_message
        chat = update.effective_chat
        if chat.type == chat.CHANNEL:
            message.reply_text(
                "Now, forward the /setlog to the group you want to tie this channel to!"
            )

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message != 'Message to delete not found':
                    log.exception(
                        'Error deleting message in log channel. Should work anyway though.'
                    )

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    f"This channel has been set as the log channel for {chat.title or chat.first_name}.",
                )
            except Unauthorized as excp:
                if excp.message == "Forbidden: bot is not a member of the channel chat":
                    bot.send_message(chat.id, "Successfully set log channel!")
                else:
                    log.exception("ERROR in setting the log channel.")

            bot.send_message(chat.id, "Successfully set log channel!")

        else:
            message.reply_text("The steps to set a log channel are:\n"
                               " - add bot to the desired channel\n"
                               " - send /setlog to the channel\n"
                               " - forward the /setlog to the group\n")
Example #11
0
    def setlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]
        if chat.type == chat.CHANNEL:
            message.reply_text("이제, 이 채널을 연결할 그룹으로 /setlog 를 전달해주세요!")

        elif message.forward_from_chat:
            sql.set_chat_log_channel(chat.id, message.forward_from_chat.id)
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception(
                        "로그 채널에서 메시지를 삭제하는 동안 오류가 발생했어요. 어쨌든 잘 될 거예요.")

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    "{} 채널이 로그 채널로 설정되었어요.".format(chat.title
                                                   or chat.first_name))
            except Unauthorized as excp:
                if excp.message == "Forbidden: bot is not a member of the channel chat":
                    bot.send_message(chat.id, "로그 채널 설정이 완료되었어요!")
                else:
                    LOGGER.exception("로그 채널을 설정하는 데에 오류가 발생했어요!")

            bot.send_message(chat.id, "로그 채널 설정이 완료되었어요!")

        else:
            message.reply_text(
                "로그 채널 설정하는 방법:\n"
                " - 원하는 채널에 봇을 추가해주세요.\n"
                " - 채널에 /setlog 를 입력해 주세요\n"
                " - 로그 채널을 설정하고자 하는 그룹에 채널에서 적었던 /setlog 를 전달해 주세요.\n")