Esempio n. 1
0
def get_user_data_by_token(token):
    res = database_helper.get_user_info(token)
    if res != None:
        jsonfile = json.dumps({
            "success": True,
            "Message": "User found",
            "Data": res
        })
    else:
        jsonfile = json.dumps({"success": False, "Message": "Token error"})
    return jsonfile
Esempio n. 2
0
def start(bot, update):
    print "{} is prompting the bot".format(update.message.chat_id)

    try:
        user_exists = check_for_existing_user(
            telegram_id=update.message.chat_id)

    except Exception as e:
        print e

    else:
        if user_exists:
            # print "User exists!"
            user_data_dict = get_user_info(telegram_id=update.message.chat_id)
            # print "User {} is prompting the bot".format(user_data_dict['eng_name'])
            print "[{}] {} starts talking".format(
                datetime.datetime.now(),
                get_user_engname(update.message.chat_id))

            if user_data_dict['isAdmin'] == 'No':
                update.message.reply_sticker('BQADAgADWgADVSx4CwEjojGmsKGbAg')
                update.message.reply_text(
                    "Hi *{}*, we meet again, what can I do for you today?".
                    format(user_data_dict['nick_name']),
                    reply_markup=markup_main_menu_kb,
                    parse_mode=telegram.ParseMode.MARKDOWN)
            else:
                update.message.reply_sticker('BQADAgADWgADVSx4CwEjojGmsKGbAg')
                update.message.reply_text(
                    "Hey whatsup boss *{}*, we meet again! What can I do for you today?"
                    .format(user_data_dict['nick_name']),
                    reply_markup=markup_adminmain_menu_kb,
                    parse_mode=telegram.ParseMode.MARKDOWN)
                return CHOOSING

        else:
            print "{} is an unknown user!".format(update.message.chat_id)
            update.message.reply_sticker('BQADAgADZgADVSx4C4I00LsibnWGAg')
            update.message.reply_text(
                "Hi! I am the LHC AutoBot!. I will need some information before we proceed. "
                "Why don't you tell me something about yourself?",
                reply_markup=markup)

            return CHOOSING
Esempio n. 3
0
def start(bot, update):
    print "[{}] {} starts talking".format(
        datetime.datetime.now(), get_user_nick(update.message.chat_id))
    user_exists = check_for_existing_user(telegram_id=update.message.chat_id)
    if user_exists:
        user_data_dict = get_user_info(telegram_id=update.message.chat_id)
        update.message.reply_sticker("CAADAgADGAADJQNSD144kdv3aKiQAg")
        update.message.reply_text(
            "Hey there *{}*! I am the LHC EvangelismBot. My buddy, AutoBot told me about you. "
            "My mission is to help you in evangelism! Now, what do you need in order evangelize today?\n\n"
            .format(user_data_dict['nick_name']),
            reply_markup=markup,
            parse_mode=telegram.ParseMode.MARKDOWN)

        return CHOOSING

    else:
        update.message.reply_sticker("CAADAgADHgADJQNSDz2IE2RzBSd-Ag")
        update.message.reply_text(
            "I'm not sure who you are.. Perhaps you should talk to my good friend, LHC Autobot first. t.me/RHopeBot"
        )
Esempio n. 4
0
def view_mypray_items(bot, update):
    try:
        pray_items = get_myprayer_items(
            member_id=get_user_info(update.message.chat_id)['id'])

        if pray_items is None:
            update.message.reply_sticker("CAADAgADYgADVSx4C-wfF-VhdzeCAg")
            update.message.reply_text(
                "You have not set any prayer items. You can set them my pressing on *Edit My Prayer Items* "
                "in the keyboard below. Then, just type in all the prayer items that you want me to remember.."
                "Simple right?",
                parse_mode=telegram.ParseMode.MARKDOWN)
    except Exception as e:
        update.message.reply_text(
            "This is embarrassing.. i cant seem to get your prayer items!\nError: {}"
            .format(e))

    else:
        update.message.reply_text(
            "These are your current prayer items:\n\n{}".format(
                pray_items.encode('utf-8')))
Esempio n. 5
0
def start(bot, update):
    # print "{} starts talking".format(get_user_nick(update.message.chat_id))
    print "[{}] {} starts talking".format(
        datetime.datetime.now(), get_user_nick(update.message.chat_id))
    user_exists = check_for_existing_user(telegram_id=update.message.chat_id)
    if user_exists:
        user_data_dict = get_user_info(telegram_id=update.message.chat_id)
        update.message.reply_sticker("CAADAgADMgADVSx4C49XV6fn89_VAg")
        update.message.reply_text(
            "Hey there *{}*! I am the LHC PrayerBot. My buddy, AutoBot told me about you. I can record your prayer time, remind you to pray, etc..\n\n"
            "What should I do for you today?".format(
                user_data_dict['nick_name']),
            reply_markup=markup,
            parse_mode=telegram.ParseMode.MARKDOWN)

        return CHOOSING
    else:
        update.message.reply_sticker("BQADAgADTAADVSx4C1Euf8V7S5s0Ag")
        update.message.reply_text(
            "I'm not sure who you are.. Perhaps you should talk to my fellow friend, LHC Autobot first. t.me/RHopeBot"
        )
Esempio n. 6
0
def start(bot, update):
    print "[{}] {} starts talking".format(
        datetime.datetime.now(), get_user_nick(update.message.chat_id))
    user_exists = check_for_existing_user(telegram_id=update.message.chat_id)
    if user_exists:
        user_data_dict = get_user_info(telegram_id=update.message.chat_id)
        update.message.reply_sticker("CAADAgADHQIAAkcVaAnKYeyU0qLAgwI")
        update.message.reply_text(
            "Hey there *{}*! I am the LHC PraiseBot. My buddy, AutoBot told me about you. "
            "Praising has been my life! How can I help you praise today?\n\n".
            format(user_data_dict['nick_name']),
            reply_markup=markup,
            parse_mode=telegram.ParseMode.MARKDOWN)

        return CHOOSING

    else:
        update.message.reply_sticker("BQADAgADTAADVSx4C1Euf8V7S5s0Ag")
        update.message.reply_text(
            "I'm not sure who you are.. Perhaps you should talk to my good friend, LHC Autobot first. t.me/RHopeBot"
        )
Esempio n. 7
0
def received_prayer_information(bot, update, user_data):
    text = update.message.text
    category = user_data['choice']
    user_data[category] = text
    del user_data['choice']

    info = get_user_info(telegram_id=update.message.chat_id)

    # filter the user inputs. Make sure user only entered numbers
    try:
        pray_mins = float(text)

    except Exception as e:
        print e
        update.message.reply_sticker("BQADAgADRAADVSx4CzmHlwP9k0jSAg")
        update.message.reply_text(
            "....*coughing hard*.... I don't seem to understand what you wrote.. "
            "Did you enter your prayer time correctly? Please key in numbers only",
            reply_markup=markup)

    else:
        update.message.reply_sticker("BQADAgADUAADVSx4C4RAPsaJNQ4GAg")
        update.message.reply_text(
            "Sweet!! You have prayed for {} minutes! I'm recording this into my notes.."
            .format(pray_mins),
            reply_markup=markup)

        name_id = int(info['id'])
        entry_prayer_time(name_id=name_id,
                          total_time_prayed=pray_mins,
                          date=datetime.datetime.now())

        print "Entered pray time for: {} at {}".format(info['eng_name'],
                                                       datetime.datetime.now())

    finally:
        return CHOOSING