# -*- coding: utf-8 -*-
+from logging.config import fileConfig
+fileConfig('logging.ini')
import pika
from distbot.common.action import Action, send_action
-from distbot.common.config import conf_set, conf_get, log_format
+from distbot.common.config import conf_set, conf_get
from distbot.common.message import process_message
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
-
logger = logging.getLogger(__name__)
-
EVENTLOOP_DELAY = 0.1
if action.msg: # and rate_limit(RATE_CHAT | plugin.ratelimit_class):
time.sleep(delay)
- self.bot.echo(action.msg)
+ self.bot.echo(action.msg, action.recipient)
# TODO test that
if action.priv_msg: # and rate_limit(RATE_CHAT | plugin.ratelimit_class):
request_counter = int(conf_get('request_counter'))
conf_set('request_counter', request_counter + 1)
-
import sleekxmpp
from distbot.bot import action_worker, worker as worker_mod
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.message import process_message, get_nick_from_message
from distbot.plugins import basic, fun, lookup, url, feeds, muc, translation, searx, queue_management, plugin_help, \
morse, meta, \
extended, bugtracker, bots, bofh
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
-
logger = logging.getLogger(__name__)
logging.getLogger("pika").setLevel(logging.WARN)
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('groupchat_message', self.muc_message)
+ self.add_event_handler('message', self.message_handler)
for room in self.rooms:
self.add_event_handler('muc::%s::got_online' % room, self.muc_online)
return False
return self.message(msg)
+ def message_handler(self, msg):
+ # disabled, as currently history leaks from groupchat chats
+ return False
+ # if msg["type"] == "groupchat":
+ # # that's a dup
+ # return False
+ # else:
+ # self.message(msg)
+
def muc_online(self, msg):
sender = get_nick_from_message(msg)
if sender == self.nick:
key.insert(0, "nick")
offset = len(self.nick) + 1
+ if msg["type"] == "groupchat":
+ recipient = msg["mucroom"]
+ else:
+ recipient = msg["from"].jid
+
process_message(
routing_key='.'.join(key)[:255],
body=json.dumps({
"from": msg["from"].jid,
- "to": msg["to"].jid,
+ "to": recipient,
"body": msg["body"][offset:].strip()
})
)
- def echo(self, body, room=None):
- if not room:
+ def echo(self, body, recipient=None):
+ if not recipient:
rooms = self.rooms
else:
- rooms = [room]
+ rooms = [recipient]
for r in rooms:
- self.send_message(
- mto=r,
- mbody=body,
- mtype='groupchat'
- )
+ if recipient.split("/")[0] in self.rooms:
+ self.send_message(
+ mto=r,
+ mbody=body,
+ mtype='groupchat' if recipient in self.rooms else 'chat'
+ )
def run():
from functools import partial
from distbot.common.action import Action, send_action
-from distbot.common.config import conf_get, log_format
-
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
+from distbot.common.config import conf_get
logger = logging.getLogger(__name__)
logger.debug("no action taken")
return
action.sender = body["from"]
+ action.recipient = body["to"]
send_action(self.actionqueue, action)
if ack:
priv_msg = None
presence = None
sender = None
+ recipient = None
# TODO: Event(Action)?
stop_event = None
self.priv_msg = kwargs.get('priv_msg')
self.presence = kwargs.get('presence')
self.sender = kwargs.get('sender')
+ self.recipient = kwargs.get('recipient')
self.event = kwargs.get('event')
self.stop_event = kwargs.get('stop_event')
from configobj import ConfigObj
from validate import Validator
-# log_format = ' %(asctime)s %(process)d %(thread)d %(levelname).1s %(funcName)-15s %(message)s'
-# TODO: log config files?
-log_format = '%(levelname).1s %(funcName)-15s %(message)s'
-logging.basicConfig(
- level=logging.INFO,
- format=log_format
-)
-
logger = logging.getLogger(__name__)
-logging.getLogger('sleekxmpp').setLevel(logging.INFO)
-
def conf_get(key):
return Config().get(key)
# TODO: can't remember the reason for this one
# disabled for now.
# self.config_store.write()
- self.runtime_config_store.write()
+ # self.runtime_config_store.write()
+ pass
def _set(self, cfg, path, value):
if len(path) == 1:
bot_owner_email = string
detectlanguage_api_key = string
-loglevel = option('ERROR', WARN', 'INFO', 'DEBUG', default='INFO')
-debug_mode = boolean(default=false)
-
# rate limiting, TODO
hist_max_count = integer(default=5)
hist_max_time = integer(default=10*60)
from sleekxmpp import Message, Presence
from sleekxmpp.jid import JID
-from distbot.common.config import conf_get, log_format
-
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
-
logger = logging.getLogger(__name__)
import requests
from functools import wraps
-from distbot.common.config import log_format, conf_get
-
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
BUFSIZ = 8192
from distbot.bot.worker import Worker
from distbot.common import config
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.message import get_nick_from_message, get_words
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.message import get_nick_from_message
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.utils import extract_title
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, conf_set, log_format
+from distbot.common.config import conf_get, conf_set
from distbot.common.message import get_words
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.message import get_nick_from_message, get_words
from distbot.common.utils import giphy
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.message import get_nick_from_message, get_words
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.message import get_nick_from_message, get_words
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.message import get_words
from distbot.common.utils import retry
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, log_format
+from distbot.common.config import conf_get
from distbot.common.message import get_nick_from_message, get_words
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get, conf_set, log_format
+from distbot.common.config import conf_get, conf_set
from distbot.common.message import get_nick_from_message, get_words
-logging.basicConfig(
- level=conf_get("loglevel"),
- format=log_format
-)
logger = logging.getLogger(__name__)
--- /dev/null
+[loggers]
+keys=root
+
+[handlers]
+keys=stream_handler
+
+[formatters]
+keys=formatter
+
+[logger_root]
+level=DEBUG
+handlers=stream_handler
+
+[handler_stream_handler]
+class=StreamHandler
+level=DEBUG
+formatter=formatter
+args=(sys.stderr,)
+
+[formatter_formatter]
+format=%(levelname).1s %(funcName)-15s %(message)s