Created
March 13, 2013 14:51
-
-
Save anonymous/5152863 to your computer and use it in GitHub Desktop.
XMPP-bot, which reply by "ip" message his Internet IP-adress. It's very usable if you hasn't money to by dyndns.org account.
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
[account] | |
login = login@xmpp-server | |
password = password | |
[presence] | |
presence = 'chat' |
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 | |
# -*- coding: utf-8 -*- | |
'''ipbot- IP address to jabber bot. | |
licence GPL v.3''' | |
import xmpp | |
import urllib2 | |
import ConfigParser | |
config = ConfigParser.ConfigParser() | |
config.read('/etc/ipbot.conf') | |
########################## | |
user=(config.get('account', 'login')) | |
password=(config.get('account', 'password')) | |
presence=(config.get('presence','presence')) | |
########################## | |
jid=xmpp.protocol.JID(user) | |
client=xmpp.Client(jid.getDomain()) | |
client.connect() | |
client.auth(jid.getNode(),password) | |
################Получаем IP################## | |
strURL='http://api.wipmania.com/' | |
f = urllib2.urlopen(urllib2.Request(strURL)) | |
response = f.read() | |
ipget = response.split() | |
f.close() | |
############################################# | |
def status(xstatus): | |
status=xmpp.Presence(status=xstatus,show=presence,priority='1') | |
client.send(msging) | |
def message(conn,mess): | |
global client | |
if ( mess.getBody() == "ip" ): | |
client.send(xmpp.Message(mess.getFrom(),ipget)) | |
client.RegisterHandler('message',message) | |
client.sendInitPresence() | |
while True: | |
client.Process(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment