Now able to respond to commands sent in PM. Minor qdb command fix. Added a misc module.
This commit is contained in:
parent
646ebb0004
commit
e8b41a3b2f
13
bot.py
13
bot.py
|
@ -81,8 +81,12 @@ class Bot:
|
|||
if cmd in m.keys():
|
||||
con.log( 'CMD \'{}\' run in ({}) by <{}> with parms: {}'.format(
|
||||
cmd, chan, nick, parms ) )
|
||||
# if msg was sent as pm,
|
||||
# change dst to nick so say_to's can respond in pm
|
||||
if chan == self.cfg['user']['nick']: chan = nick
|
||||
self._loop.create_task( m[cmd](
|
||||
self, parms, {'con': con,'dst': chan,'nick': nick} ) )
|
||||
break
|
||||
|
||||
# core commands
|
||||
|
||||
|
@ -141,7 +145,7 @@ async def cmd_list( bot, p, ctx ):
|
|||
|
||||
cmdlist = [list( c.keys() ) for c in _MOD_MAP.values()]
|
||||
|
||||
con.say_to( ctx['dst'], '>: {}'.format( cmdlist ) )
|
||||
con.say_to( ctx['dst'], '> {}'.format( cmdlist ) )
|
||||
|
||||
# reload a specified module
|
||||
@command( 'reload' )
|
||||
|
@ -151,16 +155,16 @@ async def cmd_import( bot, p, ctx ):
|
|||
if ctx['nick'] != con.cfg['usr']['owner']: return
|
||||
dst = ctx['dst']
|
||||
if p and p[0] in _MOD_MAP.keys():
|
||||
prevMod = None
|
||||
prev_mod = None
|
||||
try:
|
||||
prevMod = _MOD_MAP.pop( p[0], None )
|
||||
prev_mod = _MOD_MAP.pop( p[0], None )
|
||||
# if not reloading root bot module, re-append the modules. package name
|
||||
if p[0] != 'bot': p[0] = 'modules.' + p[0]
|
||||
importlib.reload( sys.modules[p[0]] )
|
||||
con.say_to( dst, 'Success!' )
|
||||
except Exception as e:
|
||||
con.say_to( dst, str( e ) )
|
||||
_MOD_MAP[p[0]] = prevMod
|
||||
_MOD_MAP[p[0]] = prev_mod
|
||||
else: con.say_to( dst, 'Module not found' )
|
||||
|
||||
# connect to a new server
|
||||
|
@ -194,4 +198,5 @@ async def cmd_discon( b, p, c ):
|
|||
|
||||
# custom modules
|
||||
importlib.import_module( '.qdb', 'modules' )
|
||||
importlib.import_module( '.misc', 'modules' )
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
"""
|
||||
misc
|
||||
"""
|
||||
|
||||
from bot import command
|
||||
|
||||
@command( 'owo' )
|
||||
async def cmd_owo( b, p, c ):
|
||||
c['con'].say_to( c['dst'], 'nou' )
|
||||
|
|
@ -86,6 +86,8 @@ async def get_quote( bot, parms, ctx ):
|
|||
# if too many lines for spam filter, try to find a shorter one
|
||||
while not spam and len( qt_lines ) > 5:
|
||||
#for q in qts:
|
||||
if not qts:
|
||||
qt_lines = None; break
|
||||
qt_lines = qts.pop().text.strip().split('\n')
|
||||
|
||||
if not qt_lines:
|
||||
|
|
Loading…
Reference in New Issue