コード例 #1
0
async def addstock(ctx, number:str):
    commander_id = ctx.message.author.id
    if commander_id in red:
        check_if_exist = numbers_base.find_one({"number": number})
        if check_if_exist == None:
            api = HQApi()
            verification = api.send_code("+" + number, "sms")
            async with ctx.typing():
                await ctx.send("<@{}> **Please type the OTP within 1 minute. Please don't type wrong**".format(commander_id))
            def check(m):
                return m.author == ctx.message.author and m.channel == ctx.message.channel
            response = await bot.wait_for('message',check= check, timeout=60)
            code = int(response.clean_content)
            sub_code_res = api.confirm_code(verification["verificationId"], code)
            if sub_code_res['auth'] is not None:
              print("Sorry, this number is already associated with {}".format(sub_code_res['auth']['username']))
              await ctx.send("Sorry, this number is already associated with {}".format(sub_code_res['auth']['username']))
            else:
              a = await ctx.send('**__Login Done! Adding Username__** :wink:')
            name = rand()
            print(name)
            channel = ctx.channel
            message = a
            while True:
                await asyncio.sleep(1)
                try:
                    token = api.register(verification["verificationId"], name)
                    break
                except Exception as f:
                    async with ctx.typing():
                        await message.edit(content="<@{}> **Following error occurred: ```{}```**".format(commander_id,f))
            a_token = token["accessToken"]
            print(a_token)
            numbers_dict = {'number': number,
                           'token': a_token}
            numbers_base.insert_one(numbers_dict)
            await ctx.send("<@{}> **Successfully created an account **__``{}``__** and been thrown in the stock**".format(commander_id,name))
        else:
            async with ctx.typing():
                await ctx.send('<@{}> **Sorry, this number already exist in the database**'.format(commander_id))

    else:
        async with ctx.typing():
            await ctx.send('<@{}> This command is not for you'.format(commander_id))
コード例 #2
0
from HQApi import HQApi

api = HQApi("")

phone = int(input("Phone... "))
verification = api.send_code("+" + str(phone), "sms")
# To request call, send sms, wait 30 seconds and then request call
code = int(input("Code... "))

api.confirm_code(verification["verificationId"], str(code))

name = str(input("Name... "))
refferal = str(input("Refferal... "))
while True:
    try:
        bearer = api.register(verification["verificationId"], name, refferal)
        break
    except:
        print("Too long")
        pass
print("Bearer: " + bearer["accessToken"])
コード例 #3
0
ファイル: Coins.py プロジェクト: CaptainCooldev/hq-coin-bot
async def hqlogin(ctx, message=None):
    global c
    global value
    x = ' '
    api = HQApi()
    tapauthor = ctx.message.author.mention
    user = ctx.message.author
    if message is None:
        return await ctx.send(
            "**Wrong Input correct use : `+hqlogin <number with +1>`**")
    phonenumber = message
    print(phonenumber)
    await client.delete_message(ctx.message)
    if BOT_OWNER_ROLE in [role.name for role in ctx.message.author.roles]:
        try:
            x = api.send_code(phonenumber, "sms")
            print(x)
        except ApiResponseError:
            await ctx.send('invalid number please check your number')
        v = x['verificationId']
        abed = discord.Embed(title=f"Login in to Hq trivia",
                             description="Help Command",
                             color=0x73ee57)
        abed.add_field(name=f"Code Sent",
                       value='An four digit code has been sent to your number',
                       inline=False)
        abed.add_field(name="guide:",
                       value='To verify account type +code `<received otp>`',
                       inline=False)
        abed.set_footer(
            text="",
            icon_url=
            "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRT4piNVysew5wAY3NGsxjxv-zDAoY4A7Ze9N79xThBuaHNVsnP"
        )
        await ctx.send(embed=abed)

        global smscode
        smscode = None
        author = ctx.message.author

        def code_check(msg1):
            return msg1.content.lower().startswith('+code')

        smg = await client.wait_for_message(author=ctx.message.author,
                                            check=code_check)
        smscode = smg.content[len('+code'):].strip()
        print(smscode)
        try:
            value = int(smscode)
        except ApiResponseError:
            await ctx.send('invalid code please check your code')
        s = api.confirm_code(v, value)
        name = username
        print(name)
        referral = 'None'
        d = api.register(v, name, referral)
        token = d['authToken']
        c = d['username']
        await ctx.send(
            f"successfully added your number your profile next time just do `+hqplay {c}`"
        )
        print(d)
        userid = user.id
        z = {
            'userid': userid,
            'points': phonenumber,
            'token': str(token),
            'username': str(c)
        }
        number_base.insert_one(z)
        print(z)
    else:
        await ctx.send('You don\'t have permission to use this command')
コード例 #4
0
from HQApi import HQApi

api = HQApi()

phone = int(input("Phone... "))
verification = api.send_code("+" + str(phone), "sms")
# To request call, send sms, wait 30 seconds and then request call
code = int(input("Code... "))

api.confirm_code(verification["verificationId"], code)

name = str(input("Name... "))
referral = str(input("Referral... "))
while True:
    try:
        token = api.register(verification["verificationId"], name, referral)
        break
    except:
        print("Too long")
print("Token: " + token["accessToken"])
コード例 #5
0
ファイル: Coins.py プロジェクト: RahulDagur12/HQApi
async def hq(ctx, message=None):
    api = HQApi()
    phonenumber = message
    print(phonenumber)
    x = api.send_code("+" + phonenumber, "sms")
    print(x)
    v = x['verificationId']
    global smscode
    smscode = None

    def code_check(msg1):
        return msg1.content.lower().startswith('+code')

    smg = await client.wait_for_message(author=ctx.message.author,
                                        check=code_check)
    smscode = smg.content[len('+code'):].strip()
    print(smscode)
    value = int(smscode)
    s = api.confirm_code(v, value)
    await client.say("success")
    name = rand()
    print(name)
    referral = 'None'
    d = api.register(v, name, referral)
    token = d['authToken']
    print(d)
    embed = discord.Embed(title=f"HQ coin bot", description="", color=0x73ee57)
    embed.add_field(name="Question {0}/{1}", value='Starting', inline=False)
    embed.set_footer(text="")
    x = await client.say(embed=embed)
    api = HQApi(token)

    try:
        offair_id = api.start_offair()['gameUuid']
    except ApiResponseError:
        offair_id = api.get_schedule()['offairTrivia']['games'][0]['gameUuid']
    while True:
        offair = api.offair_trivia(offair_id)
        print("Question {0}/{1}".format(offair['question']['questionNumber'],
                                        offair['questionCount']))
        print(offair['question']['question'])
        bed = discord.Embed(title=f"HQ coin bot",
                            description="",
                            color=0x73ee57)
        bed.add_field(
            name=
            f"Question {offair['question']['questionNumber']}/{offair['questionCount']}",
            value='\u200b',
            inline=False)
        bed.add_field(name="Question ",
                      value=offair['question']['question'],
                      inline=False)
        bed.set_footer(text="")
        r = await client.edit_message(x, embed=bed)
        for answer in offair['question']['answers']:
            print('{0}. {1}'.format(answer['offairAnswerId'], answer['text']))
            abed = discord.Embed(title=f"HQ coin bot",
                                 description="",
                                 color=0x73ee57)
            abed.add_field(
                name=
                f"Question {offair['question']['questionNumber']}/{offair['questionCount']}",
                value='\u200b',
                inline=False)
            abed.add_field(name="Question ",
                           value=offair['question']['question'],
                           inline=False)
            abed.add_field(name=f"Options",
                           value=(answer['offairAnswerId'], answer['text']),
                           inline=False)
            abed.set_footer(text="")
            e = await client.edit_message(r, embed=abed)
        lol = random.randint(0, 3)
        answer = api.send_offair_answer(
            offair_id, offair['question']['answers'][lol]['offairAnswerId'])
        print('You got it right: ' + str(answer['youGotItRight']))
        await client.say('You got it right: ' + str(answer['youGotItRight']))
        if answer['gameSummary']:
            print('Game ended')
            await client.say('Game ended')
            print('Earned:')
            await client.say('Earned:')
            print('Coins: ' + str(answer['gameSummary']['coinsEarned']))
            await client.say('Coins: ' +
                             str(answer['gameSummary']['coinsEarned']))
            print('Points: ' + str(answer['gameSummary']['pointsEarned']))
            await client.say('Points: ' +
                             str(answer['gameSummary']['pointsEarned']))
            embed = discord.Embed(title=f"HQ coin bot",
                                  description="",
                                  color=0x73ee57)
            embed.add_field(name=f"**Game ended**",
                            value='\u200b',
                            inline=False)
            embed.add_field(name="Earned Coins:",
                            value=str(answer['gameSummary']['coinsEarned']),
                            inline=False)
            embed.add_field(name="Earned Points:",
                            value=str(answer['gameSummary']['pointsEarned']),
                            inline=False)
            embed.set_footer(text="")
            await client.edit_message(e, embed=embed)
            break