コード例 #1
0
def check(update, context):
    uID = bot.chatID(update)

    if bot.user(uID) is not None:
        url = bot.user(uID)
        searchURL(context.bot, uID, url)
    else:
        context.bot.sendMessage(bot.chatID(update), "Website registred yet")
コード例 #2
0
def newgroup(update, context):
    grpName = update.message.text.split()[1]
    bot.modifyUser(bot.chatID(update),
                   [grpName, [bot.chatID(update)], {
                       "chat_state": 0
                   }])
    context.bot.sendMessage(bot.chatID(update),
                            "New group '" + grpName + "' has been created")
コード例 #3
0
def join(update, context):
    grpName = update.message.text.split()[1]

    for u in bot.getUserDataOriginal().values():
        if u[0] == grpName:
            u[1].append(bot.chatID(update))
            bot.modifyUser(u[1][0], u)
            context.bot.sendMessage(bot.chatID(update), "Joined group")
            break
コード例 #4
0
def begin(update, context):
    usrData = bot.user(bot.chatID(update))

    if usrData is None:
        context.bot.sendMessage(bot.chatID(update), notLeaderMessage)
        return
    reply_markup = ReplyKeyboardMarkup([["3", "4"], ["5", "6"], ["7", "8"]])
    bot.sendMessage(bot.chatID(update),
                    "How many players are you? (1-8)",
                    rpl_markup=reply_markup)

    usrData[2]["chat_state"] = 1
    bot.modifyUser(bot.chatID(update), usrData)
コード例 #5
0
def search(update, context):
    searchKey = str(update.message.text.split()[1])
    searchURL(
        context.bot,
        bot.chatID(update),
        "https://beatsaver.com/search?q=" + searchKey,
        maxResults=5,
        sendMessage=("Searching for '" + searchKey + "'"),
    )
コード例 #6
0
ファイル: app.py プロジェクト: FIUS/ceiling-pi
def modeChange(update, context):
    chatID = BotWrapper.chatID(update)

    if str(chatID) in BotWrapper.getUserData():

        msg = update.message.text.split()[0][1:]

        led.stringToMode(msg.lower())

        BotWrapper.sendMessage(chatID, "Switched to " + str(msg))
コード例 #7
0
ファイル: app.py プロジェクト: FIUS/ceiling-pi
def adminResponse(update, context):
    chatID = BotWrapper.chatID(update)
    try:
        BotWrapper.getBot().delete_message(
            chat_id=update.effective_chat.id,
            message_id=update.effective_message.message_id)
    except Exception as e:
        print(e)
    inp = str(update.callback_query.data)
    if inp is not "no":
        BotWrapper.modifyUser(int(inp), True)
        BotWrapper.sendMessage(inp, "You have been accepted")
        BotWrapper.sendMessage(chatID, "Request has been accepted")
    else:
        BotWrapper.sendMessage(chatID, "Request has been denied")
コード例 #8
0
ファイル: app.py プロジェクト: FIUS/ceiling-pi
def admin(update, context):
    user = update.message.from_user
    chatID = BotWrapper.chatID(update)
    print(chatID)
    BotWrapper.sendMessage(chatID, "Request has been sent...")
    button_list = [
        InlineKeyboardButton("Ja", callback_data=chatID),
        InlineKeyboardButton("Nein", callback_data="no")
    ]
    reply_markup = InlineKeyboardMarkup(
        BotWrapper.build_menu(button_list, n_cols=1))
    message = '{} (@{}) wants to admin, accept request?'.format(
        user['first_name'], user['username'])
    BotWrapper.getBot().sendMessage(config.admin,
                                    message,
                                    reply_markup=reply_markup)
コード例 #9
0
def register(update, context):
    websiteURL = update.message.text.split()[1]
    bot.modifyUser(bot.chatID(update), websiteURL)
    context.bot.sendMessage(bot.chatID(update), "Website registred")
コード例 #10
0
def start(update, context):
    context.bot.sendMessage(
        bot.chatID(update),
        "Register your Beatsaver page with /register <url>")
コード例 #11
0
def default(update, context):
    usrData = bot.user(bot.chatID(update))

    if usrData is not None:

        chatState = usrData[2]["chat_state"]

        if chatState == 1:
            try:
                numberInput = update.message.text
                try:
                    numberInput = int(numberInput)
                except:
                    print("Not a number")
                if numberInput > 8 or numberInput < 1:
                    bot.sendMessage(bot.chatID(update),
                                    "Choose between 1 and 8",
                                    isHTML=True)
                    return
                usrData[2]["player"] = numberInput
                usrData[2]["chat_state"] = 2
                bot.modifyUser(bot.chatID(update), usrData)

                cats = []
                cats.append(["None"])
                for i in range(0, len(config.areas)):
                    button = config.areas[i][8]["category"]
                    if button is not None:
                        cats.append([button])

                reply_markup = ReplyKeyboardMarkup(cats)
                context.bot.send_message(
                    chat_id=bot.chatID(update),
                    text="What category you want to play?",
                    reply_markup=reply_markup)

            except Exception as e:
                print("a")
                bot.sendMessage(bot.chatID(update), str(e))

        elif chatState == 2:
            try:
                #areaIdx = rdm.randint(0, len(config.areas)-1)
                areaIn = update.message.text
                possibleAreas = []

                if areaIn == "None":
                    areaIn = None
                for idx, val in enumerate(config.areas):
                    category = val[8]['category']

                    if category == areaIn:
                        possibleAreas.append(idx)

                reply_markup = ReplyKeyboardRemove()
                context.bot.send_message(chat_id=bot.chatID(update),
                                         text="Started game",
                                         reply_markup=reply_markup)

                playerInStore = len(usrData[1])
                playerInMessage = int(usrData[2]["player"])
                playerNotRegistered = playerInMessage - playerInStore
                playerNotOnPhone = playerInStore - 1
                playerOnPhone = playerNotRegistered + 1

                areaIdx = rdm.randint(0, len(possibleAreas) - 1)

                area = possibleAreas[areaIdx]
                area = config.areas[area]
                areaIdx = possibleAreas[areaIdx]
                jobs = []
                jobIdx = list(range(1, len(area) - 1))
                rdm.shuffle(jobIdx)

                if playerOnPhone < 2:
                    for i in range(0, playerInMessage - 1):
                        jobs.append("<b> 📍 Ort: </b>\n   " + str(area[0]) +
                                    "\n\n<b>💼 Beruf:</b>\n   " +
                                    area[jobIdx.pop(0)])

                    jobs.append("<b> 📍 Ort: </b>\n   " + "<i>Unbekannt</i>" +
                                "\n\n<b>💼 Beruf:</b>\n   🕵️ Spion")
                    rdm.shuffle(jobs)

                    for idx, val in enumerate(usrData[1]):

                        bot.sendMessage(val, jobs[idx], isHTML=True)
                else:
                    rdm.shuffle(jobIdx)
                    for i in range(0, 7 - playerInMessage + 1):
                        jobIdx.pop(0)

                    jobIdx.append("!")
                    rdm.shuffle(jobIdx)

                    jobIdxPhone = []
                    jobIdxOther = []

                    for i in range(0, playerOnPhone):
                        jobIdxPhone.append(jobIdx[0])
                        jobIdx.pop(0)

                    for i in range(0, playerNotOnPhone):
                        jobIdxOther.append(jobIdx[0])
                        jobIdx.pop(0)

                    for i, chatID in enumerate(usrData[1]):
                        if i == 0:
                            continue
                        idx = jobIdxOther[i - 1]
                        if idx == "!":
                            bot.sendMessage(chatID,
                                            "<b> 📍 Ort: </b>\n   " +
                                            "<i>Unbekannt</i>" +
                                            "\n\n<b>💼 Beruf:</b>\n   🕵️ Spion",
                                            isHTML=True)
                        else:
                            bot.sendMessage(chatID,
                                            "<b> 📍 Ort: </b>\n   " + "<i>" +
                                            area[0] + "</i>" +
                                            "\n\n<b>💼 Beruf:</b>\n   " +
                                            area[idx],
                                            isHTML=True)

                    callback = ""

                    for i in jobIdxPhone:
                        callback += str(areaIdx) + "," + str(i) + "#X#"

                    callback += str(bot.chatID(update))

                    button_list = [
                        InlineKeyboardButton("Next", callback_data=callback)
                    ]

                    reply_markup = InlineKeyboardMarkup(
                        bot.build_menu(button_list, n_cols=1))
                    context.bot.send_message(bot.chatID(update),
                                             "Weiter geben",
                                             reply_markup=reply_markup)

                chatState = usrData[2]["chat_state"] = 0
                bot.modifyUser(bot.chatID(update), usrData)
            except Exception as e:
                print(e)
コード例 #12
0
def locations(update, context):
    locationMsg = "<b> 📍 Orte: </b>\n"
    for idx, loc in enumerate(config.areas):
        locationMsg += str(idx + 1) + ": " + loc[0] + "\n"
    bot.sendMessage(bot.chatID(update), locationMsg, isHTML=True)
コード例 #13
0
def delgroup(update, context):
    bot.removeUser(bot.chatID(update))
コード例 #14
0
def start(update, context):
    bot.sendMessage(bot.chatID(update), startMessage)
コード例 #15
0
def start(update, context):
    chatID = BotWrapper.chatID(update)
    BotWrapper.sendMessage(chatID, "Your ChatID is: " + str(chatID))