Source code for point.plugs.xmpp
# p/plugs/xmpp.py
#
#
""" xmpp related stuff. """
# thnx to nikt none
## IMPORTS
from point import kernel, XMPPBot, Object
from point.utils import error, run_thr
## basic imports
import logging
import _thread
import time
## default config
cfg = Object()
cfg.server = "localhost"
cfg.username = "zelf"
cfg.channel = "#point"
cfg.nick = "point"
cfg.start = "xmpp"
cfg.user = "zelf@localhost"
## start_xmpp function
[docs]def start_xmpp(cfg):
logging.warn("using cfg %s" % cfg)
try: cfg.username, cfg.server = cfg.user.split("@")
except ValueError: pass
bot = XMPPBot(cfg)
run_thr(bot.begin, ())
run_thr(bot.loop, ())
kernel.fleet.append(bot)
[docs]def init():
new_cfg = kernel.last("start", "xmpp")
if not new_cfg: new_cfg = cfg ; new_cfg.save()
start_xmpp(new_cfg)