Beispiel #1
0
async def post_to_webhook(new_tweet: Tweet):
    start_time = time.time()
    url = "https://discordapp.com/api/webhooks/644694815094734848/Y9Ixa2Wh7xpF7uQzbzX8uua-cERYWbtyoD3Xg8-7NJmUl47UTN_IF-QD5W_W-3oymtdy"
    text = new_tweet.text
    webhook = Webhook.Async(url)
    embed = Embed(
        title=f"Link to tweet",
        url=
        f"https://twitter.com/{new_tweet.created_by.screen_name}/status/{new_tweet.id}"
    )
    embed.set_author(
        name=f"New tweet from {new_tweet.created_by.screen_name}",
        url=f'https://twitter.com/{new_tweet.created_by.screen_name}',
        icon_url=new_tweet.created_by.profile_image_url)
    for mentioned_user in new_tweet.mentioned_users:
        text = text.replace(
            f"@{mentioned_user.screen_name}",
            f"[@{mentioned_user.screen_name}](https://twitter.com/{mentioned_user.screen_name})"
        )
    embed.add_field(name="Content: ", value=text, inline=True)
    for url in new_tweet.links_in_tweet:
        embed.add_field(name="Link Found: ", value=f"{url.url}")
    embed.set_footer(text=f'Monitor by ike_on')
    await webhook.send(embed=embed)
    print(f"Took {time.time() - start_time} seconds to send to webhook")
    for url in new_tweet.links_in_tweet:
        if ("discord" in url.url):
            await webhook.send(f"Possible discord invite found: {url.url}")
    await webhook.close()
Beispiel #2
0
 async def post_to_webhook(self, new_tweet: Tweet):
     start_time = time.time()
     text = new_tweet.text
     webhook = Webhook.Async(self.webhookURL)
     embed = Embed(
         title=f"Link to tweet",
         url=
         f"https://twitter.com/{new_tweet.created_by.screen_name}/status/{new_tweet.id}"
     )
     embed.set_author(
         name=f"New tweet from {new_tweet.created_by.screen_name}",
         url=f'https://twitter.com/{new_tweet.created_by.screen_name}',
         icon_url=new_tweet.created_by.profile_image_url)
     for mentioned_user in new_tweet.mentioned_users:
         text = text.replace(
             f"@{mentioned_user.screen_name}",
             f"[@{mentioned_user.screen_name}](https://twitter.com/{mentioned_user.screen_name})"
         )
     embed.add_field(name="Content: ", value=text, inline=True)
     for url in new_tweet.links_in_tweet:
         embed.add_field(name="Link Found: ", value=f"{url.url}")
     embed.set_footer(
         text=
         f'Monitor by ike_on not recursive {datetime.now().strftime("%I:%M:%S.%f %p")}'
     )
     await webhook.send(embed=embed)
     print(f"Took {time.time() - start_time} seconds to send to webhook")
     for url in new_tweet.links_in_tweet:
         if ("discord" in url.url):
             await webhook.send(f"Possible discord invite found: {url.url}")
     await webhook.close()
Beispiel #3
0
async def init(app, loop):
    """Sends a message to the webhook channel when server starts."""
    app.session = aiohttp.ClientSession(loop=loop)  # to make web requests
    app.webhook = Webhook.Async(webhook_url, session=app.session)

    em = Embed(color=0x2ecc71)
    em.set_author('[INFO] Starting Worker')
    em.description = 'Host: {}'.format(socket.gethostname())

    await app.webhook.send(embed=em)
Beispiel #4
0
async def server_begin(app, loop):
    app.ctx.db = AsyncPostgresDB(user=Config.DB_USERNAME,
                                 password=Config.DB_PASSWORD,
                                 host=Config.DB_HOST,
                                 port=Config.DB_PORT,
                                 db_name=Config.DB_NAME,
                                 loop=loop)

    await app.ctx.db.init()
    app.ctx.sse_token = await app.ctx.db.fetchval(
        'SELECT token from auth_tokens')
    webhook_url = await app.ctx.db.fetchval('SELECT url FROM webhook_url')
    app.ctx.session = aiohttp.ClientSession(loop=loop)
    app.ctx.webhook = Webhook.Async(webhook_url, session=app.ctx.session)
Beispiel #5
0
async def init(app, loop):
    app.secret = config.SECRET
    app.session = aiohttp.ClientSession(
        loop=loop)  # we use this to make web requests
    app.webhook = Webhook.Async(config.WEBHOOK_URL, session=app.session)
    app.db = AsyncIOMotorClient(config.MONGO_URI).majorproject
    app.users = UserBase(app)

    em = Embed(color=Color.green)
    em.set_author('[INFO] Starting Worker', url=app.ngrok_url)
    em.set_footer(f'Host: {socket.gethostname()}')
    em.add_field('Public URL', app.ngrok_url) if app.ngrok_url else ...

    await app.webhook.send(embed=em)
Beispiel #6
0
    async def relay(self, message: Message):
        d_webhookurl = self.settings["d_webhookurl"]
        embed_hook = self.settings["embed_hook"]
        roomname = self.bot_settings.roomname

        botnick = self.bot_settings.nickname
        msgprofile = message.sender.username
        msgnick = message.handle
        msg = message.message

        jumpinurl = f"https://jumpin.chat/{roomname}"
        giticon = "https://image.flaticon.com/icons/png/512/25/25231.png"
        jprofilepic = f"https://s3.amazonaws.com/jic-uploads/room-display/display-{roomname}.png"

        async with Webhook.Async(
            url=d_webhookurl,
            username="******",
            avatar_url=jprofilepic,
        ) as hook:
            if embed_hook and msgnick != botnick or None:
                em = Embed(
                    title=roomname.title,
                    url=jumpinurl,
                    timestamp="now",
                    color="#00FF00",
                    image_url="https://i.imgur.com/BiUki4F.png",
                    thumbnail_url=jprofilepic,
                )
                em.set_footer(text="via git.io/QuantumJump", icon_url=giticon)
                if msgnick != botnick:
                    em.add_field(
                        name=f"**__{msgnick}__** ({msgprofile}):",
                        value=f"`{msg}`",
                        inline=False,
                    )
                # await hook.send(embeds=[em])
            elif embed_hook is False and msgnick != botnick or None:
                await asyncio.sleep(1.2)
                await hook.send(f"**__{msgnick}__** ({msgprofile}): `{msg}`")
            else:
                raise Exception("WEBHOOK FAILED TO SEND! PLEASE REPORT REPEATED ISSUES WITH CONTEXT!")