Commit a98bcd64 authored by Guillaume Binet's avatar Guillaume Binet

Added modules as logger names.

This allow a clearer view in the log and a better fine grained filtering
of the verbosity.
parent ca90d691
......@@ -14,6 +14,8 @@ from errbot.utils import get_sender_username, xhtml2txt, parse_jid, split_string
from errbot.templating import tenv
from errbot.bundled.threadpool import ThreadPool, WorkRequest
log = logging.getLogger(__name__)
class ACLViolation(Exception):
"""Exceptions raised when user is not allowed to execute given command due to ACLs"""
......@@ -628,7 +630,7 @@ def build_text_html_message_pair(source):
text_plain = xhtml2txt(source)
except ParseError as ee:
if source.strip(): # avoids keep alive pollution
logging.debug('Could not parse [%s] as XHTML-IM, assume pure text Parsing error = [%s]' % (source, ee))
log.debug('Could not parse [%s] as XHTML-IM, assume pure text Parsing error = [%s]' % (source, ee))
text_plain = source
except UnicodeEncodeError:
text_plain = source
......@@ -652,10 +654,10 @@ def build_message(text, message_class, conversion_function=None):
message = message_class(body=text_plain)
message.html = node
except ET.ParseError as ee:
logging.error('Error translating to hipchat [%s] Parsing error = [%s]' % (edulcorated_html, ee))
log.error('Error translating to hipchat [%s] Parsing error = [%s]' % (edulcorated_html, ee))
except ET.ParseError as ee:
if text.strip(): # avoids keep alive pollution
logging.debug('Determined that [%s] is not XHTML-IM (%s)' % (text, ee))
log.debug('Determined that [%s] is not XHTML-IM (%s)' % (text, ee))
message = message_class(body=text)
return message
......@@ -681,7 +683,7 @@ class Backend(object):
if config.BOT_ASYNC:
self.thread_pool = ThreadPool(3)
logging.debug('created the thread pool' + str(self.thread_pool))
log.debug('created the thread pool' + str(self.thread_pool))
self.commands = {} # the dynamically populated list of commands available on the bot
self.re_commands = {} # the dynamically populated list of regex-based commands available on the bot
self.MSG_UNKNOWN_COMMAND = 'Unknown command: "%(command)s". ' \
......@@ -759,11 +761,11 @@ class Backend(object):
user_cmd_history = self.cmd_history[username]
if mess.delayed:
logging.debug("Message from history, ignore it")
log.debug("Message from history, ignore it")
return False
if type_ not in ("groupchat", "chat"):
logging.debug("unhandled message type %s" % mess)
log.debug("unhandled message type %s" % mess)
return False
# Ignore messages from ourselves. Because it isn't always possible to get the
......@@ -774,13 +776,13 @@ class Backend(object):
# covers 99% of the MUC cases, so it should suffice for the time being.
if (jid.bare_match(self.jid) or
type_ == "groupchat" and mess.nick == self.bot_config.CHATROOM_FN): # noqa
logging.debug("Ignoring message from self")
log.debug("Ignoring message from self")
return False
logging.debug("*** jid = %s" % jid)
logging.debug("*** username = %s" % username)
logging.debug("*** type = %s" % type_)
logging.debug("*** text = %s" % text)
log.debug("*** jid = %s" % jid)
log.debug("*** username = %s" % username)
log.debug("*** type = %s" % type_)
log.debug("*** text = %s" % text)
# If a message format is not supported (eg. encrypted),
# txt will be None
......@@ -803,7 +805,7 @@ class Backend(object):
l = len(prefix)
if tomatch.startswith(prefix) and l > longest:
longest = l
logging.debug("Called with alternate prefix '{}'".format(text[:longest]))
log.debug("Called with alternate prefix '{}'".format(text[:longest]))
text = text[longest:]
# Now also remove the separator from the text
......@@ -814,7 +816,7 @@ class Backend(object):
if text[:l] == sep:
text = text[l:]
elif type_ == "chat" and self.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT:
logging.debug("Assuming '%s' to be a command because BOT_PREFIX_OPTIONAL_ON_CHAT is True" % text)
log.debug("Assuming '%s' to be a command because BOT_PREFIX_OPTIONAL_ON_CHAT is True" % text)
# In order to keep noise down we surpress messages about the command
# not being found, because it's possible a plugin will trigger on what
# was said with trigger_message.
......@@ -872,22 +874,22 @@ class Backend(object):
else:
match = func._err_command_re_pattern.search(text)
if match:
logging.debug("Matching '{}' against '{}' produced a match"
.format(text, func._err_command_re_pattern.pattern))
log.debug("Matching '{}' against '{}' produced a match"
.format(text, func._err_command_re_pattern.pattern))
matched_on_re_command = True
self._process_command(mess, name, text, match)
else:
logging.debug("Matching '{}' against '{}' produced no match"
.format(text, func._err_command_re_pattern.pattern))
log.debug("Matching '{}' against '{}' produced no match"
.format(text, func._err_command_re_pattern.pattern))
if matched_on_re_command:
return True
if cmd:
self._process_command(mess, cmd, args, match=None)
elif not only_check_re_command:
logging.debug("Command not found")
log.debug("Command not found")
if surpress_cmd_not_found:
logging.debug("Surpressing command not found feedback")
log.debug("Surpressing command not found feedback")
else:
reply = self.unknown_command(mess, command, args)
if reply is None:
......@@ -903,7 +905,7 @@ class Backend(object):
username = get_sender_username(mess)
user_cmd_history = self.cmd_history[username]
logging.info("Processing command '{}' with parameters '{}' from {}/{}".format(cmd, args, jid, mess.nick))
log.info("Processing command '{}' with parameters '{}' from {}/{}".format(cmd, args, jid, mess.nick))
if (cmd, args) in user_cmd_history:
user_cmd_history.remove((cmd, args)) # Avoids duplicate history items
......@@ -996,9 +998,9 @@ class Backend(object):
send_reply(process_reply(reply))
except Exception as e:
tb = traceback.format_exc()
logging.exception('An error happened while processing '
'a message ("%s") from %s: %s"' %
(mess.body, jid, tb))
log.exception('An error happened while processing '
'a message ("%s") from %s: %s"' %
(mess.body, jid, tb))
send_reply(self.MSG_ERROR_OCCURRED + ':\n %s' % e)
def is_admin(self, usr):
......@@ -1084,10 +1086,10 @@ class Backend(object):
commands[name] = value
if getattr(value, '_err_re_command'):
logging.debug('Adding regex command : %s -> %s' % (name, value.__name__))
log.debug('Adding regex command : %s -> %s' % (name, value.__name__))
self.re_commands = commands
else:
logging.debug('Adding command : %s -> %s' % (name, value.__name__))
log.debug('Adding command : %s -> %s' % (name, value.__name__))
self.commands = commands
def remove_commands_from(self, instance_to_inject):
......
import logging
import sys
from errbot.backends.base import Message, build_message, Identifier
from errbot.errBot import ErrBot
from threading import Condition
log = logging.getLogger(__name__)
try:
import pyfire
except ImportError:
logging.exception("Could not start the campfire backend")
logging.fatal("""
log.exception("Could not start the campfire backend")
log.fatal("""
If you intend to use the campfire backend please install pyfire:
pip install pyfire
""")
sys.exit(-1)
from errbot.backends.base import Message, build_message, Identifier
from errbot.errBot import ErrBot
from threading import Condition
class CampfireConnection(pyfire.Campfire):
rooms = {} # keep track of joined room so we can send messages directly to them
......@@ -57,7 +59,7 @@ class CampfireBackend(ErrBot):
room = self.conn.rooms[room_name][0]
room.speak(mess.body) # Basic text support for the moment
else:
logging.info(
log.info(
"Attempted to send a message to a not connected room yet Room %s : %s" % (room_name, mess.body))
def serve_forever(self):
......@@ -65,7 +67,7 @@ class CampfireBackend(ErrBot):
self.connect() # be sure we are "connected" before the first command
self.connect_callback() # notify that the connection occured
try:
logging.info("Campfire connected.")
log.info("Campfire connected.")
self.exit_lock.wait()
except KeyboardInterrupt:
pass
......@@ -91,7 +93,7 @@ class CampfireBackend(ErrBot):
super(CampfireBackend, self).shutdown()
def msg_callback(self, message):
logging.debug('Incoming message [%s]' % message)
log.debug('Incoming message [%s]' % message)
user = ""
if message.user:
user = message.user.name
......@@ -102,7 +104,7 @@ class CampfireBackend(ErrBot):
self.callback_message(msg)
def error_callback(self, error, room):
logging.error("Stream STOPPED due to ERROR: %s in room %s" % (error, room))
log.error("Stream STOPPED due to ERROR: %s in room %s" % (error, room))
self.exit_lock.acquire()
self.exit_lock.notify()
self.exit_lock.release()
......
import logging
import sys
import os
import re
import sys
import errbot
from errbot.backends.base import Message, build_text_html_message_pair, Identifier
from errbot.backed.text import TextBackend # we use that as we emulate MUC there already
from errbot.utils import mess_2_embeddablehtml
log = logging.getLogger(__name__)
try:
from PySide import QtCore, QtGui, QtWebKit
from PySide.QtGui import QCompleter
from PySide.QtCore import Qt, QUrl, QObject
from PySide.QtCore import Qt, QObject
except ImportError:
logging.exception("Could not start the graphical backend")
logging.fatal("""
log.exception("Could not start the graphical backend")
log.fatal("""
If you intend to use the graphical backend please install PySide:
-> On debian-like systems
sudo apt-get install python-software-properties
......@@ -22,11 +29,6 @@ except ImportError:
""")
sys.exit(-1)
import os
import errbot
from errbot.backends.base import Message, build_text_html_message_pair, Identifier
from errbot.backed.text import TextBackend # we use that as we emulate MUC there already
class CommandBox(QtGui.QPlainTextEdit, object):
newCommand = QtCore.Signal(str)
......@@ -106,7 +108,7 @@ class CommandBox(QtGui.QPlainTextEdit, object):
super(CommandBox, self).keyPressEvent(*args, **kwargs)
class ConnectionMock(QtCore.QObject):
class ConnectionMock(QObject):
newAnswer = QtCore.Signal(str, bool)
def send_message(self, mess):
......
......@@ -4,8 +4,8 @@ import sys
try:
import hypchat
except ImportError:
logging.exception("Could not start the HipChat backend")
logging.fatal(
log.exception("Could not start the HipChat backend")
log.fatal(
"You need to install the hypchat package in order to use the HipChat "
"back-end. You should be able to install this package using: "
"pip install hypchat"
......@@ -62,7 +62,7 @@ class HipChatMUCRoom(MUCRoom):
Return room information from the HipChat API
"""
try:
logging.debug("Querying HipChat API for room {}".format(self.name))
log.debug("Querying HipChat API for room {}".format(self.name))
return self.hypchat.get_room(self.name)
except hypchat.requests.HttpNotFound:
raise RoomDoesNotExistError("The given room does not exist.")
......@@ -122,7 +122,7 @@ class HipChatMUCRoom(MUCRoom):
)
holder.bot.callback_room_joined(self)
logging.info("Joined room {}".format(self.name))
log.info("Joined room {}".format(self.name))
def leave(self, reason=None):
"""
......@@ -144,10 +144,10 @@ class HipChatMUCRoom(MUCRoom):
"muc::{}::got_offline".format(room),
holder.bot.user_left_chat
)
logging.info("Left room {}".format(self))
log.info("Left room {}".format(self))
holder.bot.callback_room_left(self)
except KeyError:
logging.debug("Trying to leave {} while not in this room".format(self))
log.debug("Trying to leave {} while not in this room".format(self))
def create(self, privacy="public", guest_access=False):
"""
......@@ -162,14 +162,14 @@ class HipChatMUCRoom(MUCRoom):
Whether or not to enable guest access for this room.
"""
if self.exists:
logging.debug("Tried to create the room {}, but it has already been created".format(self))
log.debug("Tried to create the room {}, but it has already been created".format(self))
else:
self.hypchat.create_room(
name=self.name,
privacy=privacy,
guest_access=guest_access
)
logging.info("Created room {}".format(self))
log.info("Created room {}".format(self))
def destroy(self):
"""
......@@ -179,9 +179,9 @@ class HipChatMUCRoom(MUCRoom):
"""
try:
self.room.delete()
logging.info("Destroyed room {}".format(self))
log.info("Destroyed room {}".format(self))
except RoomDoesNotExistError:
logging.debug("Can't destroy room {}, it doesn't exist".format(self))
log.debug("Can't destroy room {}, it doesn't exist".format(self))
@property
def exists(self):
......@@ -227,7 +227,7 @@ class HipChatMUCRoom(MUCRoom):
The topic to set.
"""
self.room.topic(topic)
logging.debug("Changed topic of {} to {}".format(self, topic))
log.debug("Changed topic of {} to {}".format(self, topic))
@property
def occupants(self):
......@@ -266,9 +266,9 @@ class HipChatMUCRoom(MUCRoom):
else:
if room['privacy'] == "private":
room.members().add(user)
logging.info("Added {} to private room {}".format(user['name'], self))
log.info("Added {} to private room {}".format(user['name'], self))
room.invite(user, "No reason given.")
logging.info("Invited {} to {}".format(person, self))
log.info("Invited {} to {}".format(person, self))
def notify(self, message, color=None, notify=False, message_format=None):
"""
......@@ -370,13 +370,13 @@ class HipchatBackend(XMPPBackend):
An instance of :class:`~HipChatMUCRoom`.
"""
if room.endswith('@conf.hipchat.com'):
logging.debug("Room specified by JID, looking up room name")
log.debug("Room specified by JID, looking up room name")
rooms = self.conn.hypchat.rooms(expand='items')
try:
name = [r['name'] for r in rooms['items'] if r['xmpp_jid'] == room][0]
except IndexError:
raise RoomDoesNotExistError("No room with JID {} found.".format(room))
logging.info("Found {} to be the room {}, consider specifying this directly.".format(room, name))
log.info("Found {} to be the room {}, consider specifying this directly.".format(room, name))
else:
name = room
......
......@@ -15,8 +15,8 @@ try:
import irc.connection
from irc.bot import SingleServerIRCBot
except ImportError as _:
logging.exception("Could not start the IRC backend")
logging.fatal("""
log.exception("Could not start the IRC backend")
log.fatal("""
If you intend to use the IRC backend please install the python irc package:
-> On debian-like systems
sudo apt-get install python-software-properties
......@@ -43,14 +43,14 @@ class IRCMUCRoom(MUCRoom):
:meth:`create` on it first.
"""
if username is not None:
logging.debug("Ignored username parameter on join(), it is unsupported on this back-end.")
log.debug("Ignored username parameter on join(), it is unsupported on this back-end.")
if password is None:
password = ""
room = str(self)
self.connection.join(room, key=password)
holder.bot.callback_room_joined(self)
logging.info("Joined room {}".format(room))
log.info("Joined room {}".format(room))
def leave(self, reason=None):
"""
......@@ -64,7 +64,7 @@ class IRCMUCRoom(MUCRoom):
room = str(self)
self.connection.part(room, reason)
logging.info("Left room {}".format(room))
log.info("Left room {}".format(room))
holder.bot.callback_room_left(self)
def create(self):
......@@ -156,7 +156,7 @@ class IRCMUCRoom(MUCRoom):
room = str(self)
for nick in args:
self.connection.invite(nick, room)
logging.info("Invited {} to {}".format(nick, room))
log.info("Invited {} to {}".format(nick, room))
class IRCConnection(SingleServerIRCBot):
......@@ -189,7 +189,7 @@ class IRCConnection(SingleServerIRCBot):
self.connection.connect(*args, **kwargs)
def on_welcome(self, _, e):
logging.info("IRC welcome %s" % e)
log.info("IRC welcome %s" % e)
self.callback.connect_callback()
def on_pubmsg(self, _, e):
......@@ -246,9 +246,9 @@ class IRCBackend(ErrBot):
try:
self.conn.start()
finally:
logging.debug("Trigger disconnect callback")
log.debug("Trigger disconnect callback")
self.disconnect_callback()
logging.debug("Trigger shutdown")
log.debug("Trigger shutdown")
self.shutdown()
def connect(self):
......
......@@ -3,6 +3,8 @@ from time import sleep
from errbot.backends.base import Message, Identifier, build_text_html_message_pair
from errbot.errBot import ErrBot
log = logging.getLogger(__name__)
class ConnectionMock():
def send(self, mess):
......@@ -32,9 +34,9 @@ class NullBackend(ErrBot):
except KeyboardInterrupt:
pass
finally:
logging.debug("Trigger disconnect callback")
log.debug("Trigger disconnect callback")
self.disconnect_callback()
logging.debug("Trigger shutdown")
log.debug("Trigger shutdown")
self.shutdown()
def connect(self):
......
......@@ -8,6 +8,7 @@ from threading import Thread
import pytest
log = logging.getLogger(__name__)
__import__('errbot.config-template')
config_module = sys.modules['errbot.config-template']
......@@ -82,12 +83,12 @@ class MUCRoom(MUCRoom):
return
if not self.exists:
logging.debug("Room {!s} doesn't exist yet, creating it".format(self))
log.debug("Room {!s} doesn't exist yet, creating it".format(self))
self.create()
room = [r for r in rooms if str(r) == str(self)][0]
room._occupants.append(MUCOccupant(bot_itself))
logging.info("Joined room {!s}".format(self))
log.info("Joined room {!s}".format(self))
bot.callback_room_joined(room)
def leave(self, reason=None):
......@@ -102,7 +103,7 @@ class MUCRoom(MUCRoom):
room = [r for r in rooms if str(r) == str(self)][0]
room._occupants = [o for o in room._occupants if str(o) != bot_itself]
logging.info("Left room {!s}".format(self))
log.info("Left room {!s}".format(self))
bot.callback_room_left(room)
@property
......@@ -116,7 +117,7 @@ class MUCRoom(MUCRoom):
logging.warning("Room {!s} already created".format(self))
else:
rooms.append(self)
logging.info("Created room {!s}".format(self))
log.info("Created room {!s}".format(self))
def destroy(self):
global rooms
......@@ -124,7 +125,7 @@ class MUCRoom(MUCRoom):
logging.warning("Cannot destroy room {!s}, it doesn't exist".format(self))
else:
rooms = [r for r in rooms if str(r) != str(self)]
logging.info("Destroyed room {!s}".format(self))
log.info("Destroyed room {!s}".format(self))
@property
def topic(self):
......@@ -136,7 +137,7 @@ class MUCRoom(MUCRoom):
self._topic = topic
room = [r for r in rooms if str(r) == str(self)][0]
room._topic = self._topic
logging.info("Topic for room {!s} set to '{}'".format(self, topic))
log.info("Topic for room {!s} set to '{}'".format(self, topic))
from errbot.holder import bot
bot.callback_room_topic(self)
......@@ -158,7 +159,7 @@ class TestBackend(ErrBot):
while True:
stanza_type, entry = incoming_stanza_queue.get()
if entry == QUIT_MESSAGE:
logging.info("Stop magic message received, quitting...")
log.info("Stop magic message received, quitting...")
break
if stanza_type is STZ_MSG:
msg = Message(entry)
......@@ -166,21 +167,21 @@ class TestBackend(ErrBot):
msg.to = self.jid # To me only
self.callback_message(msg)
elif stanza_type is STZ_PRE:
logging.info("Presence stanza received.")
log.info("Presence stanza received.")
self.callback_presence(entry)
elif stanza_type is STZ_IQ:
logging.info("IQ stanza received.")
log.info("IQ stanza received.")
else:
logging.error("Unknown stanza type.")
log.error("Unknown stanza type.")
except EOFError:
pass
except KeyboardInterrupt:
pass
finally:
logging.debug("Trigger disconnect callback")
log.debug("Trigger disconnect callback")
self.disconnect_callback()
logging.debug("Trigger shutdown")
log.debug("Trigger shutdown")
self.shutdown()
def connect(self):
......@@ -232,11 +233,11 @@ def push_presence(presence):
def zap_queues():
while not incoming_stanza_queue.empty():
msg = incoming_stanza_queue.get(block=False)
logging.error('Message left in the incoming queue during a test : %s' % msg)
log.error('Message left in the incoming queue during a test : %s' % msg)
while not outgoing_message_queue.empty():
msg = outgoing_message_queue.get(block=False)
logging.error('Message left in the outgoing queue during a test : %s' % msg)
log.error('Message left in the outgoing queue during a test : %s' % msg)
def reset_rooms():
......@@ -307,7 +308,7 @@ class TestBot(object):
push_message(QUIT_MESSAGE)
self.bot_thread.join()
reset_app() # empty the bottle ... hips!
logging.info("Main bot thread quits")
log.info("Main bot thread quits")
zap_queues()
reset_rooms()
self.bot_thread = None
......
......@@ -3,6 +3,7 @@ import sys
from errbot.backends.base import Message, build_message, Identifier, Presence, ONLINE, OFFLINE, MUCRoom, MUCOccupant
from errbot.errBot import ErrBot
from errbot.utils import deprecated
log = logging.getLogger(__name__)
ENCODING_INPUT = sys.stdin.encoding
ANSI = hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()
......@@ -15,6 +16,7 @@ class TextBackend(ErrBot):
def __init__(self, config):
super().__init__(config)
log.debug("Text Backend Init.")
self.jid = Identifier('Err')
self.rooms = set()
......@@ -39,9 +41,9 @@ class TextBackend(ErrBot):
finally:
# simulate some real presence
self.callback_presence(Presence(identifier=me, status=OFFLINE))
logging.debug("Trigger disconnect callback")
log.debug("Trigger disconnect callback")
self.disconnect_callback()
logging.debug("Trigger shutdown")
log.debug("Trigger shutdown")
self.shutdown()
def send_message(self, mess):
......
This diff is collapsed.
import logging
import sys
import os.path
import warnings
from errbot.backends.base import (
......@@ -13,12 +12,14 @@ from errbot import holder
from threading import Thread
from time import sleep
log = logging.getLogger(__name__)
try:
from sleekxmpp import ClientXMPP
from sleekxmpp.xmlstream import resolver, cert
except ImportError as _:
logging.exception("Could not start the XMPP backend")
logging.fatal("""
log.exception("Could not start the XMPP backend")
log.fatal("""
If you intend to use the XMPP backend please install the python sleekxmpp package:
-> On debian-like systems
sudo apt-get install python-software-properties
......@@ -51,12 +52,12 @@ def verify_gtalk_cert(xmpp_client):
raw_cert = xmpp_client.socket.getpeercert(binary_form=True)
try:
if cert.verify('talk.google.com', raw_cert):
logging.info('google cert found for %s', xmpp_client.boundjid.server)
log.info('google cert found for %s', xmpp_client.boundjid.server)
return
except cert.CertificateError:
pass
logging.error("invalid cert received for %s", xmpp_client.boundjid.server)
log.error("invalid cert received for %s", xmpp_client.boundjid.server)
class XMPPMUCRoom(MUCRoom):
......@@ -88,7 +89,7 @@ class XMPPMUCRoom(MUCRoom):
t.setDaemon(True)
t.start()
holder.bot.callback_room_joined(self)
logging.info("Joined room {}".format(room))
log.info("Joined room {}".format(room))
def leave(self, reason=None):
"""
......@@ -111,10 +112,10 @@ class XMPPMUCRoom(MUCRoom):
"muc::{}::got_offline".format(room),
holder.bot.user_left_chat
)
logging.info("Left room {}".format(room))
log.info("Left room {}".format(room))
holder.bot.callback_room_left(self)
except KeyError:
logging.debug("Trying to leave {} while not in this room".format(room))
log.debug("Trying to leave {} while not in this room".format(room))
def create(self):
"""
......@@ -134,7 +135,7 @@ class XMPPMUCRoom(MUCRoom):
Calling this on a non-existing room is a no-op.
"""
self.xep0045.destroy(str(self))
logging.info("Destroyed room {!s}".format(self))
log.info("Destroyed room {!s}".format(self))
@property
def exists(self):
......@@ -220,7 +221,7 @@ class XMPPMUCRoom(MUCRoom):
room = str(self)
for jid in args:
self.xep0045.invite(room, jid)
logging.info("Invited {} to {}".format(jid, room))
log.info("Invited {} to {}".format(jid, room))
def configure(self):
"""
......@@ -241,12 +242,12 @@ class XMPPMUCRoom(MUCRoom):
)
if affiliation == "owner":
logging.debug("Configuring room {} because we have owner affiliation".format(room))
log.debug("Configuring room {} because we have owner affiliation".format(room))
form = self.xep0045.getRoomConfig(room)
self.xep0045.configureRoom(room, form)
else:
logging.debug("Not configuring room {} because we don't have owner affiliation (affiliation={})"
.format(room, affiliation))
log.debug("Not configuring room {} because we don't have owner affiliation (affiliation={})"
.format(room, affiliation))
class XMPPMUCOccupant(MUCOccupant):
......@@ -412,19 +413,19 @@ class XMPPBackend(ErrBot):
self.callback_message(msg)
def contact_online(self, event):
logging.debug("contact_online %s" % event)
log.debug("contact_online %s" % event)
p = Presence(identifier=Identifier(str(event['from'])),
status=ONLINE)
self.callback_presence(p)
def contact_offline(self, event):
logging.debug("contact_offline %s" % event)
log.debug("contact_offline %s" % event)
p = Presence(identifier=Identifier(str(event['from'])),
status=OFFLINE)
self.callback_presence(p)
def user_joined_chat(self, event):
logging.debug("user_join_chat %s" % event)
log.debug("user_join_chat %s" % event)
idd = Identifier(str(event['from']))
p = Presence(chatroom=idd,
nick=idd.resource,
......@@ -432,7 +433,7 @@ class XMPPBackend(ErrBot):
self.callback_presence(p)
def user_left_chat(self, event):
logging.debug("user_left_chat %s" % event)
log.debug("user_left_chat %s" % event)
idd = Identifier(str(event['from']))
p = Presence(chatroom=idd,
nick=idd.resource,
......@@ -440,7 +441,7 @@ class XMPPBackend(ErrBot):
self.callback_presence(p)
def chat_topic(self, event):
logging.debug("chat_topic %s" % event)
log.debug("chat_topic %s" % event)
room = event.values['mucroom']
topic = event.values['subject']