Updating the irc2chan command

This commit is contained in:
Griatch 2014-02-26 23:34:44 +01:00
parent ab6dcc605d
commit 0d071ec75f
2 changed files with 10 additions and 7 deletions

View file

@ -7,16 +7,14 @@ make sure to homogenize self.caller to always be the player object
for easy handling. for easy handling.
""" """
import time
from django.conf import settings from django.conf import settings
from src.comms.models import ChannelDB, Msg, ExternalChannelConnection from src.comms.models import ChannelDB, Msg
#from src.comms import irc, imc2, rss #from src.comms import irc, imc2, rss
from src.players.models import PlayerDB from src.players.models import PlayerDB
from src.players import bots from src.players import bots
from src.comms.channelhandler import CHANNELHANDLER from src.comms.channelhandler import CHANNELHANDLER
from src.utils import create, utils, prettytable from src.utils import create, utils, prettytable
from src.utils.utils import make_iter from src.utils.utils import make_iter
from src.utils import create
from src.commands.default.muxcommand import MuxCommand, MuxPlayerCommand from src.commands.default.muxcommand import MuxCommand, MuxPlayerCommand
# limit symbol import for API # limit symbol import for API
@ -798,10 +796,14 @@ class CmdIRC2Chan(MuxCommand):
if 'list' in self.switches: if 'list' in self.switches:
# show all connections # show all connections
ircbots = [bot.typeclass for bot in PlayerDB.filter(db_isbot=True)] ircbots = [bot.typeclass for bot in PlayerDB.objects.filter(db_is_bot=True)]
if ircbots: if ircbots:
string = "{wIRC connections:{n\n%s" % ircbots from src.utils.evtable import EvTable
self.caller.msg(string) table = EvTable("dbid", "botname", "ev-channel", "irc-channel", width=78, border_width=1)
for ircbot in ircbots:
ircinfo = "%s (%s:%s)" % (ircbot.db.irc_channel, ircbot.db.irc_network, ircbot.db.irc_port)
table.add_row(ircbot.id, ircbot.db.irc_botname, ircbot.db.ev_channel, ircinfo)
self.caller.msg(table)
else: else:
self.msg("No irc bots found.") self.msg("No irc bots found.")
return return

View file

@ -40,7 +40,8 @@ class IRCBot(irc.IRCClient, Session):
self.uid = self.factory.uid self.uid = self.factory.uid
self.logged_in = True self.logged_in = True
self.factory.sessionhandler.connect(self) self.factory.sessionhandler.connect(self)
logger.log_infomsg("IRC bot connected") logger.log_infomsg("IRC bot '%s' connected to %s at %s:%s." % (self.nickname, self.channel,
self.network, self.port))
def privmsg(self, user, channel, msg): def privmsg(self, user, channel, msg):
"A message was sent to channel" "A message was sent to channel"