Exemple #1
0
def init(update,context):
    bot = context.bot
    connector = Connection()
    usr = str(update.message.reply_to_message.from_user.id)
    chat = str(update.message.chat_id)
    default_count = '1'
    msg_usr = update.message.reply_to_message.from_user
    usr_format = "@"+msg_usr.username or msg_usr.first_name
    query = Sql_Warn.SQL_Sel_Warn
    connector.cur.execute(query,(usr,chat))
    row = connector.cur.fetchone()

    if row is None:
        save_warn = Connection()
        insert_warn = Sql_Warn.SQL_Ins_Warn
        save_warn.cur.execute(insert_warn,(usr,default_count,chat))
        bot.send_message(update.message.chat_id,str_service.WARN_START
        .format(usr_format))
        return True
    elif row[0] == MIN_WARN:
        Connection().cur.execute(Sql_Warn.SQL_Upd_Warn,(usr,chat))
        bot.send_message(update.message.chat_id,str_service.WARN_1
        .format(usr_format))
    elif row[0] == '2':
        Connection().cur.execute(Sql_Warn.SQL_Upd_Warn,(usr,chat))
        bot.send_message(update.message.chat_id,str_service.WARN_2
        .format(usr_format))
    elif row[0] == MAX_WARN:
        bot.send_message(update.message.chat_id,str_service.WARN_END
        .format(usr_format))
        bot.kick_chat_member(update.message.chat_id,update.message.reply_to_message.from_user.id)
Exemple #2
0
def init(update, context):
    try:
        bot = context.bot
        dbsel = Connection()
        chat = update.effective_chat.id
        usr = str(update.message.reply_to_message.from_user.id)
        msg_usr = update.message.reply_to_message.from_user
        usr_format = "@" + msg_usr.username or msg_usr.first_name
        usr_control = str(update.effective_user.id)
        query = Sql_reputation.SQL_Select
        dbsel.cur.execute(query, (usr, chat))
        rows = dbsel.cur.fetchall()
        if rows:
            for score in rows:
                if score[1] == usr_control.id:
                    bot.send_message(chat,
                                     "Non puoi toglierti il voto da solo!")
                elif score[1] != usr_control.id:
                    dbup = Connection()
                    sql = Sql_reputation.SQL_Update2
                    dbup.cur.execute(sql, (usr, chat))
                    message = '<a href="tg://user?id={userid}">{user}</a> ha rimossso il voto a {usr_vote} !'.format(
                        userid=usr_control.id,
                        user=update.effective_user.username
                        or update.effective_user.first_name,
                        usr_vote=usr_format)
                    bot.send_message(chat, message, parse_mode='HTML')
        else:
            bot.send_message(chat, "L'utente non è abilitato alle votazioni!")
    except:
        bot.send_message(
            chat, "Questo comando si utilizza in risposta ad un utente!")
Exemple #3
0
def init(update, context):
    bot = context.bot
    chat = update.effective_chat.id
    chat_title = update.message.chat.title
    for member in update.message.new_chat_members:
        if not member.is_bot:
            if member.username is not None:
                connector = Connection()
                usr_connector = Connection()
                u_id = str(member.id)
                u_username = str("@" + member.username)
                query = Sql_Welcome.SQL
                save_user = Sql_SaveUser.SQL
                connector.cur.execute(query, [chat])
                usr_connector.cur.execute(save_user, [u_id, u_username])
                row = connector.cur.fetchone()
                if row is not None:
                    parsed_message = row[0].replace(
                        '{first_name}',
                        update.message.from_user.first_name).replace(
                            '{chat_name}', update.message.chat.title).replace(
                                '{username}', "@" + member.username)
                    connector = Connection()
                    db_query = Sql_Buttons.SQL_1
                    connector.cur.execute(db_query, [chat])
                    rows = connector.cur.fetchall()
                    buttons = []
                    for link in rows:
                        buttons.append(
                            InlineKeyboardButton(text=link[1], url=link[2]))
                    menu = utils.build_menu(buttons, 2)
                    welcome_message = "{}".format(parsed_message)
                    update.message.reply_text(
                        welcome_message,
                        reply_markup=InlineKeyboardMarkup(menu),
                        parse_mode='HTML')
                else:
                    bot.send_message(
                        chat,
                        str_service.DEFAULT_WELCOME.format(username="******" +
                                                           member.username,
                                                           chat=chat_title))

            else:
                bot.send_message(
                    chat,
                    "{} set a username!\n You were kicked for safety!".format(
                        update.message.from_user.id))
                bot.kick_chat_member(chat,
                                     update.message.from_user.id,
                                     until_date=int(time.time() + 30))
        else:
            bot.send_message(chat, str_service.BOT_WELCOME.format(chat_title))
Exemple #4
0
def init(update, context):
    bot = context.bot
    u_id = str(update.message.from_user.id)
    connector = Connection()
    query = Sql_GDPR.SQL
    connector.cur.execute(query, [u_id])
    bot.send_message(update.message.chat_id,
                     text="You have been deleted from our database")
def init(update, context):
    message = update.message.text[8:].strip()
    connector = Connection()
    chatid = str(update.message.chat_id)
    query = Sql_Insert_BW.SQL
    connector.cur.execute(query, [message, chatid])
    connector.db.commit()
    connector.cur.close()
    connector.db.close()
Exemple #6
0
def receive_id(update, context):
    chatid = str(update.message.chat_id)
    connector = Connection()
    ids = update.effective_message.text.split(", ")
    for actual_id in ids:
         query = Sql_Buttons.SQL_2
         connector.cur.execute(query,[actual_id,chatid])
    update.effective_message.reply_text("Ho cancellato i bottoni!")
    return -1
Exemple #7
0
def init(update, context):
    bot = context.bot
    connector = Connection()
    query = Sql_Help.SQL
    connector.cur.execute(query)
    row = connector.cur.fetchone()
    help_message = "{}\n\nRelease info: {source}".format(row[0],
                                                         source=Config.SOURCE)
    bot.send_message(update.message.chat_id, help_message, parse_mode='HTML')
Exemple #8
0
def init(update, context):
    bot = context.bot
    dbsel = Connection()
    chat = update.effective_chat.id
    usr = str(update.message.reply_to_message.from_user.id)
    msg_usr = update.message.reply_to_message.from_user
    usr_format = "@"+msg_usr.username or msg_usr.first_name
    query = Sql_reputation.SQL_Select
    dbsel.cur.execute(query,(usr,chat))
    row = dbsel.cur.fetchone()
    if row is None:
        dbins = Connection()
        default_rep = '0'
        sql = Sql_reputation.SQL_Insert
        dbins.cur.execute(sql,(usr,chat,default_rep))
        message = "{} Ora sei abilitato alle votazioni !".format(usr_format)
        bot.send_message(chat,message,parse_mode='HTML')
    else:
        bot.send_message(chat, "Questo utente è già abilitato alle votazioni!")
Exemple #9
0
def init(update, context):
    bot = context.bot
    for member in update.message.new_chat_members:
        if member.username is not None:
            connector = Connection()
            chatid = str(update.message.chat_id)
            query = Sql_Welcome.SQL
            connector.cur.execute(query, [chatid])
            row = connector.cur.fetchone()
            if row is not None:
                parsed_message = row[0].replace(
                    '{first_name}',
                    update.message.from_user.first_name).replace(
                        '{chat_name}', update.message.chat.title).replace(
                            '{username}', "@" + member.username)
                connector = Connection()
                db_query = Sql_Buttons.SQL_1
                connector.cur.execute(db_query, [chatid])
                rows = connector.cur.fetchall()
                buttons = []
                for link in rows:
                    buttons.append(
                        InlineKeyboardButton(text=link[1], url=link[2]))
                menu = utils.build_menu(buttons, 2)
                welcome_message = "{}".format(parsed_message)
                update.message.reply_text(
                    welcome_message,
                    reply_markup=InlineKeyboardMarkup(menu),
                    parse_mode='HTML')
            else:
                bot.send_message(
                    update.message.chat_id,
                    str_service.DEFAULT_WELCOME.format(
                        username="******" + member.username,
                        chat=update.message.chat.title))

        else:
            bot.send_message(
                update.message.chat_id,
                "{} imposta un username!\nSei stato kickato per sicurezza!".
                format(update.message.from_user.id))
            bot.kick_chat_member(update.message.chat_id,
                                 update.message.from_user.id)
Exemple #10
0
def init(update, context):
    bot = context.bot
    connector = Connection()
    query = Sql_Joke.SQL
    connector.cur.execute(query)
    row = connector.cur.fetchone()
    if row is not None:
        bot.send_message(update.message.chat_id, text=row[1], parse_mode='HTML')
        row = connector.cur.fetchone()
        connector.cur.close()
        connector.db.close()
Exemple #11
0
def init(update, context):
  bot = context.bot
  chatid = str(update.message.chat_id)
  connector = Connection()
  query = "SELECT language_set FROM language WHERE id_group = %s"
  connector.cur.execute(query,[chatid])
  row = connector.cur.fetchone()
  print(row[0])
  if row[0] == "IT":
    bot.send_message(update.message.chat_id, text= "ITALIANO")
  if row[0] == "EN":
    bot.send_message(update.message.chat_id, text="ENGLISH")
Exemple #12
0
def init(update, context):
    connector = Connection()
    chatid = str(update.message.chat_id)
    query = Sql_Badword_Select.SQL
    connector.cur.execute(query, [chatid])
    rows = connector.cur.fetchall()
    string = ""
    for link in rows:
        string += f"<code>{link[0]}:</code> <a href=\"{link[2]}\">{link[1]}</a>\n"
    message = "Ecco la lista delle parole proibite per questo gruppo:"
    update.effective_message.reply_html(message + "\n\nLista badwords:\n" +
                                        string)
Exemple #13
0
def init(update, context):
    connector = Connection()
    chatid = str(update.effective_chat.id)
    usr = str(update.effective_user.id)
    sql = Sql_reputation.SQL_Select
    connector.cur.execute(sql,(usr,chatid))
    row = connector.cur.fetchone()
    if row is not None:
        message = "{} il tuo <b>punteggio</b> nella chat {} è di <code>{}</code> punti!".format(update.effective_user.first_name,update.message.chat.title,row[3])
        update.effective_message.reply_html(message)
    else:
        update.effective_message.reply_html("Non sei abilitato al voto!\nContatta un admin per l'abilitazione!")
def init(update, context):
    bot = context.bot
    chatid = str(update.message.chat_id)
    button_text = update.message.text[4:].strip()
    if button_text != "":
        x = button_text.split(',')
        connector = Connection()
        query = Sql_Add_Buttons.SQL
        connector.cur.execute(query,[x[0],x[1],chatid])
        bot.send_message(update.message.chat_id,"Hai aggiunto un bottone al menu Welcome!")
    else:
        bot.send_message(update.message.chat_id,str_service.BUTTONS_INSERT,parse_mode='HTML')
Exemple #15
0
def init(update, context):
    bot = context.bot
    chatid = str(update.message.chat_id)
    connector = Connection()
    query = Sql_Pin.SQL
    connector.cur.execute(query,[chatid])
    row = connector.cur.fetchone()
    message_text = "{}".format(row[0])
    bot.send_message(update.message.chat_id, text=message_text, parse_mode='HTML')
    bot.pin_chat_message(update.message.chat_id, update.message.message_id+1,
        disable_notification=True)
    connector.cur.close()
    connector.db.close()
Exemple #16
0
def init(update, context):
    connector = Connection()
    chatid = str(update.message.chat_id)
    query = Sql_Welcome.SQL
    connector.cur.execute(query, [chatid])
    row = connector.cur.fetchone()
    if row is not None:
        message = "<b>Ecco il welcome del tuo gruppo:</b>\n<code>{}</code>".format(
            row[0])
        update.effective_message.reply_html(message)
    else:
        update.effective_message.reply_html(
            "Non hai impostato nessun Welcome per questo gruppo!")
Exemple #17
0
def init(update, context):
    chatid = str(update.message.chat_id)
    connector = Connection()
    query = Sql_Buttons.SQL_1
    connector.cur.execute(query,[chatid])
    rows = connector.cur.fetchall()
    string = ""
    for link in rows:
        string += f"<code>{link[0]}:</code> <a href=\"{link[2]}\">{link[1]}</a>\n"
    message = "Ok, rispondi a questo messaggio con gli ID per i link(pulsanti) che vuoi eliminare. Nel formato " \
              "<code>0,1,2</code>. Non scrivere nient'altro nel messaggio. Oppure usa /cancel"
    update.effective_message.reply_html(message + "\n\nLista bottoni:\n" + string)
    return RECEIVE_ID
Exemple #18
0
def init(update, context):
    bot = context.bot
    connector = Connection()
    usr = str(update.message.reply_to_message.from_user.id)
    chat = str(update.message.chat_id)
    msg_usr = update.message.reply_to_message.from_user
    usr_format = "@" + msg_usr.username or msg_usr.first_name
    query = Sql_Warn.SQL_Del_Warn
    connector.cur.execute(query, (usr, chat))
    bot.send_message(update.message.chat_id,
                     text="Hai rimosso i warn di {}".format(usr_format))
    bot.unban_chat_member(update.message.chat_id,
                          update.message.reply_to_message.from_user.id)
Exemple #19
0
def init(update, context):
    bot = context.bot
    connector = Connection()
    query = Sql_Buttons.SQL_1
    connector.cur.execute(query)
    rows = connector.cur.fetchall()
    buttons = []
    for link in rows:
        buttons.append(InlineKeyboardButton(text=link[1], url=link[2]))
    menu = utils.build_menu(buttons, 2)
    bot.send_message(update.message.chat_id,
                     "Le Nostre Community su Telegram:",
                     reply_markup=InlineKeyboardMarkup(menu))
Exemple #20
0
def init(update, context):
    bot = context.bot
    message = update.message.text[10:]
    connector = Connection()
    chatid = str(update.message.chat_id)
    query = Sql_Pin.SQL_SET
    connector.cur.execute(query, [message, chatid])
    connector.cur.close()
    connector.db.close()
    bot.send_message(
        update.message.chat_id,
        text="<b>Hai salvato il seguente pin per il tuo gruppo:</b>\n\n{}".
        format(message),
        parse_mode='HTML')
Exemple #21
0
def init(update, context):
    bot = context.bot
    connector = Connection()
    ban_user = str(update.effective_user.id)
    query = Sql_Super_Ban.SQL
    connector.cur.execute(query, [ban_user])

    rows = connector.cur.fetchall()
    if rows:
        bot.send_message(
            update.message.chat_id,
            text="<b>IL SUPERBAN HA BANNATO:</b> <code>{id}!</code>".format(
                id=update.message.from_user.id),
            parse_mode='HTML')
        bot.kick_chat_member(update.message.chat_id,
                             update.message.from_user.id)
Exemple #22
0
def init(update, context):
    bot = context.bot
    message = str(update.message.text[9:]).strip()
    if message != "":
        chatid = str(update.message.chat_id)
        connector = Connection()
        query = Sql_Insert_Rules.SQL
        connector.cur.execute(query, [message, chatid])
        connector.db.commit()
        bot.send_message(update.message.chat_id,
                         text="Hai creato il regolamento del gruppo",
                         parse_mode='HTML')
    else:
        bot.send_message(update.message.chat_id,
                         str_service.RULES_HELP,
                         parse_mode='HTML')
Exemple #23
0
def action(update, context):
    bot = context.bot
    connector = Connection()
    chatid = str(update.message.chat_id)
    query = Sql_Rules.SQL
    connector.cur.execute(query, [chatid])
    row = connector.cur.fetchone()
    if row is not None:
        rules_message = "{}".format(row[0])
        bot.send_message(update.message.chat_id,
                         rules_message,
                         parse_mode='HTML')
    else:
        bot.send_message(update.message.chat_id,
                         str_service.RULES_MESSAGE,
                         parse_mode='HTML')
Exemple #24
0
def init(update, context):
    bot = context.bot
    try:
        connector = Connection()
        chatid = str(update.message.chat_id)
        bad_var = str(update.effective_message.text)
        query = Sql_Badword.SQL
        connector.cur.execute(query, [bad_var, chatid])
        rows = connector.cur.fetchall()
        if rows:
            message = "{} hai utilizzato una parola proibita!\nLeggi le /regole".format(
                update.message.from_user.first_name)
            bot.delete_message(update.message.chat_id,
                               update.message.message_id)
            bot.send_message(update.message.chat_id, message)
    except:
        print("questa chat non ha badword")
Exemple #25
0
def init(update, context):
    bot = context.bot
    message = str(update.message.text[14:])
    if message != "":
        chatid = str(update.message.chat_id)
        connector = Connection()
        query = Sql_Update_W.SQL
        connector.cur.execute(query, (message, chatid))
        connector.db.commit()
        bot.send_message(
            update.message.chat_id,
            text="Hai aggiornato correttamente il messaggio di Benvenuto!",
            parse_mode='HTML')
    else:
        bot.send_message(update.message.chat_id,
                         str_service.INSERT_W,
                         parse_mode='HTML')
def customhandler(update, context):
    connector = Connection()
    chatid = str(update.message.chat_id)
    var_answer = str(update.message.text).lower()
    query = Sql_Custom_Handler.SQL
    connector.cur.execute(query, ([var_answer], [chatid]))
    row = connector.cur.fetchone()
    if row is not None:
        parsed_message = row[0].replace(
            '{first_name}', update.message.from_user.first_name).replace(
                '{chat_title}', update.message.chat.title).replace(
                    '{username}', "@" + update.message.from_user.username)
        message = "{}".format(parsed_message)
        update.message.reply_text(text=message, parse_mode='HTML')
        row = connector.cur.fetchone()
        connector.cur.close()
        connector.db.close()
def init(update, context):
    bot = context.bot
    connector = Connection()
    chat = update.effective_chat.id
    ban_user = str(update.effective_user.id)
    query = Sql_Super_Ban.SQL
    connector.cur.execute(query, [ban_user])

    rows = connector.cur.fetchall()
    if rows:
        bot.send_message(
            chat,
            text="<b>The superban has banned:</b> <code>{id}!</code>\n"
            "Open https://hersel.it/apinebula.php".format(
                id=update.message.from_user.id),
            parse_mode='HTML')
        bot.delete_message(chat, update.message.message_id)
        bot.kick_chat_member(chat, update.message.from_user.id)
def init(update, context):
    bot = context.bot
    message = str(update.message.text[11:]).strip()
    if message != "":
        chatid = str(update.message.chat_id)
        default_b = 0
        connector = Connection()
        query = Sql_Insert_W.SQL
        connector.cur.execute(query, (chatid, message, default_b))
        connector.db.commit()
        bot.send_message(
            update.message.chat_id,
            text="Hai inserito correttamente il messaggio di Benvenuto!",
            parse_mode='HTML')
    else:
        bot.send_message(update.message.chat_id,
                         str_service.INSERT_W,
                         parse_mode='HTML')
Exemple #29
0
def init(update, context):
    bot = context.bot
    message = update.message.text[11:]
    connector = Connection()
    
    query = Sql_Insert_J.SQL_1
    connector.cur.execute(query, [message])
    row = connector.cur.fetchone()
    if row is None:
        query = Sql_Insert_J.SQL_2
        connector.cur.execute(query,[message])
        connector.db.commit()
    else:
        bot.send_message(update.message.chat_id, 
                         text="<b>Perfavore inserisci un'altra battuta questa esiste già!</b>", 
                         parse_mode='HTML')
        connector.cur.close()
        connector.db.close()
Exemple #30
0
def init(update, context):
    bot = context.bot
    message = str(update.message.text[9:])
    if message != "":
        save_user_id = update.message.reply_to_message.from_user.id
        save_date = datetime.strftime(datetime.today(), '%H:%M del %d/%m/%Y')
        connector = Connection()
        query = Sql_Superban.SQL
        connector.cur.execute(query, [save_user_id, message, save_date])
        connector.db.commit()
        bot.send_message(update.message.chat_id,
                         text="Hai SUPERBANNATO {id}".format(
                             id=update.message.reply_to_message.from_user.id),
                         parse_mode='HTML')
    else:
        bot.send_message(update.message.chat_id,
                         str_service.MESSAGE_SB,
                         parse_mode='HTML')