示例#1
0
def send_catch_action(message):
    db = TinyDbInterface()
    global active

    print("Caught: " + curPokemon)
    print(curPokemonNum)

    if curPokemonNum == '':
        print("No pokemon to catch :(")
        bot.reply_to(message, "Nothing is there :(")
    else:

        username = message.from_user.username
        chatid = message.chat.id

        if (type(message.from_user.username) is not str):
            username = str(message.from_user.username)
            chatid = str(message.chat.id)
            # You need a username now

        if (db.CheckUserExists(username, chatid) == 0):
            if (active == True):
                db.AddPokemon(username, chatid, int(curPokemonNum))
                active = False

                bot.reply_to(message, username + " caught a " + curPokemon)
            else:
                bot.reply_to(message, "Nothing is there.")
        else:
            bot.reply_to(message, "Who are you?")

    pass
示例#2
0
def send_pokedex_action(message):
    pokedex = ''
    db = TinyDbInterface()

    username = message.from_user.username
    chatid = message.chat.id

    if (type(message.from_user.username) is not str):
        username = str(message.from_user.username)
        chatid = str(message.chat.id)

    if (db.CheckUserExists(username, chatid) == 0):
        pokedex = db.GetUserPokemon(username, chatid)
        if (pokedex != ""):
            bot.reply_to(message, pokedex)
            bot.send_chat_action(message.chat.id, 'upload_photo')
            bot.send_photo(
                chatid, open('user_dex.png', 'rb')
            )  #, caption(pokedex)) #, reply_to_message_id = message.message_id)
        else:
            bot.reply_to(message, "You have no pokemon.")
    else:
        bot.reply_to(message, "Who are you?")

    pass
示例#3
0
def join_action(message):
    db = TinyDbInterface()

    if (type(message.from_user.username) is not str):
        username = str(message.from_user.username)
        chatid = message.chat.id
    else:
        username = message.from_user.username
        chatid = message.chat.id

    # cannot join 2x!!!
    if (db.CheckUserExists(username, chatid) == 0):
        bot.reply_to(message, "You already joined!")

    else:
        db.AddUser(username, chatid)
        print(username)
        bot.reply_to(message, "Welcome to the World of Pokemon " + username)