Пример #1
0
    def setlog(bot: Bot, update: Update):

        message = update.effective_message
        chat = update.effective_chat
        if chat.type == chat.CHANNEL:
            message.reply_text("Şimdi /setlog dosyasını bu kanalı bağlamak istediğiniz gruba yönlendirin!")

        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 == "Silinecek mesaj bulunamadı":
                    pass
                else:
                    LOGGER.exception("Günlük kanalındaki mesaj silinirken hata oluştu. Yine de çalışmalı.")

            try:
                bot.send_message(message.forward_from_chat.id,
                                 f"Bu kanal, için günlük kanalı olarak ayarlandı {chat.title or chat.first_name}.")
            except Unauthorized as excp:
                if excp.message == "Yasak: bot kanal sohbetinin bir üyesi değil":
                    bot.send_message(chat.id, "Günlük kanalı başarıyla ayarlandı!")
                else:
                    LOGGER.exception("Günlük kanalının ayarlanmasında HATA.")

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

        else:
            message.reply_text("Bir günlük kanalı ayarlama adımları:\n"
                               " - botu istediğiniz kanala ekleyin\n"
                               " - kanala gönder /setlog ayarla\n"
                               " - /setlog dosyasını gruba iletme\n")
Пример #2
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":
                    pass
                else:
                    LOGGER.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:
                    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"
            )
Пример #3
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(
                "İndi /setlog bu kanalı bağlamaq istədiyiniz qrupa yönəldin!")

        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 == "Silmək üçün mesaj tapılmadı":
                    pass
                else:
                    LOGGER.exception(
                        "Giriş kanalındakı mesaj silinərkən xəta baş verdi. Hər halda işləmədi."
                    )

            try:
                bot.send_message(
                    message.forward_from_chat.id,
                    f"Bu kanal üçün giriş kanalı olaraq təyin edilmişdir {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, "Giriş kanalı uğurla quruldu!")
                else:
                    LOGGER.exception("Giriş kanalını qurarkən XETA.")

            bot.send_message(chat.id, "Giriş kanalı uğurla quruldu!")

        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")