Пример #1
0
def userid(update, context):
    try:
        idu = update.message.from_user.id
        nicku = update.message.from_user.username
        subject = (nicku or str(idu))
        if update.message.reply_to_message:
            ida = update.message.reply_to_message.from_user.id
            nicka = update.message.reply_to_message.from_user.username
            namea = update.message.reply_to_message.from_user.first_name
            addressee = (nicka or namea)
            msgida = update.message.reply_to_message.message_id
            chatid = update.message.chat.id
            context.bot.send_message(chat_id=chatid,
                                     reply_to_message_id=msgida,
                                     text="Nematrice di %s: \n`%s`" %
                                     (addressee, str(ida)),
                                     parse_mode="markdown")
            log.a("%s ha scoperto che la nm. di %s è %s" %
                  (subject, addressee, str(ida)))
        else:
            update.message.reply_text(
                "Devi rispondere a un messaggio per usare questo comando. ",
                parse_mode="markdown",
                quote=True)
            log.a(
                "%s ha scoperto che deve rispondere a un messaggio per usare /userid"
                % subject)
    except Exception as err:
        log.e(err)
Пример #2
0
def helpall(update, context):
    try:
        idu = update.message.from_user.id
        nicku = update.message.from_user.username
        subject = (nicku or str(idu))
        tryinlinekey = [[
            InlineKeyboardButton(text="Prova la modalità inline!",
                                 switch_inline_query_current_chat="")
        ]]
        helpkeyboard = InlineKeyboardMarkup(tryinlinekey)
        update.message.reply_text(
            "<b>Comandi</b> "
            "\n/start - <i>Mi avvio</i> "
            "\n/help - <i>Invio questa lista</i> "
            "\n/info - <i>Invio varie informazioni sul bot</i> "
            "\n/userid - <i>Se utilizzato rispondendo al messaggio di un utente, mostro la sua nematrice</i> "
            "\n/groupid - <i>Se utilizzato in un gruppo, mostra la nematrice del gruppo</i> "
            "\n/envdht* - <i>Rilevo la temperatura e l'umidità della mia camera da letto</i> "
            "\n<s>/distance* - <i>Elaboro la distanza tra il sensore HC-SR04 e un oggetto qualsiasi</i></s> "
            "\n"
            "\n<b>Trigger</b> "
            "\n<code>I'm Piccione</code> - <i>Risponderò con un meme o con una canzone</i> "
            "\n<code>I f**k your padre</code> - <i>Continuero la citazione di @PadriFibra</i> "
            "\n<code>Kosovo</code> - <i>Risponderò con una canzone, una volta ogni tanto nei gruppi</i> "
            "\n<code>Senate</code> - <i>Se mi va, reclamerò la mia autorità</i> "
            "\n<code>Buonsalve</code> - <i>Ti ricambio il saluto o lo riporto ad altri</i> "
            "\n<code>Bot Pigeon, attivazione</code> - <i>Reagirò con un segnale di avvio</i> "
            "\n"
            "\nI comandi seguiti dall'asterisco sono disponibili solo ai Vassalli (utenti autorizzati da Lord Pigeon). ",
            parse_mode="HTML",
            reply_markup=helpkeyboard,
            quote=True)
        log.a("%s ha usato /help" % subject)
    except Exception as err:
        log.e(err)
Пример #3
0
def helpcom(update, context):
    try:
        typechat = update.message.chat.type
        if typechat == "private":
            helpall(update, context)
        else:
            idu = update.message.from_user.id
            nicku = update.message.from_user.username
            subject = (nicku or str(idu))
            titlechat = update.message.chat.title
            clickhelpkey = [[
                InlineKeyboardButton(
                    text="Clicca qui!",
                    url=f"https://telegram.me/{context.bot.username}?start=help"
                )
            ]]
            helpgroupkeyboard = InlineKeyboardMarkup(clickhelpkey)
            update.message.reply_text(
                "Avviami in chat privata per leggere le istruzioni.",
                parse_mode="markdown",
                reply_markup=helpgroupkeyboard,
                quote=True)
            log.a("%s ha usato /help in %s" % (subject, titlechat))
    except Exception as err:
        log.e(err)
Пример #4
0
def inlinelog(update, context):
    try:
        idu = update.chosen_inline_result.from_user.id
        nicku = update.chosen_inline_result.from_user.username
        subject = (nicku or str(idu))
        query = update.chosen_inline_result.query
        loot = update.chosen_inline_result.result_id
        if not query:
            quest = str("")
        else:
            quest = str(": " + str(query))
        journal = str(str(loot) + quest)
        log.a("%s ha scelto inline %s" % (subject, journal))
    except Exception as err:
        log.e(err)
Пример #5
0
def debase(update, context):
    try:
        idu = update.message.from_user.id
        nicku = update.message.from_user.username
        subject = (nicku or str(idu))
        lords = (dm.dataread("config"))["lords"]
        if idu not in lords:
            update.message.reply_text("Non sei autorizzato.", quote=True)
        elif len(context.args) == 0:
            if update.message.reply_to_message:
                ida = update.message.reply_to_message.from_user.id
                nicka = update.message.reply_to_message.from_user.username
                namea = update.message.reply_to_message.from_user.first_name
                addressee = (nicka or namea)
                msgida = update.message.reply_to_message.message_id
                chatid = update.message.chat.id
                vassals = (dm.dataread("vassals"))["vassals"]
                vassals = list(dict.fromkeys(vassals))
                vassals.remove(ida)
                vassals = list(dict.fromkeys(vassals))
                newdb = {"vassals": vassals}
                dm.datawrite("vassals", newdb)
                context.bot.send_message(
                    chat_id=chatid,
                    reply_to_message_id=msgida,
                    text="%s adesso non è più un Vassallo." % addressee,
                    parse_mode="markdown")
                log.a("%s ha degradato %s, nm.: %s" %
                      (subject, addressee, str(ida)))
            else:
                update.message.reply_text("Devi rispondere a un messaggio.",
                                          quote=True)
        else:
            listids = [int(i) for i in context.args]
            vassals = (dm.dataread("vassals"))["vassals"]
            vassals = list(dict.fromkeys(vassals))
            for ids in listids:
                vassals.remove(ids)
            vassals = list(dict.fromkeys(vassals))
            newdb = {"vassals": vassals}
            dm.datawrite("vassals", newdb)
            update.message.reply_text(
                "L'utente nm. %s ora non fa più parte dei Vassalli." %
                str(context.args),
                quote=True)
            log.a("%s ha degradato %s" % (subject, str(context.args)))
    except Exception as err:
        log.e(err)
Пример #6
0
def start(update, context):
    try:
        if len(context.args) == 0:
            idu = update.message.from_user.id
            nicku = update.message.from_user.username
            subject = (nicku or str(idu))
            nameu = update.message.from_user.first_name
            update.message.reply_text(
                "Ciao, %s, io sono il bot personale di @LordPigeon! \nDigita /help per una guida."
                % (nicku or nameu),
                parse_mode="markdown",
                quote=True)
            log.a("%s ha usato /start" % subject)
        elif "help" in context.args:
            helpall(update, context)
        elif "helpinline" in context.args:
            helpinline(update, context)
        elif "info" in context.args:
            info(update, context)
    except Exception as err:
        log.e(err)
Пример #7
0
def groupid(update, context):
    try:
        idu = update.message.from_user.id
        nicku = update.message.from_user.username
        subject = (nicku or str(idu))
        chatid = update.message.chat.id
        typechat = update.message.chat.type
        if typechat == "group":
            titlechat = update.message.chat.title
            update.message.reply_text("La nematrice del gruppo è: \n`%s`" %
                                      str(chatid),
                                      parse_mode="markdown",
                                      quote=True)
            log.a("%s ha scoperto che la nematrice del gruppo \"%s\" è: %s" %
                  (subject, titlechat, str(chatid)))
        elif typechat == "supergroup":
            titlechat = update.message.chat.title
            update.message.reply_text(
                "La nematrice del supergruppo è: \n`%s`" % str(chatid),
                parse_mode="markdown",
                quote=True)
            log.a(
                "%s ha scoperto che la nematrice del supergruppo \"%s\" è: %s"
                % (subject, titlechat, str(chatid)))
        else:
            update.message.reply_text(
                "Devi essere in un gruppo per usare questo comando. ",
                parse_mode="markdown",
                quote=True)
            log.a(
                "%s ha scoperto che dev'essere in un gruppo per usare /groupid"
                % subject)
    except Exception as err:
        log.e(err)
Пример #8
0
def info(update, context):
    try:
        idu = update.message.from_user.id
        nicku = update.message.from_user.username
        subject = (nicku or str(idu))
        typechat = update.message.chat.type
        if typechat == "private":
            update.message.reply_text(
                "Io sono il bot personale di @LordPigeon e "
                "sono stato programmato in Python grazie all'aiuto di vari amici: "
                "\n• @Kaikyu "
                "\n• @canebrutto "
                "\n• @i7_8700k "
                "\n• @hugihadein \n"
                '\nFunziono su di un Raspberry Pi 3 Model B grazie a <a href="https://python-telegram-bot.org/">python-telegram-bot</a> e '
                'a <a href="https://github.com/KaikyuLotus/kitsu-maker-bot/blob/master/Utils/Logger.py">un logger di Kaikyu</a>. ',
                parse_mode="HTML",
                disable_web_page_preview=True,
                quote=True)
            log.a("%s ha usato /info" % subject)
        else:
            titlechat = update.message.chat.title
            clickinfokey = [[
                InlineKeyboardButton(
                    text="Clicca qui!",
                    url=f"https://telegram.me/{context.bot.username}?start=info"
                )
            ]]
            infogroupkeyboard = InlineKeyboardMarkup(clickinfokey)
            update.message.reply_text(
                "Avviami in chat privata per leggere più informazioni su di me.",
                parse_mode="markdown",
                reply_markup=infogroupkeyboard,
                quote=True)
            log.a("%s ha usato /info in %s" % (subject, titlechat))
    except Exception as err:
        log.e(err)
Пример #9
0
def helpinline(update, context):
    try:
        idu = update.message.from_user.id
        nicku = update.message.from_user.username
        subject = (nicku or str(idu))
        trymekey = [[
            InlineKeyboardButton(text="Provami!", switch_inline_query="")
        ]]
        helpinlinekeyboard = InlineKeyboardMarkup(trymekey)
        update.message.reply_text(
            "*Lista delle funzioni inline*: "
            "\n1) `You know the rules and so do I` - _Per un triste addio a un picciotto disobbediente._ "
            "\n2) `Meteo` - _Scrivi il nome di una località e clicca per vederne le previsioni metereologiche._ "
            "\n3) `Formatta in HTMl` - _Scrivi un testo con tag HTML che siano compatibili con Telegram per vedere il risultato._ "
            "\n4) `Formatta in maiuscolo` - _Utile se vuoi ottenere rapidamente lettere accentate maiuscole da PC._ "
            "\n5) `Tripcode` - _Scrivi un messaggio e alla fine inserisci una #password (che inizi con l'hashtag) e il bot cripterà la tua password, utile nei gruppi anonimi._ "
            "\n"
            "\nEvita di usare il cancelletto (#) alla fine se vuoi usare le prime quattro funzioni.",
            parse_mode="markdown",
            reply_markup=helpinlinekeyboard,
            quote=True)
        log.a("%s ha usato /start helpinline" % subject)
    except Exception as err:
        log.e(err)
Пример #10
0
def triggers(update, context):
    try:
        idu = update.message.from_user.id
        nicku = update.message.from_user.username
        subject = (nicku or str(idu))
        nameu = update.message.from_user.first_name
        chatid = update.message.chat.id
        content = update.message.text
        cont = content.lower()
        gasha = [0, 0, 0, "pon"]
        
        if content == "Salve" and idu == 254166588:
            update.message.reply_text("e sane")
            log.a("Per Matteo Socrati le ragazze sono salve, ma per me sono pure sane")
            return
        
        if "Prova" in content and random.choice(gasha) == "pon":
            update.message.reply_text("Funziona!", quote = True)
            log.a("%s ha provato!"%subject)
            return
        
        regex = "i'+m p+i+c+c+i+o+n+e"
        if re.search(regex, cont):
            try:
                impiccione = dm.dataread("media")["Triggers"]["Impiccione"]
                meridiana = dm.dataread("media")["Triggers"]["Sonounpiccione"]
                ambiguity = [0, "0"]
                if random.choice(ambiguity) == 0:
                    update.message.reply_photo(photo = impiccione,
                        quote = True)
                    log.a("%s è un imPiccione"%subject)
                    return
                else:
                    update.message.reply_audio(audio = meridiana,
                        quote = True)
                    log.a("%s è un Piccione"%subject)
                    return
            except Exception as err:
                log.e(err)
        
        regex = "i f+u+c+k y+o+u+r p+a+d+r+e"
        if re.search(regex, cont):
            try:
                if update.message.reply_to_message:
                    ida = update.message.reply_to_message.from_user.id
                    nicka = update.message.reply_to_message.from_user.username
                    addressee = (nicka or str(ida))
                    msgida = update.message.reply_to_message.message_id
                    chatid = update.message.chat.id
                    context.bot.send_message(chat_id = chatid,
                        reply_to_message_id = msgida,
                        text = "He's my puttana ",
                        parse_mode = "markdown")
                    log.a("%s si fa il padre di %s"%(subject, addressee))
                    return
                else:
                    update.message.reply_text("He's my puttana ",
                        parse_mode = "markdown",
                        quote = True)
                    log.a("%s segue PadriFibra"%subject)
                    return
            except Exception as err:
                log.e(err)
        
        regex = "k+o+s+o+v+o"
        if re.search(regex, cont):
            try:
                typechat = update.message.chat.type
                kosovo = dm.dataread("media")["Triggers"]["Kosovo"]
                if typechat == "private":
                    update.message.reply_voice(kosovo,
                        caption = "Stay tuned, @PadriFibra!",
                        quote = True)
                    log.a("%s ha lodato il Kosovo"%subject)
                    return
                else:
                    if random.choice(gasha) == 0:
                        titlechat = update.message.chat.title
                        log.a("%s non ha lodato abbastanza il Kosovo in %s"%(subject, titlechat))
                    elif random.choice(gasha) == "pon":
                        update.message.reply_voice(kosovo,
                            caption = "Stay tuned, @PadriFibra!",
                            quote = True)
                        log.a("%s ha lodato il Kosovo"%subject)
                    return
            except Exception as err:
                log.e(err)
        
        regex = "s+e+n+a+t+e"
        if re.search(regex, cont):
            try:
                if random.choice(gasha) == "pon":
                    senate = dm.dataread("media")["Triggers"]["Senate"]
                    update.message.reply_voice(senate,
                        caption = '<i>I am the <a href="https://t.me/ErarioPiccioni">Senate</a>!</i>',
                        parse_mode = "HTML",
                        quote = True)
                    log.a("I am the Senate, not %s"%subject)
                    return
                else:
                    return
            except Exception as err:
                log.e(err)
        
        regex = "b+u+o+n+s+a+l+v+e"
        if re.search(regex, cont):
            try:
                if update.message.reply_to_message:
                    ida = update.message.reply_to_message.from_user.id
                    nicka = update.message.reply_to_message.from_user.username
                    addressee = (nicka or (str(ida)))
                    chatid = update.message.chat.id
                    msgida = update.message.reply_to_message.message_id
                    namea = update.message.reply_to_message.from_user.first_name
                    context.bot.sendMessage(text = "Buonsalve, %s"%(nicka or namea),
                        chat_id = chatid,
                        reply_to_message_id = msgida,
                        quote = True)
                    log.a("%s ha salutato %s"%(subject, addressee))
                    return
                else:
                    update.message.reply_text("Buonsalve, %s!"%(nicku or nameu),
                        quote = True)
                    log.a("Ho ricambiato il saluto a %s"%subject)
                    return
            except Exception as err:
                log.e(err)
        
        regex = "b+o+t p+i+g+e+o+n, a+t+t+i+v+a+z+i+o+n+e"
        if re.search(regex, cont):
            try:
                update.message.reply_text("Bot Pigeon, attivato!",
                    quote = True)
                log.a("%s ha attivato il bot!"%subject)
                return
            except Exception as err:
                log.e(err)
        
    except Exception as err:
        log.e(err)