Implement more and next features as module instead of part of core
This commit is contained in:
parent
81593a493b
commit
dcce36eb7c
20
bot.py
20
bot.py
@ -536,26 +536,6 @@ class Bot(threading.Thread):
|
||||
if msg.cmds[0] == "help":
|
||||
return _help_msg(msg.sender, self.modules, msg.cmds)
|
||||
|
||||
elif msg.cmds[0] == "more":
|
||||
if msg.receivers == srv.nick:
|
||||
if msg.sender in srv.moremessages:
|
||||
return srv.moremessages[msg.sender]
|
||||
else:
|
||||
if msg.receivers in srv.moremessages:
|
||||
return srv.moremessages[msg.receivers]
|
||||
|
||||
elif msg.cmds[0] == "next":
|
||||
ret = None
|
||||
if msg.receivers == srv.nick:
|
||||
if msg.sender in srv.moremessages:
|
||||
ret = srv.moremessages[msg.sender]
|
||||
else:
|
||||
if msg.receivers in srv.moremessages:
|
||||
ret = srv.moremessages[msg.receivers]
|
||||
if ret is not None:
|
||||
ret.pop()
|
||||
return ret
|
||||
|
||||
elif msg.cmds[0] == "dcc":
|
||||
logger.debug("dcctest for %s", msg.sender)
|
||||
srv.send_dcc("Hello %s!" % msg.nick, msg.sender)
|
||||
|
59
modules/more.py
Normal file
59
modules/more.py
Normal file
@ -0,0 +1,59 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Nemubot is a smart and modulable IM bot.
|
||||
# Copyright (C) 2012-2014 nemunaire
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Progressive display of very long messages"""
|
||||
|
||||
from hooks import hook
|
||||
|
||||
nemubotversion = 3.4
|
||||
|
||||
SERVERS = dict()
|
||||
|
||||
@hook("all_post")
|
||||
def parseresponse(res):
|
||||
# TODO: handle inter-bot communication NOMORE
|
||||
# TODO: check that the response is not the one already saved
|
||||
if not res.alone:
|
||||
if res.server not in SERVERS:
|
||||
SERVERS[res.server] = dict()
|
||||
for receiver in res.receivers:
|
||||
SERVERS[res.server][receiver] = res
|
||||
return True
|
||||
|
||||
|
||||
@hook("cmd_hook", "more")
|
||||
def cmd_more(msg):
|
||||
"""Display next chunck of the message"""
|
||||
res = list()
|
||||
if msg.server in SERVERS:
|
||||
for receiver in msg.receivers:
|
||||
if receiver in SERVERS[msg.server]:
|
||||
res.append(SERVERS[msg.server][receiver])
|
||||
return res
|
||||
|
||||
|
||||
@hook("cmd_hook", "next")
|
||||
def cmd_next(msg):
|
||||
"""Display the next information include in the message"""
|
||||
res = list()
|
||||
if msg.server in SERVERS:
|
||||
for receiver in msg.receivers:
|
||||
if receiver in SERVERS[msg.server]:
|
||||
SERVERS[msg.server][receiver].pop()
|
||||
res.append(SERVERS[msg.server][receiver])
|
||||
return res
|
Loading…
Reference in New Issue
Block a user