-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscord.py
104 lines (97 loc) · 4.09 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import prof
import requests
import os
import time
import datetime
import re
target_jid = "JID_TO_TARGET"
webhook_address = "YOUR_URL_HERE"
footer_icon = "YOUR_AVATAR_HERE"
svc_by = "YOUR_NAME_HERE"
logo_url = "CORP/ALLIANCE_LOGO_URL_HERE"
jid_url = "LINK_FOR_JID"
headers = {
'content-type': "application/json",
'cache-control': "no-cache",
}
def prof_on_start():
prof.cons_show("Profanity has started...")
prof.cons_show("Discord Forwarding Enabled")
def prof_post_chat_message_display(barejid, resource, message):
if barejid == target_jid:
prof.cons_show("JID IS " + barejid)
prof.cons_show("MESSAGE IS " + message)
check = message
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', check)
if len(urls) == 0:
urlstr = ""
else:
urlstr = "**PING CONTAINS THE FOLLOWING URLS** \n> " + ' \n> '.join(urls) + "\n\n"
prof.cons_show("URLS: "+ urlstr)
payload = {
"embeds":[{
"description": "```"+ message +"```\n "+ urlstr +" ***THIS IS PING HAS BEEN AUTOMATICALLY FORWARDED FROM JABBER***",
"url": "https://discordapp.com",
"color": 16259585,
"timestamp": datetime.datetime.utcnow().isoformat(),
"footer":{
"icon_url": footer_icon,
"text": "Service by "+ svc_by
},
"thumbnail":{
"url": logo_url
},
"author":{
"name": barejid,
"url": jid_url,
"icon_url": logo_url
}
}]
}
r = requests.post(webhook_address, headers=headers, json=payload)
else:
prof.cons_show("Message not a ping")
def prof_on_disconnect(account_name, fulljid):
payload = {
"embeds":[{
"description": ":warning:***WARNING***:warning: \n\n **JABBER PING FORWARDING IS DOWN! (Reason: D)** \n **PLEASE NOTIFY "+ svc_by +" ASAP!** \n\n :warning:***WARNING***:warning:",
"url": "https://discordapp.com",
"color": 16776960,
"timestamp": datetime.datetime.utcnow().isoformat(),
"footer":{
"icon_url": footer_icon,
"text": "Service by "+ svc_by
},
"thumbnail":{
"url": "http://icons.iconarchive.com/icons/martz90/hex/128/warning-icon.png"
},
"author":{
"name": "EMERGENCY ALERT BROADCAST SYSTEM",
"url": "",
"icon_url": "http://icons.iconarchive.com/icons/martz90/hex/128/warning-icon.png"
}
}]
}
r = requests.post(webhook_address, headers=headers, json=payload)
def prof_on_shutdown():
payload = {
"embeds":[{
"description": ":warning:***WARNING***:warning: \n\n **JABBER PING FORWARDING IS DOWN!** \n **PLEASE NOTIFY "+ svc_by +" ASAP! (Reason: S)** \n\n :warning:***WARNING***:warning:",
"url": "https://discordapp.com",
"color": 16776960,
"timestamp": datetime.datetime.utcnow().isoformat(),
"footer":{
"icon_url": footer_icon,
"text": "Service by "+ svc_by
},
"thumbnail":{
"url": "http://icons.iconarchive.com/icons/martz90/hex/128/warning-icon.png"
},
"author":{
"name": "EMERGENCY ALERT BROADCAST SYSTEM",
"url": "",
"icon_url": "http://icons.iconarchive.com/icons/martz90/hex/128/warning-icon.png"
}
}]
}
r = requests.post(webhook_address, headers=headers, json=payload)