-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscord.py
40 lines (25 loc) · 1.18 KB
/
discord.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from discord_webhook import DiscordWebhook, DiscordEmbed
def send_msg(username,unfollowers,newfollowers, time, webhook_url):
# print("In the discord")
newfollowers_content=''
unfollowers_content=''
if newfollowers == [] and unfollowers == []:
print("No change in followers, so not sending message to discord")
return
if newfollowers == []:
newfollowers_content = 'None'
if unfollowers == []:
unfollowers_content = 'None'
for x in newfollowers:
newfollowers_content=newfollowers_content+x+'\n'
for x in unfollowers:
unfollowers_content=unfollowers_content+x+'\n'
webhook = DiscordWebhook(url= webhook_url)
embed = DiscordEmbed(title=':notebook: Report for %s' %(username), description='%s' %(time))
embed.add_embed_field(name='People who followed you', value=newfollowers_content ,inline=False)
embed.add_embed_field(name='People who unfollowed you', value=unfollowers_content)
# Attaches a footer
embed.set_footer(text='--Tony Stark')
webhook.add_embed(embed)
response = webhook.execute()
print("Sent message to discord")