コード例 #1
0
def mute(bot, update):
    message = update.message
    user_id = message.from_user.id
    name = update.message.text
    reported = utils.get_user_id(name)
    con = demi_utils.create_connection()

    if not check_points(bot, update, MUTE):
        return ConversationHandler.END
    try:
        with con.cursor() as cur:
            cur.execute('UPDATE Ranking SET Points = Points - %s WHERE UserId = %s',
                        (str(MUTE), str(user_id)))
            cur.execute('UPDATE Usos SET Veces = Veces + %s WHERE UserId = %s', (str(MUTE), str(user_id)))
        text = 'Mira %s que te calles la puta boca 🤐\nCon amor @%s' % (name, message.from_user.username)
        bot.send_message(group_id, text, reply_markup=ReplyKeyboardRemove(selective=True))
        if message.chat.type == 'private':
            text = 'Has silenciado a %s 🤐' % name
            bot.send_message(user_id, text, reply_to_message_id=message.message_id,
                             reply_markup=ReplyKeyboardRemove(selective=True))

        thr1 = threading.Thread(target=couter_mute, args=(bot, reported))
        thr1.start()
    except Exception:
        logger.error('Fatal error in mute', exc_info=True)
    finally:
        if con:
            con.commit()
            con.close()
        return ConversationHandler.END
コード例 #2
0
def safe_love(bot, update, job_queue):
    message = update.message
    user_id = message.from_user.id
    command = message.text.split('@')[0].split(' ')[0]
    name = command.replace('/love', '').capitalize()
    loved = utils.get_user_id(name)
    if loved == user_id:
        bot.delete_message(chat_id=message.chat_id,
                           message_id=message.message_id)
    else:
        reports.send_love(bot, user_id, loved, job_queue)
コード例 #3
0
def duelo(bot, update, job_queue):
    import random
    message = update.message
    user_id = message.from_user.id
    name = update.message.text
    con = demi_utils.create_connection()
    random = random.randint(0, 1)
    if not check_points(bot, update, DUELO):
        return ConversationHandler.END
    try:
        bot.send_document(group_id, 'https://i.imgur.com/eK86rUd.gif')
        msg = bot.send_message(group_id, 'Es hora del DU DU DU DUELO!', parse_mode='Markdown')
        for i in range(3, 0, -1):
            time.sleep(1)

        if random == 0:
            reported = user_id
            bot.send_message(variables.group_id, name + ' tenía una carta trampa y pierdes')
            name = utils.get_name(reported)
            resource = 'data/gifs/duelo/bewd.mp4'
        else:
            reported = utils.get_user_id(name)
            bot.send_message(variables.group_id, 'Sacas a Exodia y ganas automáticamente')
            resource = 'data/gifs/duelo/exodia.mp4'

        gif_path = os.path.join(os.path.dirname(sys.modules['demiReportTelegram'].__file__), resource)
        if os.path.isfile(gif_path):
            gif1, gif2 = open(gif_path, 'rb'), open(gif_path, 'rb')
        else:
            gif1 = gif2 = 'data/gifs/duelo/exodia.mp4'

        with con.cursor() as cur:
            cur.execute('UPDATE Ranking SET Points = Points - %s WHERE UserId = %s',
                        (str(DUELO), str(user_id)))
            cur.execute('UPDATE Usos SET Veces = Veces + %s WHERE UserId = %s', (str(DUELO), str(user_id)))
        if message.chat.type == 'private':
            bot.send_document(user_id, gif2, reply_to_message_id=message.message_id,
                              reply_markup=ReplyKeyboardRemove(selective=True))
            bot.send_document(group_id, gif1)
        else:
            bot.send_document(group_id, gif1, reply_to_message_id=message.message_id,
                              reply_markup=ReplyKeyboardRemove(selective=True))
        if not isinstance(gif1, str):
            gif1.close()
            gif2.close()
        thr1 = threading.Thread(target=reports.counter, args=(bot, name, reported, job_queue))
        thr1.start()
    except Exception:
        logger.error('Fatal error in duelo', exc_info=True)
    finally:
        if con:
            con.commit()
            con.close()
        return ConversationHandler.END
コード例 #4
0
def headshot(bot, update, job_queue):
    message = update.message
    user_id = message.from_user.id
    name = update.message.text
    reported = utils.get_user_id(name)
    con = demi_utils.create_connection()

    if not check_points(bot, update, HEADSHOT):
        return ConversationHandler.END
    try:
        resource = 'data/gifs/headshots/%s.mp4' % str(reported)
        gif_path = os.path.join(
            os.path.dirname(sys.modules['demiReportTelegram'].__file__),
            resource)
        if os.path.isfile(gif_path):
            gif1, gif2 = open(gif_path, 'rb'), open(gif_path, 'rb')
        else:
            gif1 = gif2 = 'https://media.giphy.com/media/3N2ML3tw4c4uc/giphy.gif'

        with con.cursor() as cur:
            cur.execute(
                'UPDATE Ranking SET Points = Points - %s WHERE UserId = %s',
                (str(HEADSHOT), str(user_id)))
            cur.execute('UPDATE Usos SET Veces = Veces + %s WHERE UserId = %s',
                        (str(HEADSHOT), str(user_id)))
        if message.chat.type == 'private':
            bot.send_document(user_id,
                              gif2,
                              reply_to_message_id=message.message_id,
                              reply_markup=ReplyKeyboardRemove(selective=True))
            bot.send_document(group_id, gif1)
        else:
            bot.send_document(group_id,
                              gif1,
                              reply_to_message_id=message.message_id,
                              reply_markup=ReplyKeyboardRemove(selective=True))
        if not isinstance(gif1, str):
            gif1.close()
            gif2.close()
        thr1 = threading.Thread(target=reports.counter,
                                args=(bot, name, reported, job_queue))
        thr1.start()
    except Exception:
        logger.error('Fatal error in headshot', exc_info=True)
    finally:
        if con:
            con.commit()
            con.close()
        return ConversationHandler.END