-
-
Save kaymccormick/f044a4ece363c32727046585325a4498 to your computer and use it in GitHub Desktop.
Command-line utility for sending jabber messages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# xsend: command-line utility for sending jabber messages | |
# http://xmpppy.sourceforge.net/ | |
# | |
import sys,os,xmpp,time | |
if len(sys.argv) < 2: | |
print "Syntax: xsend JID msg" | |
sys.exit(0) | |
tojid = sys.argv[1] | |
#msg = ' '.join(sys.argv[2:]) | |
data = sys.stdin.readlines() | |
msg = ' '.join(data) | |
username = '[email protected]/resource' | |
password = 'yourpassword' | |
jid=xmpp.protocol.JID(username) | |
cl=xmpp.Client(jid.getDomain(),debug=[]) | |
con=cl.connect() | |
if not con: | |
sys.exit() | |
auth=cl.auth(jid.getNode(),password,resource=jid.getResource()) | |
if not auth: | |
sys.exit() | |
#cl.SendInitPresence(requestRoster=0) # you may need to uncomment this for old server | |
id=cl.send(xmpp.protocol.Message(tojid, msg)) | |
time.sleep(1) # some older servers will not send the message if you disconnect immediately after sending | |
#cl.disconnect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment