Source code for core.plugs.xmpp

# core/plugs/xmpp.py
#
#

""" xmpp related stuff. """

__copyright__ = "Copyright 2014 B.H.J Thate"

## IMPORTS

from core.utils import error, run_thr
from core import kernel, Object
from core.bots import XMPPBot

import logging
import _thread
import time

## CONFIG

cfg = Object()
cfg.server = "localhost"
cfg.username = "core"
cfg.channel = "#core"
cfg.nick = "core"
cfg.ctype = "xmpp"
cfg.user = "core@localhost"

## INIT

[docs]def init(*args, **kwargs): new_cfg = kernel.last("ctype", "xmpp") if not new_cfg: new_cfg = cfg ; new_cfg.save() try: new_cfg.username, new_cfg.server = new_cfg.user.split("@") except ValueError: pass bot = XMPPBot(new_cfg) kernel.fleet.append(bot) run_thr(bot.loop, ()) run_thr(bot.start, ())