Beispiel #1
0
def choose_meme(message):
    send_in_analytics({
        'text': message.text,
        'userId': str(message.from_user.id),
        "intent": {
            "name": "MEME CREATION",
            "inputs": [{
                "name": "query",
                "value": message.text
            }]
        }
    })
    page = 0
    markup = generate_page_inline_layout(page)  # Setup inline keyboard markup
    msg = bot.send_message(message.chat.id,
                           'Select the meme from database',
                           reply_markup=markup)
    send_out_analytics({
        'text': msg.text,
        'userId': str(message.from_user.id),
        "intent": {
            "name": "MEME CREATION",
            "inputs": [{
                "name": "select meme menu",
                "value": msg.text
            }]
        }
    })
Beispiel #2
0
def select_meme(call):

    curr_meme = str(call.data)[6:]
    bot.answer_callback_query(call.id)
    msg = bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id, reply_markup=None)

    sent_messages_id = list()  # Accumulating sent messages in case the user will send /cancel command
    sent_messages_id.append(msg.message_id)

    msg = bot.send_message(call.message.chat.id, parse_mode='Markdown',
                           text='Fill the following content areas. Send me a photo, a text or even a _STICKER_.\n\n'
                                '(type \"-\" to leave the area blank)')
    sent_messages_id.append(msg.message_id)
    send_out_analytics({
        'text': msg.text,
        'userId': str(call.from_user.id),
        "intent": {"name": "MEME CREATION", "inputs": [{"name": "creation info", "value": msg.text}]}})

    area = 1
    num_of_fields_to_read = len(Memes[curr_meme].areas.keys())
    markup = telebot.types.ForceReply()
    meme_content = list()

    msg = bot.send_message(call.message.chat.id, 'Enter the content for the area 1:', reply_markup=markup)
    sent_messages_id.append(msg.message_id)
    send_out_analytics({'text': msg.text, "intent": {"name": "MEME CREATION",
                                                     "inputs": [{"name": "area", "value": str(1)}]}})

    bot.register_next_step_handler(msg, content_injection, num_of_fields_to_read, area, curr_meme, meme_content,
                                   sent_messages_id)
Beispiel #3
0
def send_available_memes(message):
    send_in_analytics({'text': message.text, 'userId': str(message.from_user.id)})
    global available_memes_file_id
    if available_memes_file_id is None:
        available_memes_file_id = bot.send_photo(message.chat.id, open('Memes.png', 'rb')).photo[0].file_id
    else:
        bot.send_photo(message.chat.id, available_memes_file_id)
    send_out_analytics({'text': '', 'userId': str(message.from_user.id), 'images': [
        {'url': 'https://api.telegram.org/file/bot' + TOKEN + '/' + bot.get_file(available_memes_file_id).file_path}]})
Beispiel #4
0
def send_welcome(message):
    send_in_analytics({'text': message.text, 'userId': str(message.from_user.id)})
    send_out_analytics({'text': bot.send_message(message.chat.id, parse_mode='Markdown',
                                                 text='Hi there, *' + message.from_user.first_name +
                                                      '*! Go on and make some 😂😂👌👌😂_dank shit_💯💯 here!\n\n'
                                                      'Use /creatememe\n\n'
                                                      'Make yourself familiar with all available _memes_ with /available',
                                                 reply_markup=menu).text,
                        'userId': str(message.from_user.id)})
Beispiel #5
0
def cancel(message):
    send_in_analytics({
        'text': message.text,
        'userId': str(message.from_user.id)
    })
    send_out_analytics({
        'text':
        bot.send_message(message.chat.id, 'No action to cancel.').text,
        'userId':
        str(message.from_user.id)
    })
Beispiel #6
0
def info(message):
    send_in_analytics({
        'text': message.text,
        'userId': str(message.from_user.id)
    })
    send_out_analytics({
        'text':
        bot.send_message(
            message.chat.id, 'Bot made by @TheSubliminal\n'
            'Feel free to send me any suggestions or bug reports.').text,
        'userId':
        str(message.from_user.id)
    })
Beispiel #7
0
def help_info(message):
    send_in_analytics({
        'text': message.text,
        'userId': str(message.from_user.id)
    })
    send_out_analytics({
        'text':
        bot.send_message(
            message.chat.id, '/creatememe - Create a meme from template\n'
            '/available - List of the all available memes\n'
            '/cancel - Cancels current action').text,
        'userId':
        str(message.from_user.id)
    })
Beispiel #8
0
def respond_to_message(message):
    send_in_analytics({
        'text': message.text,
        'userId': str(message.from_user.id),
        'intent': {
            'name': 'NotHandled'
        }
    })
    send_out_analytics({
        'text':
        bot.send_message(message.chat.id,
                         'I don\'t understand you...Is this loss??').text,
        'userId':
        str(message.from_user.id),
        'intent': {
            'name': 'NotHandled'
        }
    })
Beispiel #9
0
def donation_info(message):
    send_in_analytics({
        'text': message.text,
        'userId': str(message.from_user.id)
    })
    send_out_analytics({
        'text':
        bot.send_message(
            message.chat.id,
            parse_mode='Markdown',
            text=
            'If you want to thank me for the experience you had with this bot'
            ' you can donate me via:\n\n'
            'PrivatBank:\n*4149 4978 5676 6680*\n\n'
            'Bitcoin:\n*1HvF4uSHNz9z1zafqSr2N8rxXyHcqAGrmY*\n\n'
            'Ethereum:\n*0x5714Dde9B12Bf629F185CeE90f263C05816B1616*').text,
        'userId':
        str(message.from_user.id)
    })
Beispiel #10
0
def content_injection(message, num_of_fields_to_read, area, curr_meme, meme_content, sent_messages):

    num_of_fields_to_read -= 1
    area += 1
    markup = telebot.types.ForceReply()

    if message.text == '-':
        meme_content.append('')

    elif message.text == '/cancel':
        send_in_analytics({'text': message.text, 'userId': message.from_user.id})
        send_out_analytics(
            {'text': bot.send_message(message.chat.id, 'Current action was cancelled.', reply_markup=menu).text,
             'userId': message.from_user.id})
        num_of_fields_to_read = -1
        delete_messages(message.chat.id, sent_messages)
        del meme_content

    elif message.content_type == 'photo':
        file_id = message.photo[-1].file_id
        file = bot.get_file(file_id)
        meme_content.append(file.file_path)
        send_in_analytics({'text': '', 'userId': str(message.from_user.id),
                           'images': [{'url': 'https://api.telegram.org/file/bot' + TOKEN + '/' + file.file_path}]})

    elif message.content_type == 'sticker':
        sticker = message.sticker.file_id
        sticker_file = bot.get_file(sticker)
        meme_content.append(sticker_file.file_path)
        send_in_analytics({'text': '', 'userId': str(message.from_user.id),
                           'images': [{'url': 'https://api.telegram.org/file/bot' + TOKEN + '/' + sticker_file.file_path
                                       }]})

    elif message.content_type == 'text':
        meme_content.append(message.text)
        send_in_analytics({'text': message.text, 'userId': str(message.from_user.id)})

    else:
        err_msg = bot.send_message(message.chat.id, 'Please, try to send me some text, picture or a sticker')
        send_out_analytics({'text': err_msg.text, 'userId': message.from_user.id, 'intent': {'name': 'NotHandled'}})
        sent_messages.append(err_msg.message_id)
        num_of_fields_to_read += 1
        area -= 1

    if num_of_fields_to_read > 0:
        msg = bot.send_message(message.chat.id, 'Enter the content for the area ' + str(area) + ':',
                               reply_markup=markup)
        send_out_analytics({'text': msg.text, 'userId': str(message.from_user.id)})
        sent_messages.append(msg.message_id)
        bot.register_next_step_handler(msg, content_injection, num_of_fields_to_read, area,
                                       curr_meme, meme_content, sent_messages)

    elif num_of_fields_to_read == 0:
        send_out_analytics({'text': bot.send_message(message.chat.id, 'Your meme', reply_markup=menu).text,
                            'userId': str(message.from_user.id)})
        file_id = bot.send_photo(message.chat.id, create_meme(curr_meme, meme_content, TOKEN)).photo[-1].file_id
        file = bot.get_file(file_id)
        send_out_analytics({'text': '', 'userId': str(message.from_user.id),
                           'images': [{'url': 'https://api.telegram.org/file/bot' + TOKEN + '/' + file.file_path}]})
        del sent_messages

    else:
        pass