-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest.py
45 lines (35 loc) · 1.05 KB
/
request.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
import sys
try:
import xmpp
except ImportError:
print("[!] please pip3 install xmpppy")
def send_xmpp_notify(text=""):
#Change here
jidparams = {
'jid': "[email protected]/resource",
'password': "yourpassword",
}
senderList = ["[email protected]"]
jid=xmpp.protocol.JID(jidparams['jid'])
cl=xmpp.Client(jid.getDomain(),debug=[])
con=cl.connect()
if not con:
print('could not connect!')
raise Exception("Fail in connect to jabber")
return
print('connected with',con)
auth=cl.auth(jid.getNode(),jidparams['password'], resource=jid.getResource())
if not auth:
print('could not authenticate!')
raise Exception("Fail in authenticate")
return
print('authenticated using',auth)
#cl.SendInitPresence(requestRoster=0) # you may need to uncomment this for old server
for tojid in senderList:
try:
id=cl.send(xmpp.protocol.Message(tojid, text))
print('sent message with id ',id)
except Exception as exc:
print("error: {}".format(str(exc)))
raise Exception("Fail in send to jabber")
send_xmpp_notify(text=str(sys.argv[1]))