1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2010, 2011 Anaƫl Verrier <elghinn@free.fr>
4 # Copyright (C) 2014 kaliko <kaliko@azylum.org>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, version 3 only.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 from .sid import botcmd
21 """Simple Plugin object to derive from:
22 Exposes the bot object and its logger
23 Provides some send helpers
26 def __init__(self, bot):
28 self.log = bot.log.getChild(self.__class__.__name__)
30 def send(self, dest, msg, mtype='chat'):
34 mhtml: '<b>text</b>, # optional'
37 if isinstance(msg, str):
39 msg.setdefault('mhtml', None)
40 self.bot.send_message(mto=dest,
44 def reply(self, rcv, msg):
45 """Smart reply to message received.
46 Replies <msg> in private or on the muc depending on <rcv>
49 if rcv['type'] == 'groupchat':
51 self.send(to, msg, mtype=rcv['type'])