Example #1
0
def quest_mon_var(monid, mon, shiny, typeid, formid):
    mariadb_connection = mariadb.connect(user=user,
                                         password=passwd,
                                         database=database,
                                         host=host)
    cursor = mariadb_connection.cursor()
    query = (
        "select CONVERT(pokestop.name USING UTF8MB4) as pokestopname,pokestop.latitude,pokestop.longitude,quest_task from pokestop inner join trs_quest on pokestop.pokestop_id = trs_quest.GUID where quest_pokemon_id ="
        + monid + " and quest_pokemon_form_id =" + typeid +
        " and ST_CONTAINS(ST_GEOMFROMTEXT('POLYGON((" + area +
        "))'), point(pokestop.latitude, pokestop.longitude))")
    cursor.execute(query)
    name = cursor.fetchall()

    if not name:
        print("no quests for " + mon)
    else:
        #convert data into string
        res = [tuple(str(ele) for ele in sub) for sub in name]
        webhook = DiscordWebhook(url=webhookurl)
        # create embed object for webhook
        research = ''
        for stop in res:
            research += ('[' + stop[0] + ']('
                         'https://www.google.com/maps/search/?api=1&query='
                         '' + stop[1] + ',' + stop[2] + ')' + ' ' + stop[3] +
                         '\n')
            if len(research) > 1900:
                print("larger then 2048 breaking up")
                print(mon + " Length:", len(research))
                embed = DiscordEmbed(title=shiny + mon + ' Field Research' +
                                     shiny,
                                     description=research,
                                     color=16777011)
                embed.set_thumbnail(
                    url=
                    'https://raw.githubusercontent.com/whitewillem/PogoAssets/resized/no_border/pokemon_icon_'
                    + monid + '_' + formid + '.png')
                embed.set_footer(text='Research by ' + author)
                #add embed object to webhook
                webhook.add_embed(embed)
                webhook.execute()
                research = ''
                webhook.remove_embed(0)
                time.sleep(2)

        print(mon + " Length:", len(research))
        embed = DiscordEmbed(title=shiny + mon + ' Field Research' + shiny,
                             description=research,
                             color=16777011)
        embed.set_thumbnail(
            url=
            'https://raw.githubusercontent.com/whitewillem/PogoAssets/resized/no_border/pokemon_icon_'
            + monid + '_' + formid + '.png')
        embed.set_footer(text='Research by ' + author)
        #add embed object to webhook
        webhook.add_embed(embed)
        webhook.execute()
        research = ''
        time.sleep(2)
def discord_webhook(callsign, name, cid, rating_long, server, status):

    webhook = DiscordWebhook(url=webhookurl)

    if status == "online":
        embed = DiscordEmbed(title=callsign + " - Online", description=callsign + ' is now online on the VATSIM network.', color=65290)
        embed.set_footer(text='ZDC VATSIM Notify Bot ' + version, icon_url='https://vzdc.org/photos/discordbot.png')
        embed.set_thumbnail(url='https://vzdc.org/photos/logo.png')
        embed.set_timestamp()
        embed.add_embed_field(name='Name', value=name)
        embed.add_embed_field(name='Rating', value=rating_long)
        embed.add_embed_field(name='CID', value=cid)
        embed.add_embed_field(name='Callsign', value=callsign)
        embed.add_embed_field(name='Server', value=server)

        webhook.add_embed(embed)
        webhook.execute()
        webhook.remove_embed(0)
        
    else:
        embed = DiscordEmbed(title=callsign + " - Offline", description=callsign + ' is now offline on the VATSIM network.', color=16711683)
        embed.set_footer(text='ZDC VATSIM Notify Bot ' + version, icon_url='https://vzdc.org/photos/discordbot.png')
        embed.set_thumbnail(url='https://vzdc.org/photos/logo.png')
        embed.set_timestamp()
        #embed.add_embed_field(name='Name', value=name)
        #embed.add_embed_field(name='Rating', value=rating_long)
        #embed.add_embed_field(name='CID', value=cid)
        #embed.add_embed_field(name='Callsign', value=callsign)
        #embed.add_embed_field(name='Server', value=server)

        webhook.add_embed(embed)
        webhook.execute()
        webhook.remove_embed(0)
Example #3
0
def rocket(leader, lname, sprite, guide):
    mariadb_connection = mariadb.connect(user=user,
                                         password=passwd,
                                         database=database,
                                         host=host,
                                         port=port)
    cursor = mariadb_connection.cursor()
    query = (
        "select CONVERT(pokestop.name USING UTF8MB4) as pokestopname,pokestop.latitude,pokestop.longitude from pokestop WHERE incident_grunt_type = "
        + leader + " and ST_CONTAINS(ST_GEOMFROMTEXT('POLYGON((" + area +
        "))'), point(pokestop.latitude, pokestop.longitude))")
    cursor.execute(query)
    name = cursor.fetchall()

    if not name:
        print("Leader not Found: " + lname)
    else:
        #convert data into string
        res = [tuple(str(ele) for ele in sub) for sub in name]
        res.sort()
        webhook = DiscordWebhook(url=webhookurlr)
        # create embed object for webhook
        research = ''
        for stop in res:
            research += ('[' + stop[0] + ']('
                         'https://maps.google.com/?q='
                         '' + stop[1] + ',' + stop[2] + ')' + '\n')
            if len(research) > 1900:
                print("larger then 2048 breaking up")
                print(lname + " Length:", len(research))
                embed = DiscordEmbed(title='Leader: ' + lname,
                                     description=research,
                                     color=3158064,
                                     url=guide)
                embed.set_thumbnail(url=sprite)
                embed.set_footer(text='Leader Locations by: ' + author)
                embed.set_author(name=lname + ' Counters Guide Link',
                                 url=guide)
                #add embed object to webhook
                webhook.add_embed(embed)
                webhook.execute()
                research = ''
                webhook.remove_embed(0)
                time.sleep(2)

        print(lname + " Length:", len(research))
        embed = DiscordEmbed(title='Leader: ' + lname,
                             description=research,
                             color=3158064,
                             url=guide)
        embed.set_thumbnail(url=sprite)
        embed.set_footer(text='Leader Locations by: ' + author,
                         icon_url=footerimg)
        embed.set_author(name=lname + ' Counters Guide Link', url=guide)
        #add embed object to webhook
        webhook.add_embed(embed)
        webhook.execute()
        research = ''
        time.sleep(2)
Example #4
0
def quest_stardust(itemid, item, sprite):
    mariadb_connection = mariadb.connect(user=user,
                                         password=passwd,
                                         database=database,
                                         host=host)
    cursor = mariadb_connection.cursor()
    query = (
        "select CONVERT(pokestop.name USING UTF8MB4) as pokestopname,pokestop.latitude,pokestop.longitude,trs_quest.quest_task,if(trs_quest.quest_stardust>999,trs_quest.quest_stardust, null) from pokestop inner join trs_quest on pokestop.pokestop_id = trs_quest.GUID where quest_pokemon_id = "
        + itemid +
        " and DATE(FROM_UNIXTIME(trs_quest.quest_timestamp)) = CURDATE() and if(trs_quest.quest_stardust>999,trs_quest.quest_stardust, null) is not null and ST_CONTAINS(ST_GEOMFROMTEXT('POLYGON(("
        + area + "))'), point(pokestop.latitude, pokestop.longitude))")
    cursor.execute(query)
    name = cursor.fetchall()

    if not name:
        print("no quests for " + item)
    else:
        #convert data into string
        res = [tuple(str(ele) for ele in sub) for sub in name]
        webhook = DiscordWebhook(url=webhookurl)
        # create embed object for webhook
        research = ''
        for stop in res:
            research += ('[' + stop[0] + ']('
                         'https://www.google.com/maps/search/?api=1&query='
                         '' + stop[1] + ',' + stop[2] + ')' + ' ' + stop[3] +
                         ' - Amount: ' + stop[4] + '\n')
            if len(research) > 1900:
                print("larger then 2048 breaking up")
                print(item + " Length:", len(research))
                embed = DiscordEmbed(title=item + ' Field Research',
                                     description=research,
                                     color=16711931)
                embed.set_footer(text='Research by ' + author)
                embed.set_thumbnail(url=sprite)
                #add embed object to webhook
                webhook.add_embed(embed)
                webhook.execute()
                research = ''
                webhook.remove_embed(0)
                time.sleep(2)
        print(item + " Length:", len(research))
        embed = DiscordEmbed(title=item + ' Field Research',
                             description=research,
                             color=16711931)
        embed.set_footer(text='Research by ' + author)
        embed.set_thumbnail(url=sprite)
        #add embed object to webhook
        webhook.add_embed(embed)
        webhook.execute()
        research = ''
        time.sleep(2)
Example #5
0
def ad():
 if not adbody:
  print ("no Ad to Display")
 else:
  print ("Ad found")
  webhook = DiscordWebhook(url=webhookurl)
  # create embed object for webhook 
  embed = DiscordEmbed(title=adtitle, description=adbody, color=16711931)
  embed.set_footer(text='Research by '+author, icon_url=footerimg)
  embed.set_thumbnail(url=adthumb) 
  #add embed object to webhook
  webhook.add_embed(embed)
  webhook.execute()
  research = ''
  webhook.remove_embed(0)
  time.sleep(2)
Example #6
0
def update_discord(new, extra, webhook_url):
    webhook = DiscordWebhook(url=webhook_url)
    for i in new:
        embed = DiscordEmbed(title='{}({})'.format(new[i]['name'],
                                                   new[i]['color']),
                             description='id: {}'.format(i),
                             color=7395813,
                             timestamp=new[i]['date'])

        embed.set_thumbnail(url=new[i]['image'])

        embed.set_footer(
            text="Lacuh time",
            icon_url="https://cdn.discordapp.com/embed/avatars/0.png")
        embed.set_image(url=new[i]['image'])
        embed.add_embed_field(name="Lauch Method",
                              value="{}".format(new[i]['publishType']))
        embed.add_embed_field(name="Price",
                              value="${}\n".format(new[i]['price']))
        embed.add_embed_field(name='Product Type', value=new[i]['type'])
        webhook.add_embed(embed)
        webhook.execute()
        webhook.remove_embed(0)
        time.sleep(3)
    for i in extra:
        embed = DiscordEmbed(title=extra[i]['name'],
                             description='id: {}'.format(i),
                             color=7395813,
                             timestamp=extra[i]['date'])
        embed.set_image(url=extra[i]['image'])
        embed.set_footer(
            text='Published time',
            icon_url="https://cdn.discordapp.com/embed/avatars/0.png")
        embed.set_thumbnail(url=extra[i]['image'])
        embed.add_embed_field(name='detail', value=extra[i]['desc'])
        webhook.add_embed(embed)
        webhook.execute()
        webhook.remove_embed(0)
        time.sleep(3)
class DiscordMessenger:
    def __init__(self, webhook_url):
        self.webhook = DiscordWebhook(url=webhook_url, username="******")
        self.website_url = 'https://futurarchives.com/password'

    def send_warning_message(self, message):
        embed = DiscordEmbed(title="Warning Message",
                             description=message,
                             color=242424)
        embed.set_timestamp()
        self.webhook.add_embed(embed)
        self.webhook.execute()
        self.remove_embeds_from_webhook()

    def send_store_open_message(self):
        embed = DiscordEmbed(title="Store Update",
                             description="Store is now open",
                             color=242424)
        embed.add_embed_field(name="Website Link", value=self.website_url)
        embed.set_timestamp()
        self.webhook.add_embed(embed)
        self.webhook.execute()
        self.remove_embeds_from_webhook()

    def send_store_closed_message(self):
        embed = DiscordEmbed(title="Store Update",
                             description="Store is closed",
                             color=242424)
        embed.add_embed_field(name="Website Link", value=self.website_url)
        embed.set_timestamp()
        self.webhook.add_embed(embed)
        self.webhook.execute()
        self.remove_embeds_from_webhook()

    def remove_embeds_from_webhook(self):
        for i, embed in enumerate(self.webhook.get_embeds()):
            self.webhook.remove_embed(i)
Example #8
0
class DiscordLogger:
    """
    Python message transporter for Discord
    """

    COLORS = {
        "default": 2040357,
        "error": 14362664,
        "warn": 16497928,
        "info": 2196944,
        "verbose": 6559689,
        "debug": 2196944,
        "success": 2210373,
    }
    EMOJIS = {
        "default": ":loudspeaker:",
        "error": ":x:",
        "warn": ":warning:",
        "info": ":bell:",
        "verbose": ":mega:",
        "debug": ":microscope:",
        "success": ":rocket:",
    }

    def __init__(self, webhook_url, **kwargs):
        if webhook_url is None:
            raise ValueError("The field webhook_url cannot be:", webhook_url)
        self.webhook_url = str(webhook_url)

        self.application_name = kwargs.get("application_name", "Application")
        if self.application_name is not None:
            self.application_name = str(self.application_name)

        self.service_name = kwargs.get("service_name", "Status Bot")
        if self.service_name is not None:
            self.service_name = str(self.service_name)

        self.service_icon_url = kwargs.get("service_icon_url")
        if self.service_icon_url is not None:
            self.service_icon_url = str(self.service_icon_url)

        self.service_environment = kwargs.get("service_environment")
        if self.service_environment is not None:
            self.service_environment = str(self.service_environment)

        self.host_name = gethostname()
        if kwargs.get("display_hostname") is False:
            self.host_name = None

        self.default_level = kwargs.get("default_level")
        if self.default_level not in self.COLORS.keys():
            self.default_level = "default"

        self.discord = DiscordWebhook(url=self.webhook_url,
                                      username=self.application_name)

    def __remove_embeds(self):
        existing_embeds = self.discord.get_embeds()
        for i in reversed(range(0, len(existing_embeds))):
            self.discord.remove_embed(i)

    def construct(
        self,
        title=None,
        description=None,
        level=None,
        error=None,
        metadata=None,
    ):
        self.__remove_embeds()

        _level = level
        if _level is None:
            _level = self.default_level
        if error is not None:
            _level = "error"

        _color = self.COLORS.get(_level)

        _title = ""
        if title is not None:
            _title = self.EMOJIS.get(_level) + " " + str(title)

        _description = ""
        if description is not None:
            _description = str(description)

        embed = DiscordEmbed(title=_title,
                             description=_description,
                             color=_color)
        embed.set_author(name=self.service_name,
                         icon_url=self.service_icon_url)

        if metadata is not None:
            _metadata = dump(metadata,
                             indent=4,
                             default_flow_style=False,
                             sort_keys=False)

            embed.add_embed_field(name="Metadata",
                                  value=Code(str(_metadata)),
                                  inline=False)

        if error is not None:
            embed.add_embed_field(name="Error",
                                  value=Code(str(error)),
                                  inline=False)

        if self.service_environment is not None:
            embed.add_embed_field(name="Environment",
                                  value=self.service_environment)
        if self.host_name is not None:
            embed.add_embed_field(name="Host", value=self.host_name)

        embed.set_timestamp()

        self.discord.add_embed(embed)

    def send(self):
        response = self.discord.execute()
        return response
Example #9
0
        "https://cdn.discordapp.com/attachments/762872025210421268/771618824810266624/20201029_183222.jpg"
    ],
    [
        "Lewis",
        "https://discordapp.com/channels/637075986726518794/762872025210421268/771701132387942411",
        "https://cdn.discordapp.com/attachments/762872025210421268/771701617539416094/20201030_114552.jpg"
    ],
    [
        "DIY Jaad",
        "https://discordapp.com/channels/637075986726518794/762872025210421268/771858996940111892",
        "https://cdn.discordapp.com/attachments/637099044165910528/771828747204165652/PXL_20201030_200803374.jpg"
    ],
    [
        "hughie1987",
        "https://discordapp.com/channels/637075986726518794/762872025210421268/772165574926139402",
        "https://cdn.discordapp.com/attachments/762872025210421268/772165562695549009/20201031_142652.jpg"
    ]
]

embed = DiscordEmbed(title="3DMeltdown - Voting", color=0xa21d1d)
random.shuffle(post)
for p in post:
    embed = DiscordEmbed(title=f"By :{p[0]}",
                         description=f"[See full post]({p[1]})",
                         color=0xa21d1d)
    embed.set_image(url=p[2])
    webhook.add_embed(embed)
    webhook.execute()
    webhook.remove_embed(0)
    time.sleep(1)
Example #10
0
def send_webhook_message(
    retailer,
    product,
    item_name,
    product_image,
    quantity,
    is_combo,
    discord_role_id,
    discord_channel,
    in_stock_bot_chat,
):

    webhook = DiscordWebhook(discord_channel)
    # create embed object for webhook
    embed = DiscordEmbed(description=item_name, color=0x10AC00)

    product_url = product["url"]
    # set description
    if is_combo:
        embed.set_description("{} is available IN A COMBO.".format(item_name))
        embed.set_title("COMBO IN STOCK!!")
    else:
        embed.set_description("{} is now in stock.".format(item_name))
        embed.set_title("{} IN STOCK!!".format(item_name))

    # set author
    embed.set_author(name=retailer,
                     url=product_url,
                     icon_url=RETAILER_ICONS[retailer])

    # set thumbnail
    if product_image:
        embed.set_thumbnail(url=product_image)

    # set footer
    embed.set_footer(
        text=
        "Please report any issues by sending the @programmer role a message.")

    # set timestamp (default is now)
    embed.set_timestamp()

    # add fields to embed
    if product["brand"]:
        embed.add_embed_field(name="Brand", value=product["brand"])

    if product["model"]:
        embed.add_embed_field(name="Model", value=product["model"])

    if product["series"]:
        embed.add_embed_field(name="Series", value=product["series"])
    embed.add_embed_field(name="URL", value=product_url)

    # add embed object to webhook
    webhook.add_embed(embed)

    # ping discord roles if not in stock-bot
    if not in_stock_bot_chat:
        time_since_last_ping = datetime.now(
        ) - sent_role_pings[discord_role_id]
        time_since_last_ping_in_sec = round(
            time_since_last_ping.total_seconds(), 2)

        if time_since_last_ping_in_sec > 600:
            webhook.set_content("<@&{}>".format(discord_role_id))
            sent_role_pings[discord_role_id] = datetime.now()

    sent_webhook = webhook.execute()

    # add not-in-stock edited webhook message and save it for later
    webhook.remove_embed(0)
    embed.set_color(0xC90000)

    if is_combo:
        embed.set_title("Combo is no longer in stock.")
        embed.set_description(
            "{} is no longer available in a combo.".format(item_name))
    else:
        embed.set_title("Item is no longer in stock.")
        embed.set_description("{} is not in stock.\n Quantity sold: {}".format(
            item_name, quantity))
    webhook.add_embed(embed)

    return (webhook, sent_webhook)
def discWebhook(discURL, prodDet, siteURL):
    try:
        webhook = DiscordWebhook(url=discURL)
        #setup webhook
        embed = DiscordEmbed(title='ShopifyScraper',
                             description='I scrape shopify sites',
                             color=242424)
        embed.set_author(
            name='Kane-Bot',
            url='https://github.com/ahmad-afiquddin',
            icon_url=
            'https://pbs.twimg.com/profile_images/905928854740586496/piFPvtXM_400x400.jpg'
        )
        if (prodDet):
            for pName, pDet in prodDet.items():
                pLink = pDet[0]
                pImg = pDet[1]
                embed = DiscordEmbed(title='ShopifyScraper',
                                     description='I scrape shopify sites',
                                     color=242424)
                embed.set_author(
                    name='Kane-Bot',
                    url='https://github.com/ahmad-afiquddin',
                    icon_url=
                    'https://pbs.twimg.com/profile_images/905928854740586496/piFPvtXM_400x400.jpg'
                )
                embed.set_image(url=pImg)
                embed.add_embed_field(name=pName, value=pLink)
                embed.add_embed_field(
                    name='PD QUICK TASK',
                    value='[' + pName + ']' + '(' +
                    'https://api.destroyerbots.io/quicktask?url=' + pLink +
                    ')')
                varDict = variantGrab(pLink)
                for size, var in varDict.items():
                    embed.add_embed_field(
                        name=size,
                        value=siteURL + '/cart/' + var + ':1' + ' [**PD**]' +
                        '(' + 'https://api.destroyerbots.io/quicktask?url=' +
                        siteURL + '/cart/' + var + ':1' + ')')
                embed.set_timestamp()
                webhook.add_embed(embed)
                webhook.execute()
                webhook.remove_embed(0)
        else:
            embed = DiscordEmbed(title='ShopifyScraper',
                                 description='I scrape shopify sites',
                                 color=242424)
            embed.set_author(
                name='Kane-Bot',
                url='https://github.com/ahmad-afiquddin',
                icon_url=
                'https://pbs.twimg.com/profile_images/905928854740586496/piFPvtXM_400x400.jpg'
            )
            embed.set_image(
                url=
                'https://user-images.githubusercontent.com/24848110/33519396-7e56363c-d79d-11e7-969b-09782f5ccbab.png'
            )
            embed.add_embed_field(name='NOT LOADED YET, OR BAD KW',
                                  value='PATIENCE FROM ZHOU')
            embed.set_timestamp()
            webhook.add_embed(embed)
            webhook.execute()
            webhook.remove_embed(0)
    except:
        print('Something is wrong with the discord webhook link you provided')