Exemplo n.º 1
0
def start_message(message):
    state[message.chat.id] = States.S_START
    # TODO Update message text
    bot.send_message(
        message.chat.id,
        'Hello {}!\nI can create cyberLinks, upload content to IPFS and check monitor validator jail status.'
        .format(message.from_user.username),
        reply_markup=base_keyboard_reply_markup(message.from_user.id))
Exemplo n.º 2
0
def tweet_menu(message):
    if message.text.lower() == TWEETER_MENU_LOWER[0]:
        bot.send_message(
            message.chat.id,
            'Please send new tweet as text, file, photo, video, audio, IPFS hash, URL, contact, location, '
            'video or voice',
            reply_markup=TWEETER_KEYBOARD)
    elif message.text.lower() == TWEETER_MENU_LOWER[1]:
        state[message.chat.id] = States.S_START
        bot.send_message(message.chat.id,
                         'Main Menu',
                         reply_markup=base_keyboard_reply_markup(
                             message.from_user.id))
Exemplo n.º 3
0
def sign_up_user(message):
    account_name = message.text
    if len(account_name) > 20:
        bot.send_message(
            message.chat.id,
            'Your account name contains more than 20 characters.\n'
            'Please enter a different account name.',
            reply_markup=base_keyboard_reply_markup(message.from_user.id))
        return
    if re.match("^[A-Za-z0-9_-]*$", account_name):
        account_data, create_account_error = create_account(account_name)
    else:
        bot.send_message(
            message.chat.id,
            'Your account name should only contain letters and numbers.\n'
            'Please enter a different account name.',
            reply_markup=base_keyboard_reply_markup(message.from_user.id))
        return
    if account_data:
        try:
            db_worker.signup_user(message.from_user.id, account_data["name"],
                                  account_data["address"])
        except Exception as e:
            print(e)
        bot.send_message(
            message.chat.id, f'Account: <b>{account_data["name"]}</b>\n'
            f'Address: <b>{account_data["address"]}</b>\n'
            f'Link: https://cyber.page/network/euler/contract/{account_data["address"]}\n\n'
            f'Mnemonic phrase: <u>{account_data["mnemonic_phrase"]}</u>\n'
            f'**Important**Please write down your mnemonic phrase and keep it safe. '
            f'The mnemonic is the only way to recover your account. '
            f'There is no way of recovering any funds if you lose it.',
            parse_mode="HTML",
            reply_markup=base_keyboard_reply_markup(message.from_user.id))
        transfer_state, transfer_error = transfer_eul_tokens(
            account_address=account_data["address"], value=10_000_000)
        if transfer_state:
            bot.send_message(
                message.chat.id,
                'I have transferred 2,500,000 EUL to you account.\n'
                'You can create cyberlinks now!\n'
                'If you create more than 10 cyberlinks, I will transfer an additional 7,500,000 EUL to your account!',
                reply_markup=base_keyboard_reply_markup(message.from_user.id))
        else:
            bot.send_message(
                message.chat.id,
                f'Tokens was not transferred.\nError: {transfer_error}',
                reply_markup=base_keyboard_reply_markup(message.from_user.id))
    else:
        bot.send_message(message.chat.id, f'Account not created\n'
                         f'error: {create_account_error}',
                         reply_markup=base_keyboard_reply_markup(
                             message.from_user.id))
Exemplo n.º 4
0
def monitoring_menu(message):
    if message.text.lower() == 'add validator moniker':
        bot.send_message(message.chat.id,
                         'Enter a validator moniker',
                         reply_markup=MONITORING_KEYBOARD)
    elif message.text.lower() == 'jail check':
        jail_check(message.chat.id)
    elif message.text.lower() == 'reset validator moniker':
        db_worker.reset_moniker(message.chat.id)
        bot.send_message(
            message.chat.id,
            'Moniker reset. Please add a validators moniker to check their jailed status',
            reply_markup=MONITORING_KEYBOARD)
    elif message.text.lower() == 'validator list':
        validators_dict, _ = validators_state()
        bot.send_message(message.chat.id,
                         '{}'.format(dict_to_md_list(validators_dict)),
                         parse_mode="HTML",
                         reply_markup=MONITORING_KEYBOARD)
    elif message.text.lower() == 'hourly check':
        scheduler_state = db_worker.get_scheduler_state(message.chat.id)
        if scheduler_state == 0:
            db_worker.set_scheduler_state(message.chat.id, 1)
            bot.send_message(message.chat.id,
                             'Set hourly jail check',
                             reply_markup=MONITORING_KEYBOARD)
            bot.send_message(
                message.chat.id,
                'The following notifications will be sent to you hourly',
                reply_markup=MONITORING_KEYBOARD)
            jail_check(message.chat.id)
        else:
            db_worker.set_scheduler_state(message.chat.id, 0)
            bot.send_message(message.chat.id,
                             'Unset hourly jail check',
                             reply_markup=MONITORING_KEYBOARD)
    elif message.text.lower() == 'back to main':
        state[message.chat.id] = States.S_START
        bot.send_message(message.chat.id,
                         'Main Menu',
                         reply_markup=base_keyboard_reply_markup(
                             message.from_user.id))
Exemplo n.º 5
0
def chat_unsupported_content_types(message):
    bot.send_message(message.chat.id,
                     f'Unsupported message type: {message.content_type}',
                     reply_markup=base_keyboard_reply_markup(
                         message.from_user.id))
Exemplo n.º 6
0
def main_menu(message):
    state[message.chat.id] = States.S_START
    if message.text.lower() == 'jail check':
        jail_check(message.chat.id)
    elif message.text.lower() == 'validator list':
        validators_dict, _ = validators_state()
        bot.send_message(message.chat.id,
                         '{}'.format(dict_to_md_list(validators_dict)),
                         parse_mode="HTML",
                         reply_markup=base_keyboard_reply_markup(
                             message.from_user.id))
    elif message.text.lower() == 'jail check settings':
        state[message.chat.id] = States.S_MONITORING
        bot.send_message(message.chat.id,
                         'Enter a validator moniker',
                         reply_markup=MONITORING_KEYBOARD)
    elif message.text.lower() == 'upload to ipfs':
        state[message.chat.id] = States.S_UPLOAD_IPFS
        bot.send_message(
            message.chat.id,
            'Please send text, file, photo, video, audio, IPFS hash, URL, contact, location, video or voice',
            reply_markup=base_keyboard_reply_markup(message.from_user.id))
    elif message.text.lower() == 'create cyberlink':
        if db_worker.check_sign_user(message.from_user.id):
            state[message.chat.id] = States.S_STARTPOINT_CYBERLINK
            bot.send_message(
                message.chat.id,
                'Please enter a keyword as a starting point for a new cyberLink or choose another service from the '
                'menu.\n'
                'You may enter an text, cyberLink, IPFS hash, URL, file, photo, video, audio, contact, location, video '
                'or voice.\n'
                'Please enter a keyword by which your content will be searchable in cyber, this will create '
                'the first part of the cyberLink.\n'
                'Please remember to be gentle, the search is case-sensitive.',
                reply_markup=base_keyboard_reply_markup(message.from_user.id))
        else:
            bot.send_message(
                message.chat.id,
                'Please create an account before creating cyberLinks',
                reply_markup=base_keyboard_reply_markup(message.from_user.id))
    elif message.text.lower() == 'sign up':
        if db_worker.check_sign_user(message.from_user.id):
            bot.send_message(message.chat.id,
                             f'You already created account',
                             reply_markup=base_keyboard_reply_markup(
                                 message.from_user.id))
            return
        if message.from_user.id > 1_400_000_000:
            bot.send_message(
                message.chat.id,
                f'Your telegram was recently registered, please use an older account',
                reply_markup=base_keyboard_reply_markup(message.from_user.id))
            return
        state[message.chat.id] = States.S_SIGNUP
        bot.send_message(
            message.chat.id,
            'To the maximum extent permitted by law, we make no guarantee, representation or warranty and expressly '
            'disclaim liability (whether to you or any person).\n'
            'Your use of this bot is voluntary and at your sole risk.\n'
            'In the event of any loss, hack or theft of EUL tokens from your account, you acknowledge and confirm '
            'that you shall have no right(s), claim(s) or causes of action in any way whatsoever against us.',
            reply_markup=base_keyboard_reply_markup(message.from_user.id))
        bot.send_message(
            message.chat.id,
            'Choose a name for your cyber account. Remember that the name will be case sensitive',
            reply_markup=base_keyboard_reply_markup(message.from_user.id))
    elif message.text.lower() == 'tweet':
        if not db_worker.check_sign_user(message.from_user.id):
            bot.send_message(message.chat.id,
                             f'For tweet please sign up',
                             reply_markup=base_keyboard_reply_markup(
                                 message.from_user.id))
            return
        state[message.chat.id] = States.S_NEW_TWEET
        bot.send_message(
            message.chat.id,
            'Please send new tweet as text, file, photo, video, audio, IPFS hash, URL, contact, location, '
            'video or voice',
            reply_markup=TWEETER_KEYBOARD)
Exemplo n.º 7
0
def send_message_when_start_state(message):
    bot.send_message(
        message.chat.id,
        'Please press "Create cyberLink" or the "Upload to IPFS" button to upload this file',
        reply_markup=base_keyboard_reply_markup(message.from_user.id))
Exemplo n.º 8
0
def endpoint_cyberlink(message):
    ipfs_hash, ipfs_error = message_upload_to_ipfs(message)
    send_ipfs_notification(message, ipfs_hash, ipfs_error, message_text=None)
    if ipfs_hash:
        state[message.chat.id] = States.S_STARTPOINT_CYBERLINK
        cyberlink_hash, cyberlink_error = \
            create_cyberlink(
                account_name=db_worker.get_account_name(message.from_user.id),
                from_hash=cyberlink_startpoint_ipfs_hash[message.chat.id],
                to_hash=ipfs_hash)
        if cyberlink_error == 'not enough personal bandwidth':
            cyberlink_hash, cyberlink_error = \
                create_cyberlink(
                    account_name=CYBERD_KEY_NAME,
                    from_hash=cyberlink_startpoint_ipfs_hash[message.chat.id],
                    to_hash=ipfs_hash)
        if cyberlink_hash:
            bot.send_message(
                message.chat.id,
                f'CyberLink created: https://cyber.page/network/euler/tx/{cyberlink_hash} \n'
                f'Transaction hash: <u>{cyberlink_hash}</u> ',
                parse_mode='HTML',
                reply_markup=base_keyboard_reply_markup(message.from_user.id))
            bot.send_message(
                message.chat.id,
                f'from: https://ipfs.io/ipfs/{cyberlink_startpoint_ipfs_hash[message.chat.id]}\n'
                f'to: https://ipfs.io/ipfs/{ipfs_hash}',
                parse_mode='HTML',
                reply_markup=base_keyboard_reply_markup(message.from_user.id))
            db_worker.write_cyberlink(
                user_id=message.from_user.id,
                cyberlink_hash=cyberlink_hash,
                from_ipfs_hash=cyberlink_startpoint_ipfs_hash[message.chat.id],
                to_ipfs_hash=ipfs_hash)
            if db_worker.get_cyberlink_count(
                    user_id=message.from_user.id) == 10:
                transfer_state, transfer_error = transfer_eul_tokens(
                    account_address=db_worker.get_account_address(
                        user_id=message.from_user.id),
                    value=90_000_000)
                if transfer_state:
                    bot.send_message(
                        message.chat.id, 'Congratulations!\n'
                        'You have created 10 links.\n'
                        '7,500,000 EUL Tokens have been transferred to your account!',
                        reply_markup=base_keyboard_reply_markup(
                            message.from_user.id))
                else:
                    bot.send_message(
                        message.chat.id,
                        f'Tokens was not transferred.\nError: {transfer_error}',
                        reply_markup=base_keyboard_reply_markup(
                            message.from_user.id))
        elif cyberlink_error:
            bot.send_message(message.chat.id, f'CyberLink not created\n'
                             f'error: {cyberlink_error}',
                             reply_markup=base_keyboard_reply_markup(
                                 message.from_user.id))
        bot.send_message(
            message.chat.id,
            'Please enter a keyword as a starting point for a new cyberLink or choose another service from the menu.\n'
            'You may enter an IPFS hash, URL, text, file, photo, video, audio, contact, location, video or voice.\n'
            'Please enter a keyword by which your content will be searchable in cyber, this will create the first part '
            'of the cyberlink.\n'
            'Please remember to be gentle, the search is case-senstive.',
            reply_markup=base_keyboard_reply_markup(message.from_user.id))