예제 #1
0
def send_message(webhookurl, subreddit, link, image, text):
    """Send a webhook message to a given discord server channel.

    Args:
        webhookurl (str): A discord webhook URL
        subreddit (str): The subreddit concerning the title
        link (str): Link to the main reddit post with more data
        image (str): Link to the imgur graph image
        text (str): Formatted text table to be shown in the webhook
    """
    webhook = DiscordWebhooks(webhookurl)
    webhook.set_content(title="/r/%s Moderator Actions" % subreddit)
    webhook.set_image(url=image)
    webhook.send()
    #sending two webhooks is the only way that the text is formatted nicely
    #on both mobile and desktop with the image
    #this is because discord's CSS is really shitty.

    webhook = DiscordWebhooks(webhookurl)
    webhook.set_content(content=link, description=text)
    webhook.set_footer(
        text=
        'jwnskanzkwk#9757\nhttps://github.com/jwansek/SubredditModActionsLog',
        icon_url=
        'https://avatars1.githubusercontent.com/u/37976823?s=460&u=1739eabb8af515eccf259a9eb5ad7f44ac6aed85&v=4'
    )
    webhook.send()
예제 #2
0
    def test_complex_embed(self):
        """
      Tests a combination of all methods to form a complex payload object.
    """
        webhook = DiscordWebhooks('webhook_url')
        webhook.set_content(content='Montezuma', title='Best Cat Ever', description='Seriously', \
          url='http://github.com/JamesIves', color=0xF58CBA, timestamp='2018-11-09T04:10:42.039Z')
        webhook.set_image(
            url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
        webhook.set_thumbnail(
            url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
        webhook.set_author(
            name='James Ives',
            url='https://jamesiv.es',
            icon_url=
            'https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
        webhook.set_footer(
            text='Footer',
            icon_url=
            'https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
        webhook.add_field(name='Field', value='Value!')

        self.maxDiff = None
        expected_payload = \
          {
            'content': 'Montezuma',
            'embeds': [
                {
                  'title': 'Best Cat Ever',
                  'description': 'Seriously',
                  'url': 'http://github.com/JamesIves',
                  'color': 16092346,
                  'timestamp': '2018-11-09T04:10:42.039Z',
                  'fields': [
                    {
                      'name': 'Field',
                      'value': 'Value!',
                      'inline': False
                    }
                  ],
                  'image': {
                    'url': 'https://avatars1.githubusercontent.com/u/10888441?s=460&v=4'
                  },
                  'author': {
                    'name': 'James Ives',
                    'url': 'https://jamesiv.es',
                    'icon_url': 'https://avatars1.githubusercontent.com/u/10888441?s=460&v=4'
                  },
                  'thumbnail': {
                    'url': 'https://avatars1.githubusercontent.com/u/10888441?s=460&v=4'
                  },
                  'footer': {
                    'text': 'Footer',
                    'icon_url': 'https://avatars1.githubusercontent.com/u/10888441?s=460&v=4'
                  },
                }
              ]
            }

        self.assertEquals(webhook.format_payload(), expected_payload)
예제 #3
0
파일: 1bot.py 프로젝트: ddoskid/idfkk
async def dos24hrs(ctx, *, ipxer: str):

    await ctx.send('DDoS Started! check  <#750038125862060152>')

    WEBHOOK_URL = 'https://discordapp.com/api/webhooks/750045740352667788/q71VgymARTPb-qLiS98cQSBOuAIJRZseLN6z-AhE2fRqFQXfCfp5dGjl_dcon4ZMJxUI'

    webhook = DiscordWebhooks(WEBHOOK_URL)

    webhook.add_field(name='`IPADRESS:`', value=ipxer, inline=True)

    webhook.add_field(name='`PORT:`', value='`80`', inline=True)

    webhook.add_field(name='`Hours:`', value='`24`', inline=True)

    webhook.set_footer(
        text='DDOS Started!',
        icon_url=
        'https://www.logolynx.com/images/logolynx/3b/3bc09932e42516a9fa80e0b8dbb695e8.png'
    )

    webhook.set_content(content='', color=0xff1100)

    webhook.send()

    os.system('perl Packet86400.pl ' + ipxer)
    pass

    await ctx.send('DDoS Completed!')

    os.system('python3 1bot.py')
def send_webhook():
    voters = []
    max_votes = []
    data = get_vote_json()
    for x in data.items():
        for v in x[1]:
            voters.append(v)
    for x in voters:
        if x["nickname"] in [x["nickname"] for x in max_votes]:
            for u in max_votes:
                if u["nickname"] == x["nickname"]:
                    u["votes"] = str(int(x["votes"]) + int(u["votes"]))
        else:
            max_votes.append(x)
    message = "**Current Votes!** \U0001F389 \n\n"
    for v in max_votes:
        message += f"**User:** {v['nickname']} **Votes:** {v['votes']}\n"
    webhook = DiscordWebhooks(web_hook_url)
    webhook.set_content(content="**Vote Rewards**:\n"
                                "**12 = 500ARc\n15 = 750ARc\n18 = 1000ARc\n21 = 1250ARc**\n\n",
                        title='Click Me To Vote!',
                        description=message,
                        url='https://ark-servers.net/group/568/',
                        timestamp=str(datetime.now()),
                        color=0xF58CBA)
    webhook.send()
예제 #5
0
def job():
    url = 'add-your-webhook-url-here'
    apiurl = 'add-your-api-url-here'
    res = requests.get(apiurl)
    data = res.json()

    # current weather data extract
    ctemp = data['current']['temp']
    cwspeed = data['current']['wind_speed']
    ccloud = data['current']['clouds']
    cwmain = data['current']['weather'][0]['main']
    cwdesc = data['current']['weather'][0]['description']
    cicon = data['current']['weather'][0]['icon']

    #int to string and some calculations
    c_temp = str(ctemp)
    c_clouds = str(ccloud)
    c_wspeed = str(cwspeed)
    #h_temp = str(htemp)
    #h_clouds = str(hcloud)

    # message design for current weather
    cweather = DiscordWebhooks(url)
    cweather.set_content(title="Current Weather")
    cweather.set_thumbnail(url='http://openweathermap.org/img/wn/' + cicon +
                           '@4x.png')
    cweather.add_field(name='Temperature :', value=str(c_temp + " ºC"))
    cweather.add_field(name='Wind speed :', value=str(c_wspeed + " km/h"))
    cweather.add_field(name=(cwmain + ' :'), value=cwdesc)
    cweather.add_field(name='Cloudiness :', value=(c_clouds + '%'))
    cweather.set_footer(text='Source - OpenWeather')

    cweather.send()
예제 #6
0
def insta_usr():
    instagram = Instagram()

    # authentication supported
    instagram.with_credentials(username, password)
    instagram.login()

    account = instagram.get_account(usr)
    print(f"\t{account}")

    server = DiscordWebhooks(webhook_url)
    try:
        server.set_image(url=account.profile_pic_url)
        server.add_field(name="UserName : "******"Hacking is not a trick. It's an state of mind :)")
        server.set_author(name="HackersBrain Instagram Analyser Bot",
                          url="http://gauravraj.gq/",
                          icon_url="https://source.unsplash.com/35x35/?man")
        server.add_field(name="Full Name : ", value=account.full_name)
        server.add_field(name="Bio : ", value=account.biography)
        server.add_field(name="No. of Posts : ", value=account.media_count)
        server.add_field(name="No. of Followers : ",
                         value=account.followed_by_count)
        server.add_field(name="No. of Follows : ", value=account.follows_count)
        server.add_field(name="Is Private : ", value=account.is_private)
        server.add_field(name="Is Verified : ", value=account.is_verified)
        server.send()
        print(Fore.GREEN + "\t Message Sent Successfully...\n" +
              Style.RESET_ALL)
    except KeyboardInterrupt as key_err:
        print(" Exiting Program... \tProject by : HackersBrain\n")
    except Exception as err:
        print(f"\n {err}\n Exiting Program... \tProject by : HackersBrain\n")
예제 #7
0
    def test_set_thumbnail(self):
        """
      Tests the set_thumbnail method and ensures the data gets added to the payload.
    """
        webhook = DiscordWebhooks('webhook_url')
        webhook.set_content(content='Montezuma')
        webhook.set_thumbnail(
            url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')

        expected_payload = \
          {
            'content': 'Montezuma',
            'embeds': [
                {
                  'fields': [],
                  'image': {},
                  'author': {},
                  'thumbnail': {
                    'url': 'https://avatars1.githubusercontent.com/u/10888441?s=460&v=4'
                  },
                  'footer': {},
                }
              ]
            }

        self.assertEquals(webhook.format_payload(), expected_payload)
예제 #8
0
    def getProductLink(self):
        webhook = DiscordWebhooks("enter discord webhook")
        response = self.s.get(self.link)
        responseSoup = BeautifulSoup(response.text, "lxml")

        productSelect = responseSoup.find("select", {"name": "id"})
        sizes = productSelect.findAll("option")

        productTitle = responseSoup.find("h1",
                                         {"class", "product-single__title"})

        img = responseSoup.find("img")
        imgURL = "http:" + img['src']

        webhookContent = ""

        for size in sizes:
            if "value" and not "disabled" in str(size):
                inStockSize = size.text.strip()
                variant = size["value"]
                print(inStockSize + " (" + variant + ")")
                webhookContent += f"{inStockSize} ([{variant}](http://www.kith.com/cart/{variant}:1))\n"

        webhook.set_content(title=productTitle.text.strip(),
                            description=(webhookContent),
                            url=self.link,
                            color=0xdc00ff)
        webhook.set_footer(
            text="oapi webhook",
            icon_url=
            'https://avatars1.githubusercontent.com/u/58406347?s=460&v=4')
        webhook.set_thumbnail(url=imgURL)
        webhook.send()
예제 #9
0
    def test_generic_embed_message(self):
        """
      Tests a generic message payload.
    """
        webhook = DiscordWebhooks('webhook_url')
        webhook.set_content(content='Montezuma', title='Best Cat Ever', description='Seriously', \
          url='http://github.com/JamesIves', color=0xF58CBA, timestamp='2018-11-09T04:10:42.039Z')

        expected_payload = \
          {
            'content': 'Montezuma',
            'embeds': [
                {
                  'title': 'Best Cat Ever',
                  'description': 'Seriously',
                  'url': 'http://github.com/JamesIves',
                  'color': 16092346,
                  'timestamp': '2018-11-09T04:10:42.039Z',
                  'fields': [],
                  'image': {},
                  'author': {},
                  'thumbnail': {},
                  'footer': {},
                }
              ]
            }

        self.assertEquals(webhook.format_payload(), expected_payload)
예제 #10
0
 def send_msg(self, title, desc, msg_title, msg):
     time.sleep(3)
     webhook = DiscordWebhooks(self.webhook_url)
     webhook.set_footer(text='    --By Hariprasath')
     webhook.set_content(title=title, description=desc)
     webhook.add_field(name=msg_title, value=msg)
     webhook.send()
예제 #11
0
def post_report_server(classname, entered, timeoutquery):
    whurl = 'discord webhook url here'
    webhook = DiscordWebhooks(whurl)
    webhook.set_content(
        title='WA Report',
        description='Hello, here is the current Teams Bot status:')
    webhook.add_field(name='Class', value=classname)
    webhook.add_field(name='Entered', value=str(entered))
    webhook.add_field(name='Timeout', value=str(timeoutquery))
    webhook.send()
def send_test(textm):
    WEBHOOK_URL = webhook_url

    webhook = DiscordWebhooks(WEBHOOK_URL)
    # Attaches a footer
    webhook.set_footer(text='-- selenium bot')
    webhook.set_content(title='Test Message', description='sending log')
    webhook.add_field(name='log', value=textm)
    webhook.send()
    print("test message sent")
예제 #13
0
def sendMessage(config, className, status):

    webhook = DiscordWebhooks(config['webhookURL'])
    webhook.set_footer(text='github.com/nxm')

    if status == 'success':
        print('{}Joined successfully!\n{}Sending notification to discord{}'.
              format(Colors.GREEN, Colors.BLUE, Colors.RESET))
        webhook.set_content(title='Class joined successfully!',
                            description=className)

    webhook.send()
예제 #14
0
def post_changes():
  """ Posts the changes to the Discord server via a webhook.  """
  payload = check_for_changes()

  if payload != '':
    message = DiscordWebhooks(DISCORD_WEBHOOK_URL)
    message.set_content(color=0xc8702a, description='`%s`' % (payload))
    message.set_author(name=DISCORD_TITLE)
    message.send()

  else:
    return
예제 #15
0
def post():
    discord_text = get_changes()

    if discord_text != '':
        message = DiscordWebhooks(WebhookURL)
        message.set_content(color=0xc8702a,
                            description='`%s`' % (discord_text))
        message.set_author(name='Perforce Changelist Submit')
        message.set_footer(text='KaosSpectrum Perforce Commit Bot', ts=True)
        message.send()

    else:
        return
예제 #16
0
def clientthread(conn, addr):
    # Takes in messages from client to send to discord
    webhook = DiscordWebhooks(WEBHOOK_URL)
    while True:
        try:
            message = conn.recv(2048)
            if message:
                # Display message and send to discord
                webhook.set_content(content=message.decode('utf_8'))
                webhook.send()
                print("Me>\n\t" + message.decode('utf_8'))
            else:
                remove(conn)
        except:
            continue
def send_msg(username, follower_change, followers, unfollowers,
             followers_count, unfollowers_count, time, webhook_url):

    WEBHOOK_URL = webhook_url

    if followers == [] and unfollowers == []:
        print("No change in followers, so not sending message to discord")
        return

    if followers == []:
        followers = 'None'

    if unfollowers == []:
        unfollowers = 'None'

    webhook = DiscordWebhooks(WEBHOOK_URL)

    webhook.set_content(title='Report for %s' % (time),
                        description="Here's your report with :heart:")

    # Attaches a footer
    webhook.set_footer(text='-- Teja Swaroop')

    # Appends a field
    webhook.add_field(name='Username', value=username)
    webhook.add_field(name='Total follower change', value=follower_change)

    if unfollowers != 'None':
        webhook.add_field(name='People who unfollowed you (%d)' %
                          (unfollowers_count),
                          value=', '.join(unfollowers))
    else:
        webhook.add_field(name='People who unfollowed you (%d)' %
                          (unfollowers_count),
                          value=unfollowers)

    if followers != 'None':
        webhook.add_field(name='People who followed you (%d)' %
                          (followers_count),
                          value=', '.join(followers))
    else:
        webhook.add_field(name='People who followed you (%d)' %
                          (followers_count),
                          value=followers)

    webhook.send()

    print("Sent message to discord")
    def post_changes(self):
        """ Posts the changes to the Discord server via a webhook. """
        output = self.check_p4()
        payload = self.check_for_changes(output)

        if payload != '':
            message = DiscordWebhooks(self.webhook_url)
            message.set_content(color=0xc8702a, description='`%s`' % (payload))
            message.set_author(name='Perforce')
            message.set_footer(
                text='https://github.com/JamesIves/perforce-commit-discord-bot',
                ts=True)
            message.send()

        else:
            return
예제 #19
0
    def on_status(self, status):
        if status.author.id_str in twitter_ids:
            # Get the time
            time_format = "%Y-%m-%d %H:%M:%S"
            timestamp_utc = status.created_at.replace(tzinfo=pytz.utc)
            timestamp_est = timestamp_utc.astimezone(pytz.timezone('America/New_York'))
            timestamp_str = timestamp_est.strftime(time_format)

            tweet_url = f'https://twitter.com/{status.author.screen_name}/status/{status.id}'

            message = f'{role_mentions[status.author.id_str]} New tweet from @{status.author.screen_name} at {timestamp_str}\n{tweet_url}'

            webhook = DiscordWebhooks(twitter_webhooks[status.author.id_str])
            webhook.set_content(content=message, url=tweet_url, color=0x00acee, description=status.text)
            webhook.set_author(name=f'{status.author.name} (@{status.author.screen_name})', url=f'https://twitter.com/{status.author.screen_name}', icon_url=status.author.profile_image_url)
            webhook.set_footer(text="Twitter", icon_url="https://cdn1.iconfinder.com/data/icons/iconza-circle-social/64/697029-twitter-512.png")
            webhook.send()
예제 #20
0
def webhook_call(url):
    print("Running SHU Episode Update")

    # Pull RSS feed, parse relevant content
    shu_feed = feedparser.parse("http://hoppedupgaming.hipcast.com/rss/super_hopped_up.xml")
    episode_info = shu_feed['entries'][0]
    ep_title = episode_info['title_detail']['value']
    ep_url = episode_info['media_comment']['href']
    ep_description = episode_info['content'][0]['value']

    # Setup content to post, create webhook connection, send post
    discord_content = "New SHU Podcast Episode!\n\n{}\n\n{}\n\n{}".format(ep_title, ep_url, ep_description)
    webhook = DiscordWebhooks(url)
    webhook.set_content(content=discord_content)
    webhook.send()
    print("Episode Update Successful")
    return
예제 #21
0
    def sendMessage(self, Message):
        if 'description' not in Message:
            raise ValueError('Discord messages requires a description')

        if 'content' not in Message:
            Message['content'] = ''

        if 'title' not in Message:
            Message['title'] = ''

        if 'color' not in Message:
            Message['color'] = 0xFFFFFF

        if 'author' not in Message:
            Message['author'] = {}
        if 'name' not in Message['author']:
            Message['author']['name'] = ''
        if 'url' not in Message['author']:
            Message['author']['url'] = ''
        if 'icon_url' not in Message['author']:
            Message['author']['icon_url'] = ''

        if 'footer' not in Message:
            Message['footer'] = {}
        if 'text' not in Message['footer']:
            Message['footer']['text'] = ''
        if 'icon_url' not in Message['footer']:
            Message['footer']['icon_url'] = ''

        message = DiscordWebhooks(self.webhook_url)
        message.set_content(color=Message['color'],
                            content=Message['content'],
                            description=Message['description'],
                            title=Message['title'])
        message.set_footer(text=Message['footer']['text'],
                           icon_url=Message['footer']['icon_url'])
        message.set_author(url=Message['author']['url'],
                           name=Message['author']['name'],
                           icon_url=Message['author']['icon_url'])
        if 'image' in Message:
            message.set_image(url=Message['image'])

        if not self.dry_run:
            message.send()
예제 #22
0
파일: a.py 프로젝트: Akathian/akathian.com
def send_msg(username, follower_change, followers, unfollowers,
             followers_count, unfollowers_count, time, webhook_url,
             not_follow_back):

    WEBHOOK_URL = webhook_url

    if followers == []:
        followers = 'None'

    if unfollowers == []:
        unfollowers = 'None'

    webhook = DiscordWebhooks(WEBHOOK_URL)

    webhook.set_content(title='Report for %s' % (time),
                        description="Here's your report with :heart:")

    # Appends a field
    webhook.add_field(name='Username', value=username)
    webhook.add_field(name='Total follower change', value=follower_change)

    if unfollowers != 'None':
        webhook.add_field(name='People who unfollowed you (%d)' %
                          (unfollowers_count),
                          value=', '.join(unfollowers))
    else:
        webhook.add_field(name='People who unfollowed you (%d)' %
                          (unfollowers_count),
                          value=unfollowers)

    if followers != 'None':
        webhook.add_field(name='People who followed you (%d)' %
                          (followers_count),
                          value=', '.join(followers))
    else:
        webhook.add_field(name='People who followed you (%d)' %
                          (followers_count),
                          value=followers)

    webhook.add_field(name='People who don\'t follow you back (%d)' %
                      (len(not_follow_back)),
                      value=', '.join(not_follow_back))

    webhook.send()
def score():
    webhook = DiscordWebhooks(web_hook_url)
    r = requests.get("https://api.sigmadraconis.games/scores")
    servers = r.json()["scores"]
    s = set([s["Server"] for s in servers])
    print(s)
    for s in s:
        ss = [x for x in servers if x["Server"] == s]
        print(ss)
        p = set([s["PlanetId"] for s in ss])
        print(p)
        d = ""
        webhook.set_content(content="\n", title=f"Scores for {s}")
        for p in p:
            sss = [x for x in ss if x["PlanetId"] == p]
            d += f"\n**Planet**: ***{p}***\n"
            for sss in sss:
                d += f"\n**Faction**: {sss['FactionName']}\n"
                d += f"**Score**: {sss['Points']}\n"
        print(d)
        webhook.set_content(content="",
                            title=f"Scores for **{s}**",
                            url="https://sigmadraconis.games/koth.html",
                            description=d,
                            timestamp=str(datetime.datetime.now()),
                            color=0xF58CBA)
        webhook.set_author(
            name="KOTH",
            icon_url=
            "https://cdn.discordapp.com/attachments/657771421564534807/689958406194200666/draconis_logo.png",
            url="https://sigmadraconis.games/koth.html")
        webhook.set_footer(
            text="https://sigmadraconis.games/koth.html",
            icon_url=
            "https://cdn.discordapp.com/attachments/657771421564534807/689958406194200666/draconis_logo.png"
        )
        webhook.set_thumbnail(
            url=
            "https://cdn.discordapp.com/attachments/657771421564534807/689958406194200666/draconis_logo.png"
        )
        webhook.send()
        time.sleep(5)
예제 #24
0
    def test_standard_message(self):
        """
      Tests a standard messgae payload with nothing but content.
    """
        webhook = DiscordWebhooks('webhook_url')
        webhook.set_content(content='Montezuma')

        expected_payload = {
            'content':
            'Montezuma',
            'embeds': [{
                'fields': [],
                'image': {},
                'author': {},
                'thumbnail': {},
                'footer': {},
            }]
        }

        self.assertEqual(webhook.format_payload(), expected_payload)
예제 #25
0
def send_msg(class_name, status, start_time, end_time):
    webhook = DiscordWebhooks(webhook_url)
    # Attach the footer
    webhook.set_footer(text = '--Attender Bot')

    if status == "joined":
        webhook.set_content(title=f"{class_name} lecture has started",
                    description = ":heart:")
        #Put the Fields
        webhook.add_field(name = "Class", value = class_name)
        webhook.add_field(name = "Status", value = status)
        webhook.add_field(name = "Joined at", value = start_time)
        webhook.add_field(name = "Leaving at", value = end_time)
        
    elif status == "left":
        webhook.set_content(title=f"I left the {class_name} lecture",
                    description = "heart:")
        #Put the Fields
        webhook.add_field(name = "Class", value = class_name)
        webhook.add_field(name = "Status", value = status)
        webhook.add_field(name = "Joined at", value = start_time)
        webhook.add_field(name = "Left at", value = end_time)
        
    elif status == "noclass":
        webhook.set_content(title=f"today their is no class of {class_name}",
                    description = "heart:")
        #Put the Fields
        webhook.add_field(name = "Class", value = class_name)
        webhook.add_field(name = "Status", value = status)
        webhook.add_field(name = "Expected Join at", value = start_time)
        webhook.add_field(name = "Expected Leave at", value = end_time)
    webhook.send()
    print("Message Send")
예제 #26
0
class Discord:
    def __init__(self, config, webhook):
        self.data = discord_data()
        self.data.url = config['discord']['webhooks'][webhook]['url']
        self.data.name = config['discord']['webhooks'][webhook]['name']
        self.webhook = DiscordWebhooks(self.data.url)

    def send(self, message):
        if self.webhook != None:
            if message.url != None:
                self.webhook.set_content(color=message.color,
                                         title='%s' % (message.header),
                                         description='%s' % (message.content),
                                         url=message.url)
            else:
                self.webhook.set_content(color=message.color,
                                         title='%s' % (message.header),
                                         description='%s' % (message.content))
            self.webhook.set_author(name=message.user)
            self.webhook.set_footer(text=message.footer, ts=True)
            self.webhook.send()
        else:
            assert False, "Discord was not initilized"
예제 #27
0
def send_msg(status, sent, error):
    IST = pytz.timezone('Asia/Kolkata')
    datetime_ist = datetime.now(IST)
    timestamp = datetime_ist.strftime('%Y:%m:%d %H:%M:%S %Z %z')

    WEBHOOK_URL = "https://discordapp.com/api/webhooks/"
    webhook = DiscordWebhooks(WEBHOOK_URL)
    webhook.set_footer(text='-- Teja Swaroop')

    if status == "info":
        webhook.set_content(title="Report")
        webhook.add_field(name='Sent', value=sent)
        webhook.add_field(name="timestamp", value=timestamp)
    if status == "error":
        webhook.set_content(title="Error occured")
        webhook.add_field(name='Sent until here', value=sent)
        webhook.add_field(name='Error', value=error)
        webhook.add_field(name="timestamp", value=timestamp)

    try:
        webhook.send()
        print("Message sent to discord")
    except Exception as e:
        print("Message failed to send to discord")
예제 #28
0
def send_msg(class_name,link,status,date,start_time,end_time):

    WEBHOOK_URL = webhook_url 

    webhook = DiscordWebhooks(WEBHOOK_URL)
    

    if(status=="fetched"):

      webhook.set_content(title='Zoom Class',
                          description="Here's your Link :zap:")

      # Appends a field
      webhook.add_field(name='Class', value=class_name)
      webhook.add_field(name='Zoom link', value=link)
      webhook.add_field(name='Date', value=date)
      webhook.add_field(name='Start time', value=start_time)
      webhook.add_field(name='End time', value=end_time)
    


    elif(status=="noclass"):
      webhook.set_content(title='Zoom Class',
                          description="Class Link Not Found! Assuming no class :sunglasses:")

      # Appends a field
      webhook.add_field(name='Class', value=class_name)
      webhook.add_field(name='Date', value=date)
      webhook.add_field(name='Start time', value=start_time)
      webhook.add_field(name='End time', value=end_time)




    elif(status=="G-learn down"):
      webhook.set_content(title='G-learn Is Not Responding',
                          description="Link bot failed to fetch :boom:")

      # Appends a field
      webhook.add_field(name='Status', value=status)



    # Attaches a footer
    webhook.set_footer(text='-- Zoom Links')


    webhook.send()

    print("Sent message to discord")
def send_msg(class_name, status, start_time, end_time):

    WEBHOOK_URL = webhook_url

    webhook = DiscordWebhooks(WEBHOOK_URL)
    # Attaches a footer
    webhook.set_footer(text='-- vaibdix')

    if (status == "joined"):

        webhook.set_content(title='Class Joined Succesfully',
                            description="Here's your report with :heart:")

        # Appends a field
        webhook.add_field(name='Class', value=class_name)
        webhook.add_field(name='Status', value=status)
        webhook.add_field(name='Joined at', value=start_time)
        webhook.add_field(name='Leaving at', value=end_time)

    elif (status == "left"):
        webhook.set_content(title='Class left Succesfully',
                            description="Here's your report with :heart:")

        # Appends a field
        webhook.add_field(name='Class', value=class_name)
        webhook.add_field(name='Status', value=status)
        webhook.add_field(name='Joined at', value=start_time)
        webhook.add_field(name='Left at', value=end_time)

    elif (status == "noclass"):
        webhook.set_content(
            title='Seems like no class today',
            description="No join button found! Assuming no class.")

        # Appends a field
        webhook.add_field(name='Class', value=class_name)
        webhook.add_field(name='Status', value=status)
        webhook.add_field(name='Expected Join time', value=status)
        webhook.add_field(name='Expected Leave time', value=end_time)

    webhook.send()

    print("Sent message to discord")
예제 #30
0
def send_msg(msg, vc):

    WEBHOOK_URL = webhook_url

    webhook = DiscordWebhooks(WEBHOOK_URL)
    # Attaches a footer
    webhook.set_footer(text='With Love from Divyansh Sikarwar')
    # main Content
    if (msg == 0):
        webhook.set_content(
            title=msg,
            description=
            "Currently there are no Vaccination Centers available for your age in your area"
        )
    elif (msg == -1):
        webhook.set_content(
            title=msg,
            description=
            "Sorry due to some techical reasons we cant access Vaccination Availability Info right now"
        )
    else:
        webhook.set_content(
            title="Vaccination Centers are now available !!",
            description=
            "Here is your Available Vaccination Center's list :Heart: :")
        # Appends a field
        for i in range(len(vc)):
            a = vc[i]
            print(a["name"], "(", a["min_age_limit"], "+) : ",
                  a["available_capacity"])
            webhook.add_field(name="Center Name", value=a["name"])
            webhook.add_field(name="Min Age", value=a["min_age_limit"])
            webhook.add_field(name="Available Capacity",
                              value=a["available_capacity"])
            webhook.add_field(name="----",
                              value="-----------------------------------")

    webhook.send()

    print("Report sent to discord")