Пример #1
0
def push(content, webhook, options={}, files=[]):
    if isinstance(content, str):
        content = [content]
    webhook = DiscordWebhook(url=webhook)
    webhook.avatar_url = options.get('avatar_url')
    webhook.username = options.get('username')
    for file in files:
        webhook.add_file(file=file['data'], filename=file['name'])
    for msg in content:
        webhook.content = msg
        webhook.execute()
Пример #2
0
    def send_random_comic():
        webhook = DiscordWebhook(url=config.URL)
        webhook.avatar_url = "https://pbs.twimg.com/profile_images/1364920241265012743/Y__158zv.png"

        max = get_latest_comic_num()
        rand = random.randrange(1, max + 1)

        comic = requests.get(f'https://xkcd.com/{rand}/info.0.json').json()
        embed = create_embed(comic)

        webhook.add_embed(embed)
        webhook.execute()
Пример #3
0
def hook(content, name, files=[], username=None, avatar_url=None):
    if current_app.debug:
        name = 'debug'
    if isinstance(content, str):
        content = [content]
    links = webhooks.get(name)
    if isinstance(links, str):
        links = [links]
    for link in links:
        webhook = DiscordWebhook(link)
        webhook.username = username
        webhook.avatar_url = avatar_url
        for file in files:
            webhook.add_file(file=file['data'], filename=file['name'])
        for msg in content:
            webhook.content = msg
            webhook.execute()
Пример #4
0
    return utc_to_local(utc_dt).strftime('%m/%d/%Y, %I:%M:%S %p')


discord_url = 'YOUR_WEBHOOK_URL'

#Set the URLs for the svn and the Discord webhook
r = svn.remote.RemoteClient('YOUR_SVN_ADDRESS')  #only records changes in trunk
webhook = DiscordWebhook(url=discord_url, username='******')

commitMadeToday = False

outfile = open("changelog.txt", "r+")
outfile.write("Today's changes:" + "\n")
outfile.write("====================\n")

webhook.avatar_url = 'https://i.imgur.com/Pi5ICIR.jpg'


def discord(u):
    global commitMadeToday
    i = 0

    for e in r.log_default():

        #creates embed
        embed = DiscordEmbed(title="Today's Updates", url=u, color=242424)

        if e.date.date() == today:
            if e:
                # If a change has been made today, set this variable to True
                commitMadeToday = True