Ejemplo n.º 1
0
 def test_serde_client(self):
     """
     Verify basic serialization client
     """
     protocols = [SchemaType.AVRO, SchemaType.PROTOBUF]
     topics = [f"serde-topic-{x.name}" for x in protocols]
     self._create_topics(topics)
     schema_reg = self.redpanda.schema_reg().split(',', 1)[0]
     for i in range(len(protocols)):
         self.logger.info(
             f"Connecting to redpanda: {self.redpanda.brokers()} schema_reg: {schema_reg}"
         )
         client = SerdeClient(self.redpanda.brokers(),
                              schema_reg,
                              protocols[i],
                              topic=topics[i],
                              logger=self.logger)
         client.run(2)
         schema = self._get_subjects_subject_versions_version(
             f"{topics[i]}-value", "latest")
         self.logger.info(schema.json())
         if protocols[i] == SchemaType.AVRO:
             assert schema.json().get("schemaType") is None
         else:
             assert schema.json()["schemaType"] == protocols[i].name
Ejemplo n.º 2
0
import discord
import pyfootball
import http.client
import json

client = discord.Client() #sets the discord client up

connection = http.client.HTTPConnection("api.football-data.org")
headers = { "X-Auth-Token": "49514fb34530408e95aba7f3b49733ad" }
connection.request("GET", "/v2/competitions/DED", None, headers )
response = json.loads(connection.getresponse().read().decode())
print(response)

@client.event
async def on_ready():
    print("We have logged in")

@client.event
async def on_message(message):
    if "!HI" in message.content.upper():
        await message.channel.send("Hello")
    elif "FIND" in message.content.upper() and "TEAM" in message.content.upper(): #not completed yet
        for letter in message.content:
            print(letter) #testing the loop
        teamToSearch = message.content
        teams = f.search_teams()
        print(teams)

client.run("Filler")
Ejemplo n.º 3
0
async def on_message(message):
    if message.content.startswith('!test'):
        await client.send_message(message.channel, 'Working.')
    if message.content.startswith('!as'):
        await client.send_message(
            message.channel, ':arrows_counterclockwise: Checking prices...')
        content_price = []
        for x in range(0, len(message.content)):
            content_price.append(message.context[x])
            print(content_price)
    if message.content.startswith('!price'):
        new_message = []
        for x in range(0, len(message.content)):
            new_message.append(message.content[x])
        for o in range(0, 7):
            new_message.remove(new_message[0])
        message_final = ''
        for z in range(0, len(new_message)):
            message_final += new_message[z]
            message_finala = '**:arrows_counterclockwise: Checking prices for: ' + '`' + message_final + '`**'
        await client.send_message(message.channel, message_finala)
        url = 'https://rl.insider.gg/pc/' + message_final
        await client.send_message(message.channel, url)
        ourUrl = opener.open(url).read()
        soup = BeautifulSoup(ourUrl)
        body = soup.find(text=message_final).findnext('h1')
        print(body)


client.run('MzczNjYzMjE3OTQ1MjgwNTEy.DN63iA.USaOXi2RmiNAJPCufYjy8NtACpg')
Ejemplo n.º 4
0
        # If it is a new day, reset calls count to 0
        timer.check(current, calls)
        # Connect to word API with correct headers
        conn = http.client.HTTPSConnection("wordsapiv1.p.rapidapi.com")
        headers = {
            'x-rapidapi-host': "wordsapiv1.p.rapidapi.com",
            'x-rapidapi-key': KEY
        }
        conn.request("GET", "/words/?random=true", headers=headers)
        # Decode UTF8 response
        res = conn.getresponse()
        data = res.read().decode("utf-8")
        # Create JSON object from data
        try:
            js = json.loads(data)
        except:
            js = None
        # Respond with random word
        word = js["word"]
        await message.channel.send(word)
        # Increment calls and set current to new js['dayOfTheWeek']
        calls += 1
        current = timer.current()
        # If call limit is reached, exit the bot
        if calls >= 2500:
            await message.channel.send("API limit has been reached")
            exit()


client.run(TOKEN)
Ejemplo n.º 5
0
    time = datetime.today().strftime('%Y-%m-%d-%H:%M:%S')
    timeanduser = name + " " + "•" + " " + time
    tckmsg = "Dear **{}**, \n\nThanks for reaching out to us, we'll do our best to respond to your question as soon as possible. You can leave any extra information in this channel if needed.".format(mention)
    num = random.randint(0,1000000000000000000)
    ticket = "ticket-" + str(num)
    guilds = ctx.message.guild
    nameofcat = cat
    category = discord.utils.get(ctx.guild.categories, name=nameofcat)
    await guilds.create_text_channel(ticket, overwrites=overwrites, category=category)
    channel = discord.utils.find(lambda c: c.name == str(ticket), guilds.text_channels)
    if channel is not None:
        embed = discord.Embed(
            title  = "Support Ticket",
            description = tckmsg,
            colour = discord.Colour.blue()
        )
        embed.set_footer(text=timeanduser)
        embed.add_field(name='**Ticket Reason**', value=arg, inline=False)
        txtchannel =  client.get_channel(channel.id)
        await txtchannel.send(embed=embed)
        msgticket = "new #{} was created by {}".format(ticket, name)
        for members in client.get_all_members():
            for role in members.roles:
                if role.name == "Admin":
                    await members.send(msgticket)




client.run(token)
Ejemplo n.º 6
0
def setup():
    client.run("redacted")
Ejemplo n.º 7
0
        for i in range(len(translation)):
            word_list.update({index: translation[i]})
    await ctx.send(word_list)


# @client.command()
# async def lama(ctx,*,arg):
#     DIR = 'C:\\Users\\magge\\Desktop\\Atom\\Mattek_3\\Lama\\'+arg
#     img = choice(os.listdir(DIR))
#     await ctx.send(file=discord.File(sassy_socialist_meme())


@client.command()
async def clear(ctx, amount=10):
    await ctx.channel.purge(limit=amount)


@client.command()
async def ss_meme(ctx):
    await ctx.send(file=discord.File(sassy_socialist_meme()))


#url_object = urllib.request('https://matchilling-chuck-norris-jokes-v1.p.rapidapi.com/jokes/random')
#dict = json.load(url_object)

#@client.command(aliases=['chuck'])
#async def chuck_norris(ctx):
#    await ctx.send(dict)

client.run('NTkzMzcxOTg3OTAwODkxMTU3.XRM66g.0qLLKEN6WRrGjAL8sApC9t_WoBg')
Ejemplo n.º 8
0
@client.command(pass_context=True, aliases=['r', 'res'])
async def resume(ctx):

    voice = get(client.voice_clients, guild=ctx.guild)

    if voice and voice.is_paused():
        print("Resumed music")
        voice.resume()
        await ctx.send("Resumed music")
    else:
        print("Music is not paused")
        await ctx.send("Music is not paused")


@client.command(pass_context=True, aliases=['s', 'sto'])
async def stop(ctx):

    voice = get(client.voice_clients, guild=ctx.guild)

    if voice and voice.is_playing():
        print("Music stopped")
        voice.stop()
        await ctx.send("Music stopped")
    else:
        print("No music playing failed to stop")
        await ctx.send("No music playing failed to stop")


client.run('NzM2MjQ2NjYzMTg1ODI1ODYy.XxsBIw.1Ky8LN7NLzNF9WuKIt2mPEh2MGY')
Ejemplo n.º 9
0
                msg = cinema['cinemas'][z]['name'].format(message)
                await client.send_message(message.channel, msg)
                z = z + 1

    if message.content.startswith('!editme'):
        msg = await client.send_message(message.author, '10')
        await asyncio.sleep(3)
        await client.edit_message(msg, '40')


@client.event
async def on_message_edit(before, after):
    fmt = '**{0.author}** edited their message:\n{1.content}'
    await client.send_message(after.channel, fmt.format(after, before))


@bot.command()
async def add(left: int, right: int):
    await bot.say(left + right)


@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')


client.run('NTAzOTgyNDA4MTQwMzI0ODY1.Dq-1Jw.lOYHE8LSpXpOjuaRD7qW8KAbZYM')
Ejemplo n.º 10
0
        try:
            navigation_timing = self._browser.execute_script(
                "return performance.getEntriesByType('navigation');")
            resource_timing = self._browser.execute_script(
                "return performance.getEntriesByType('resource');")
        except WebDriverException as e:
            navigation_timing = []
            resource_timing = []

        for entry in navigation_timing + resource_timing:
            if "toJSON" in entry:
                del (entry["toJSON"])

        return {
            "timing": timing,
            "navigation_timing": navigation_timing,
            "resource_timing": resource_timing
        }

    # TODO
    # add interaction methods like clicking and text entering


if __name__ == '__main__':

    from clients.StandaloneClient import StandaloneClient

    # start client
    client = StandaloneClient.StandaloneClient(client_class=WebClient)
    client.run()
Ejemplo n.º 11
0
 def handle(self, *args, **kwargs):
     client.run(settings.DISCORD_BOT_TOKEN)
Ejemplo n.º 12
0
                if b"Could not find comic" not in d:

                    imgstart = d.find(b"src=\"//", d.find(b"main-comic")) + 7
                    imgend = d.find(b"\"", imgstart)
                    img = str(d[imgstart:imgend], 'utf-8')
                    data["comics"][currId] = "http://" + img

                    try:
                        urllib.request.urlretrieve(
                            data["comics"][currId],
                            "/home/images/" + str(currId) + ".png")
                    except Exception as e:
                        print(e)
                        print("Failed to download comic :( (" +
                              data["comics"][currId] + ")")

                    print("Downloading comic " + str(i))

                else:
                    data["comics"][currId] = "not_found"
                    print("Comic " + str(i) + " not found :/")

                saveData()

    print("Connecting")

    client.run(data["apikey"])
else:
    print(
        "Could not find save data (candh.json). Creating now. Please fill in the apikey and then restart."
    )
Ejemplo n.º 13
0
            else:
                await message.channel.send("Please set an ID")



        



        if message.content == ".ranks":
            conn = createConn()
            c = conn.cursor()
            c.execute('SELECT * FROM users WHERE discordID = "%s"' % message.author)
            result = c.fetchone()
            conn.close()
            if result:
                await message.channel.send("Fetching...")
                await getImg(result[1], message.channel)
            else:
                await message.channel.send("Your steamID64 is not set! Please set it using the .setid command.")







client = MyClient()
client.run('Njk1NTg2NzQ1MTc3MDc5ODA4.XoeUog.isBoswCZjHICDIi5q_ev5hAf6h8')

Ejemplo n.º 14
0
    await ctx.send(response)
    await ctx.send(file=discord.File(gif_resp))


@client.command()
async def clear(ctx, amount=10):
    await ctx.channel.purge(limit=amount)


@client.command()
async def sam(ctx):
    await ctx.send(file=discord.File(Get_gif()))


@client.command()
async def roast(ctx):
    await ctx.send(file=discord.File(gif_roast()))


@client.command()
async def chuck(ctx):
    await ctx.send(chuck_norris_joke())


@client.command()
async def sam_swears(ctx):
    await ctx.send("!myswears")


client.run('NTk0NzgwNzczNzkwNTE1MjEx.XRjY0Q.OalDUkXYCOQiQhNM2Xh0zmB1t-0')
Ejemplo n.º 15
0
                    await client.send_message(message.channel,
                                              msg[2],
                                              embed=msg[0])
                    await client.send_message(message.channel, embed=msg[1])
                else:
                    await client.send_message(message.channel,
                                              msg[1],
                                              embed=msg[0])
                return
            elif message.content.lower().startswith("w!cmds"):
                e_msg = discord.Embed()
                e_msg.add_field(
                    name="w!stats [region] [handle] ('recent'): ",
                    value=
                    "See a PUBG player's (recent) stats from a specifc region.\n\n"
                    "Region codes:\n"
                    "-SEA: Southeast Asia\n-AS: Asia\n-NA: North America\n"
                    "-EU: Europe\n-OC: Oceania.",
                    inline=True)
                return await client.send_message(
                    message.channel,
                    "List of WaiterBot commands: ",
                    embed=e_msg)
            return
    except Exception as e:
        traceback.print_exc()
    return


client.run('NDA1NzEwNzY4OTc4NTI2MjA4.DUoXbA.YKgLUl9cqfgB5VqoAkAbCJKaRQI')