Пример #1
0
def connectExpert():
    sessionID = request.values.get('sessionID', None)
    type = request.values.get('type', None)
    userID = db.getUserID(sessionID)
    if userID:
        expert = connect.connect_expert(userID, type)
        return str(expert)
    return str("Invalid Session")
Пример #2
0
def tip(update, ctx):
    gettime = str(update.message.date).split()
    timetoconvert = gettime[0] + "T" + gettime[1]
    timestamp = strict_rfc3339.rfc3339_to_timestamp(timetoconvert)

    if timestart < int(timestamp):

        user = update.message.from_user
        args = update.message.text.split(" ")

        if not db.checkUser(user["id"]):
            ctx.bot.send_message(chat_id=update.message.chat_id,
                                 text="It looks like you haven't registered yet. Please run /help first to register yourself")
        else:
            target = None
            try:
                target = args[1][1:]
            except IndexError:
                target = target

            amount = None
            try:
                amount = args[2]
            except IndexError:
                amount = amount

            if target is not None:
                if not db.getUserID(target):
                    ctx.bot.send_message(chat_id=update.message.chat_id,
                                         text="Oops, looks like your sending to a user who hasn't registered or has changed their username. Ask them to do /help to register/re-register!\nPlease be mindful that usernames are case senstive. Make sure that the case of the target is correct.")
                else:
                    if user["username"] == target:
                        ctx.bot.send_message(chat_id=update.message.chat_id, text="😆 You can't tip yourself!")
                    else:
                        if amount is not None:
                            if isFloat(amount):
                                if float(amount) > float(config.coin['minFee']):
                                    keyboard = [
                                        [
                                            InlineKeyboardButton("Yes", callback_data=f"Y,{db.getUserID(target)},{amount},{user['id']},t"),
                                            InlineKeyboardButton("No", callback_data=f"N,{target},{amount},{user['id']},t")
                                        ]
                                    ]
                                    reply_markup = InlineKeyboardMarkup(keyboard)
                                    ctx.bot.send_message(chat_id=update.message.chat_id,
                                                         text=f"You are about to send {amount} {config.coin['ticker']} with an additional fee of {format(float(config.coin['minFee']), '.8f')} SUGAR to @{target}. Please click Yes to confirm",
                                                         reply_markup=reply_markup)
                                else:
                                    ctx.bot.send_message(chat_id=update.message.chat_id,
                                                         text="You cannot send negative amounts or amounts less than 0.00001!")
                            else:
                                ctx.bot.send_message(chat_id=update.message.chat_id,
                                                     text="Invalid amount of SUGAR. Please try again")
                        else:
                            ctx.bot.send_message(chat_id=update.message.chat_id, text="No amount specified!")
            else:
                ctx.bot.send_message(chat_id=update.message.chat_id, text="No user specified!")
Пример #3
0
def tip(update, ctx):
    gettime = str(update.message.date).split()
    timetoconvert = gettime[0] + "T" + gettime[1]
    timestamp = strict_rfc3339.rfc3339_to_timestamp(timetoconvert)

    if timestart < int(timestamp):

        user = update.message.from_user
        args = update.message.text.split(" ")

        language = str()

        if update.message.chat.type == "private":
            language = db.getLang(user["id"])
        else:
            language = getLang(update.message.chat_id)

        if not db.checkUser(user["id"]):
            ctx.bot.send_message(
                chat_id=update.message.chat_id,
                text=lang[language]['error']['general']['dm-only'])
        else:
            target = None
            try:
                target = args[1][1:]
            except IndexError:
                target = target

            amount = None
            try:
                amount = args[2]
            except IndexError:
                amount = amount

            if target is not None:
                if not db.getUserID(target):
                    ctx.bot.send_message(
                        chat_id=update.message.chat_id,
                        text=lang[language]['error']['tip']['re-register'])
                else:
                    if user["username"] == target:
                        ctx.bot.send_message(
                            chat_id=update.message.chat_id,
                            text=lang[language]['tip']['tip-yourself'])
                    else:
                        if amount is not None:
                            if isFloat(amount):
                                if float(amount) > float(
                                        config.coin['minFee']):
                                    print(db.getUserID(target))
                                    keyboard = [[
                                        InlineKeyboardButton(
                                            "Yes",
                                            callback_data=
                                            f"Y,{db.getUserID(target)},{amount},{user['id']},t"
                                        ),
                                        InlineKeyboardButton(
                                            "No",
                                            callback_data=
                                            f"N,{db.getUserID(target)},{amount},{user['id']},t"
                                        )
                                    ]]
                                    reply_markup = InlineKeyboardMarkup(
                                        keyboard)
                                    ctx.bot.send_message(
                                        chat_id=update.message.chat_id,
                                        text=
                                        f"{lang[language]['tip']['part-1']} {amount} {config.coin['ticker']} {lang[language]['tip']['part-2']} {format(float(config.coin['minFee']), '.8f')} {lang[language]['tip']['part-2']} @{target}. {lang[language]['tip']['part-4']}",
                                        reply_markup=reply_markup)
                                else:
                                    ctx.bot.send_message(
                                        chat_id=update.message.chat_id,
                                        text=lang[language]['error']['tip']
                                        ['negative-amount'])
                            else:
                                ctx.bot.send_message(
                                    chat_id=update.message.chat_id,
                                    text=lang[language]['error']['tip']
                                    ['invalid-amount'])
                        else:
                            ctx.bot.send_message(
                                chat_id=update.message.chat_id,
                                text=lang[language]['error']['tip']
                                ['no-amount'])
            else:
                ctx.bot.send_message(
                    chat_id=update.message.chat_id,
                    text=lang[language]['error']['tip']['no-user'])
Пример #4
0
def tip(update, ctx):
    gettime = str(update.message.date).split()
    chatid = update.message.chat_id
    timetoconvert = gettime[0] + "T" + gettime[1]
    timestamp = strict_rfc3339.rfc3339_to_timestamp(timetoconvert)

    if timestart < int(timestamp):

        user = update.message.from_user
        args = update.message.text.split(" ")

        if not db.checkUser(user["id"]):
            if checkRus(chatid):
                ctx.bot.send_message(
                    chat_id=update.message.chat_id,
                    text=
                    "Похоже, вы еще не зарегистрировались. Пожалуйста запустите команду /help для регистрации"
                )
            else:
                ctx.bot.send_message(
                    chat_id=update.message.chat_id,
                    text=
                    "It looks like you haven't registered yet. Please run /help first to register yourself"
                )
        else:
            target = None
            try:
                target = args[1][1:]
            except IndexError:
                target = target

            amount = None
            try:
                amount = args[2]
            except IndexError:
                amount = amount

            if target is not None:
                if not db.getUserID(target):
                    if checkRus(chatid):
                        ctx.bot.send_message(
                            chat_id=update.message.chat_id,
                            text=
                            "Упс, похоже, вы отправляете пользователю, который не зарегистрировался. Попросите его сделать /help для регистрации!\nПомните, что имена пользователей чувствительны к регистру. Убедитесь, что большие и маленькие буквы введены правильно."
                        )
                    else:
                        ctx.bot.send_message(
                            chat_id=update.message.chat_id,
                            text=
                            "Oops, looks like your sending to a user who hasn't registered. Ask them to do /help to register!\nPlease be mindful that usernames are case senstive. Make sure that the case of the target is correct."
                        )
                else:
                    if user["username"] == target:
                        if checkRus(chatid):
                            ctx.bot.send_message(
                                chat_id=update.message.chat_id,
                                text="😆 Вы не можете дать себе чаевые!")
                        else:
                            ctx.bot.send_message(
                                chat_id=update.message.chat_id,
                                text="😆 You can't tip yourself!")
                    else:
                        if amount is not None:
                            if isFloat(amount):
                                if float(amount) > float(
                                        config.coin['minFee']):
                                    keyboard = [[
                                        InlineKeyboardButton(
                                            "Yes",
                                            callback_data=
                                            f"Y,{db.getUserID(target)},{amount},{user['id']},t"
                                        ),
                                        InlineKeyboardButton(
                                            "No",
                                            callback_data=
                                            f"N,{target},{amount},{user['id']},t"
                                        )
                                    ]]
                                    reply_markup = InlineKeyboardMarkup(
                                        keyboard)
                                    if checkRus(chatid):
                                        ctx.bot.send_message(
                                            chat_id=update.message.chat_id,
                                            text=
                                            f"Вы собираетесь отправить {amount} {config.coin['ticker']} с дополнительной комиссией в размере {format(float(config.coin['minFee']), '.8f')} YENTEN to @{target}. Пожалуйста, нажмите Yes, чтобы подтвердить",
                                            reply_markup=reply_markup)
                                    else:
                                        ctx.bot.send_message(
                                            chat_id=update.message.chat_id,
                                            text=
                                            f"You are about to send {amount} {config.coin['ticker']} with an additional fee of {format(float(config.coin['minFee']), '.8f')} YENTEN to @{target}. Please click Yes to confirm",
                                            reply_markup=reply_markup)
                                else:
                                    if checkRus(chatid):
                                        ctx.bot.send_message(
                                            chat_id=update.message.chat_id,
                                            text=
                                            "Вы не можете отправлять отрицательные суммы или суммы меньше, чем 0.00001!"
                                        )
                                    else:
                                        ctx.bot.send_message(
                                            chat_id=update.message.chat_id,
                                            text=
                                            "You cannot send negative amounts or amounts less than 0.00001!"
                                        )
                            else:
                                if checkRus(chatid):
                                    ctx.bot.send_message(
                                        chat_id=update.message.chat_id,
                                        text=
                                        "Неверное количество YENTEN. Пожалуйста, попробуйте еще раз"
                                    )
                                else:
                                    ctx.bot.send_message(
                                        chat_id=update.message.chat_id,
                                        text=
                                        "Invalid amount of YENTEN. Please try again"
                                    )
                        else:
                            if checkRus(chatid):
                                ctx.bot.send_message(
                                    chat_id=update.message.chat_id,
                                    text="Сумма не указана!")
                            else:
                                ctx.bot.send_message(
                                    chat_id=update.message.chat_id,
                                    text="Сумма не указана!")
            else:
                ctx.bot.send_message(chat_id=update.message.chat_id,
                                     text="No amount specified!")