Ejemplo n.º 1
0
async def hqplay(ctx, refercode=None):
    if BOT_OWNER_ROLE in [role.name for role in ctx.message.author.roles]:
        global count
        global idk
        user = ctx.message.author.id
        print(refercode)
        embed = discord.Embed(title=f"HQ DAILY CHALLENGE",
                              description="",
                              color=0x73ee57)
        embed.add_field(name="loading... It may take some second",
                        value='🤔🤔',
                        inline=False)
        embed.set_footer(text="Hq Daily challenge")
        x = await ctx.send(embed=embed)
        token_id = []
        ref_list = []

        data = list(number_base.find())
        p = number_base.find()

        for i in data:
            token_id.append(i['userid'])
            ref_list.append(i['username'])
            print(ref_list)
            print(token_id)
        if user in token_id and refercode in ref_list:
            use = user
            p_list = number_base.find_one({
                'userid': use,
                'username': refercode
            })['token']
            if p_list == 'NoneType':
                abed = discord.Embed(title=f"Hq Daily challenge",
                                     description="",
                                     color=0x73ee57)
                abed.add_field(name=f"sorry ",
                               value='its not your account',
                               inline=False)
                await ctx.send(embed=abed)
            else:
                pass
            print(p_list)
            api = HQApi(p_list)

            try:
                offair_id = api.start_offair()['gameUuid']
                print(offair_id)
            except ApiResponseError:
                url = 'https://api-quiz.hype.space/shows/schedule?&type='
                headers = {
                    'authority': 'api-quiz.hype.space',
                    'accept': '*/*',
                    'accept-encoding': 'br, gzip, deflate',
                    'accept-language': 'en-us',
                    'authorization': f'Bearer {p_list}',
                    'user-agent': 'HQ-iOS/159 CFNetwork/975.0.3 Darwin/18.2.0',
                    'x-hq-client': 'iOS/1.5.2 b159',
                    'x-hq-country': 'en',
                    'x-hq-device': 'iPhone11,6',
                    'x-hq-deviceclass': 'phone',
                    'x-hq-lang': 'en',
                    'x-hq-stk': 'MQ==',
                    'x-hq-timezone': 'America/New_York'
                }
                gcheck = requests.get(url, headers=headers).json()
                embed = discord.Embed(title="Hq Daily challenge",
                                      description="",
                                      color=0x73ee57)
                wait1 = gcheck['offairTrivia']['waitTimeMs']
                embed.add_field(name="Hq Daily challenge",
                                value=f'❌ Game already played',
                                inline=False)
                embed.add_field(
                    name="you can't play more game daily challenge right now!!",
                    value=f'use `+hqplay` after **{wait1}** milliseconds ',
                    inline=False)
                embed.set_footer(
                    text="",
                    icon_url=
                    "https://cdn.discordapp.com/attachments/718400433844125767/740953567996805171/e2faa71710f3f99d507f2b42e2a87563.jpg"
                )
                await client.edit_message(x, embed=embed)
                offair_id = api.get_schedule(
                )['offairTrivia']['games'][0]['gameUuid']
                print(offair_id)

            embed = discord.Embed(title=f"HQ DAILY CHALLENGE",
                                  description="",
                                  color=0x73ee57)
            embed.add_field(name="Starting playing",
                            value='waiting..',
                            inline=False)
            embed.set_footer(text="Hq Daily challenge")
            v = await client.edit_message(x, embed=embed)
            await asyncio.sleep(3)
            while True:
                offair = api.offair_trivia(offair_id)
                print("Question {0}/{1}".format(
                    offair['question']['questionNumber'],
                    offair['questionCount']))
                print(offair['question']['question'])

                for answer in offair['question']['answers']:
                    print('{0}. {1}'.format(answer['offairAnswerId'],
                                            answer['text']))
                    answers = [
                        unidecode(answer["text"])
                        for answer in offair['question']["answers"]
                    ]
                lol = random.randint(0, 3)
                q = offair['question']['question']
                #print(base)
                url = 'https://www.dl.dropboxusercontent.com/s/0ea433zcpljtv3j/sitejson.json?dl=0'
                r = requests.get(url)
                a = json.loads(r.text)
                base = {'ques': [], 'right': []}
                for i in a["questionData"]:
                    c = i['question']
                    ok = i['answerCounts']
                    base['ques'].append(c)
                    base['right'].append(ok)
                    basa = base['right']
                if q in base['ques']:
                    on = base['ques'].index(q)
                    print(on)
                    print('yes found in database')
                    x = base = {'ques': q}
                    print(x)
                    ans = basa[on]
                    x = 0
                    for i in ans:
                        print(i)
                        if i['correct'] == True:
                            try:
                                answerdict = answers
                                cor = i['answer']
                                x = answerdict.index(cor)
                                print(x)
                            except ValueError:
                                lol = random.randint(0, 3)
                                answer = api.send_offair_answer(
                                    offair_id, offair['question']['answers'][
                                        lol - 1]['offairAnswerId'])
                            answer = api.send_offair_answer(
                                offair_id, offair['question']['answers'][x]
                                ['offairAnswerId'])
                            ree = answer['seasonXp']['currentPoints']
                            pe = answer['pointsEarned']
                            qm = answer['questionNumber']
                            print(ree)
                            print('You got it right: ' +
                                  str(answer['youGotItRight']))
                            if answer['youGotItRight'] == True:
                                count += 1
                else:
                    print('nope not in database')
                    lol = random.randint(0, 3)
                    answer = api.send_offair_answer(
                        offair_id,
                        offair['question']['answers'][lol -
                                                      1]['offairAnswerId'])
                    el = HQApi(token=p_list)
                    a = el.get_users_me()
                    for i in a['seasonXp']:
                        idk = i['currentPoints']
                    pe = answer['pointsEarned']
                    qm = answer['questionNumber']
                    print('You got it right: ' + str(answer['youGotItRight']))
                    if answer['youGotItRight'] == True:
                        count += 1
                abed = discord.Embed(title=f"Hq Daily challenge",
                                     description=f"{c}",
                                     color=0x73ee57)
                abed.add_field(
                    name=f"<:hhhh:634462529921482762> Username:- {refercode}",
                    value=
                    f'<:hhhh:634462529921482762> Point earned{pe}\n<:hhhh:634462529921482762> Total Points:-{idk}',
                    inline=False)
                abed.add_field(
                    name=f"Question Correct {count}/{offair['questionCount']}",
                    value='\u200b',
                    inline=False)
                abed.set_footer(text="Hq Daily challenges playing now")
                e = await client.edit_message(v, embed=abed)

                if answer['gameSummary']:
                    print(answer['gameSummary'])
                    print('Game ended')
                    print('Earned:')
                    api = HQApi(token=p_list)
                    a = api.get_users_me()
                    coin = a['coins']
                    print('Coins: ' +
                          str(answer['gameSummary']['coinsEarned']))
                    print('Points: ' +
                          str(answer['gameSummary']['pointsEarned']))
                    embed = discord.Embed(title=f"Hq Daily challenge",
                                          description="",
                                          color=0x73ee57)
                    embed.add_field(
                        name=f"✅HQ DAILY CHALLENGE PLAYED {refercode}",
                        value=
                        f"<:disco:634462418344345600>  Discord user:-<@{user}>",
                        inline=False)
                    embed.add_field(
                        name=
                        f"<:hhhh:634462529921482762> Username:-{refercode}",
                        value=
                        f"**<:hhhh:634462529921482762>  Question Correct:-{count}/{offair['questionCount']}\n<:ccccc:634464030446190602> Earned Coins:-{str(answer['gameSummary']['coinsEarned'])}\n<:hhhh:634462529921482762>  Earned Points:-{str(answer['gameSummary']['pointsEarned'])}**",
                        inline=False)
                    embed.add_field(
                        name=f"<:hhhh:634462529921482762> Total Points:-{ree}",
                        value=
                        f"**<:hqcoin:637185641565782026> Total Coins:-{coin}**",
                        inline=False)
                    embed.set_footer(text="")
                    await client.edit_message(e, embed=embed)
                    count = 0
                    break

            else:
                await ctx.send('you didn\'t added any number')
    else:
        await ctx.send('You have no permission')
Ejemplo n.º 2
0
from HQApi import HQApi
from HQApi.exceptions import ApiResponseError

token = "Token"
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'])
    for answer in offair['question']['answers']:
        print('{0}. {1}'.format(answer['offairAnswerId'], answer['text']))
    select = int(input('Select answer [1-3] > '))
    answer = api.send_offair_answer(
        offair_id, offair['question']['answers'][select - 1]['offairAnswerId'])
    print('You got it right: ' + str(answer['youGotItRight']))
    if answer['gameSummary']:
        print('Game ended')
        print('Earned:')
        print('Coins: ' + str(answer['gameSummary']['coinsEarned']))
        print('Points: ' + str(answer['gameSummary']['pointsEarned']))
        break
Ejemplo n.º 3
0
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