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()
Exemple #2
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")
Exemple #3
0
    def test_set_footer(self):
        """
      Tests the set_footer method and ensures the data gets added to the payload.
    """
        webhook = DiscordWebhooks('webhook_url')
        webhook.set_footer(
            text='Footer',
            icon_url=
            'https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')

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

        self.assertEquals(webhook.format_payload(), expected_payload)
 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()
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()
Exemple #6
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)
Exemple #7
0
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')
Exemple #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()
Exemple #9
0
def job():
    url = 'add-your-webhook-url-here'
    newsapi = NewsApiClient(api_key='add-your-api-key-here')

    data = newsapi.get_top_headlines(language='en',country='in')

    if data['status'] == 'ok':
        ar1t = data['articles'][0]['title']
        ar1d = data['articles'][0]['url']
        ar1i = data['articles'][0]['urlToImage']

        ar2t = data['articles'][1]['title']
        ar2d = data['articles'][1]['url']
        ar2i = data['articles'][1]['urlToImage']

        ar3t = data['articles'][2]['title']
        ar3d = data['articles'][2]['url']
        ar3i = data['articles'][2]['urlToImage']

        ar4t = data['articles'][3]['title']
        ar4d = data['articles'][3]['url']
        ar4i = data['articles'][3]['urlToImage']

        ar5t = data['articles'][4]['title']
        ar5d = data['articles'][4]['url']
        ar5i = data['articles'][4]['urlToImage']

        cnews1 = DiscordWebhooks(url)
        cnews1.set_author(name="Today's top headlines")
        cnews1.set_content(title=ar1t,url=ar1d)
        cnews1.set_thumbnail(url=ar1i)

        cnews2 = DiscordWebhooks(url)
        cnews2.set_content(title=ar2t,url=ar2d)
        cnews2.set_thumbnail(url=ar2i)

        cnews3 = DiscordWebhooks(url)
        cnews3.set_content(title=ar3t,url=ar3d)
        cnews3.set_thumbnail(url=ar3i)

        cnews4 = DiscordWebhooks(url)
        cnews4.set_content(title=ar4t,url=ar4d)
        cnews4.set_thumbnail(url=ar4i)

        cnews5 = DiscordWebhooks(url)
        cnews5.set_content(title=ar5t,url=ar5d)
        cnews5.set_thumbnail(url=ar5i)
        cnews5.set_footer(text='Source - newsapi.org')

        cnews1.send()
        cnews2.send()
        cnews3.send()
        cnews4.send()
        cnews5.send()

    else:
        cnews = DiscordWebhooks(url)
        cnews.set_content(title="Sorry, we will be back soon with live news!")
        cnews.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")
Exemple #11
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()
Exemple #12
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
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(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
Exemple #16
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()
Exemple #17
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()
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")
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)
Exemple #20
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")
Exemple #21
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"
Exemple #22
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")
import requests
from discord_webhooks import DiscordWebhooks

webhook_url = input('Enter WEBHOOK URL: ')

message = input('Enter Message: ')
ilosc = int(input('Enter Amount of Messages: '))

webhook = DiscordWebhooks(webhook_url)

webhook.set_content(title='get spammed nwords',
                    description=message,
                    color=0xF58CBA)

webhook.set_footer(text='made by: b00mek#1314')

for i in range(ilosc):
    webhook.send()
Exemple #24
0
if StartMessage():
  print("webhook di start inviato")

#---------------------------------------------------------------------------------------------------------------------------------

while True:
    circolari = {}
    c=0
    for i in range(0, getNumeroCircolari()):
        circolari[c] = {"titolo":getTitoli(c),"link":getLinks(c),"data":getDate(c)}
        c=c+1
        print(c)
    with open("ultimacirc.txt",'r') as f:
        if f.read() != circolari[0]["titolo"]:
            webhook.set_content(title=circolari[0]["titolo"],
                                description="Data: "+circolari[0]["data"],
                                url=circolari[0]["link"],
                                color=0x9900FF)
            webhook.set_author(name="Nuova circolare")
            webhook.set_footer(text="Badoni circolari")
            webhook.send()   
            print("webhook inviato")

    with open("ultimacirc.txt", 'w+') as f:
        f.write(circolari[0]["titolo"])

    time.sleep(60)
        
#---------------------------------------------------------------------------------------------------------------------------------
def DisIntro(webhook_url):
    webhook = DiscordWebhooks(webhook_url)
    webhook.set_content(
        title='Discord Bot Intro',
        description="This is going to be the channel to send message")
    webhook.set_footer(text='--ScarLet42')
def send_msg(insta_username, insta_password, username, follower_change,
             followers, unfollowers, followers_count, unfollowers_count, time,
             webhook_url, uforuf, fof):

    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='-- ScarLet42')

    # 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)

    if (unfollowers != 'None' and uforuf == 'y'):

        bot = MyIGBot(insta_username, insta_password)
        for x in unfollowers:
            response = bot.unfollow(x)
            if (response == 200):
                print(x, "Unfollowed You On -", username)
                webhook.add_field(name='Unfollowed %s' % (x))
                print("Unfollowed", x)
            else:
                print(x, "Unfollowed You On -", username)
                print("Wasn't following ", x)

    if (followers != 'None' and fof == 'y'):
        bot = MyIGBot(insta_username, insta_password)
        for y in followers:
            response = bot.follow(y)
            if (response == 200):
                print("Followed back ", y)
                webhook.add_field(name='Followed Back %s' % (y))
            else:
                print("Already Following %s or some other error occured..." %
                      (y))

    webhook.send()

    print("Sent message to discord")
Exemple #27
0
def send_msg(class_name, status, start_time, end_time, t_date):

    WEBHOOK_URL = webhook_url

    webhook = DiscordWebhooks(WEBHOOK_URL)

    if (status == "joined"):

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

        # 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)
        webhook.add_field(name='Date', value=t_date)

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

        # 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)
        webhook.add_field(name='Date', value=t_date)

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

        # 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=start_time)
        webhook.add_field(name='Expected Leave time', value=end_time)
        webhook.add_field(name='Date', value=t_date)

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

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

    elif (status == "zoom_link down"):
        webhook.set_content(title='Zoom Link Is Not Working',
                            description="Zoom bot failed to join :boom:")

        # 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=start_time)
        webhook.add_field(name='Expected Leave time', value=end_time)
        webhook.add_field(name='Date', value=t_date)

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

    webhook.send()

    print("Sent message to discord")