Made a first version of command IRC2Chan, server starts but no more testing yet.

This commit is contained in:
Griatch 2014-02-23 22:30:29 +01:00
parent 2108506a8a
commit 75ef743297
5 changed files with 337 additions and 347 deletions

13
ev.py
View file

@ -143,7 +143,7 @@ from src.locks import lockfuncs
from src.scripts.scripts import Script from src.scripts.scripts import Script
# comms # comms
from src.comms.models import Msg, ChannelDB, PlayerChannelConnection, ExternalChannelConnection from src.comms.models import Msg, ChannelDB#, PlayerChannelConnection, ExternalChannelConnection
from src.comms.comms import Channel from src.comms.comms import Channel
# objects # objects
@ -214,7 +214,7 @@ class DBmanagers(_EvContainer):
from src.help.models import HelpEntry from src.help.models import HelpEntry
from src.players.models import PlayerDB from src.players.models import PlayerDB
from src.scripts.models import ScriptDB from src.scripts.models import ScriptDB
from src.comms.models import Msg, ChannelDB, PlayerChannelConnection, ExternalChannelConnection from src.comms.models import Msg, ChannelDB#, PlayerChannelConnection, ExternalChannelConnection
from src.objects.models import ObjectDB from src.objects.models import ObjectDB
from src.server.models import ServerConfig from src.server.models import ServerConfig
from src.typeclasses.models import Tag, Attribute from src.typeclasses.models import Tag, Attribute
@ -225,15 +225,16 @@ class DBmanagers(_EvContainer):
scripts = ScriptDB.objects scripts = ScriptDB.objects
msgs = Msg.objects msgs = Msg.objects
channels = ChannelDB.objects channels = ChannelDB.objects
connections = PlayerChannelConnection.objects #connections = PlayerChannelConnection.objects
externalconnections = ExternalChannelConnection.objects #externalconnections = ExternalChannelConnection.objects
objects = ObjectDB.objects objects = ObjectDB.objects
serverconfigs = ServerConfig.objects serverconfigs = ServerConfig.objects
attributes = Attribute.objects attributes = Attribute.objects
tags = Tag.objects tags = Tag.objects
# remove these so they are not visible as properties # remove these so they are not visible as properties
del HelpEntry, PlayerDB, ScriptDB, Msg, ChannelDB, PlayerChannelConnection, del HelpEntry, PlayerDB, ScriptDB, Msg, ChannelDB#, PlayerChannelConnection,
del ExternalChannelConnection, ObjectDB, ServerConfig, Tag, Attribute #del ExternalChannelConnection
del ObjectDB, ServerConfig, Tag, Attribute
managers = DBmanagers() managers = DBmanagers()
del DBmanagers del DBmanagers

View file

@ -68,7 +68,7 @@ class PlayerCmdSet(CmdSet):
self.add(comms.CmdCdesc()) self.add(comms.CmdCdesc())
self.add(comms.CmdPage()) self.add(comms.CmdPage())
self.add(comms.CmdIRC2Chan()) self.add(comms.CmdIRC2Chan())
self.add(comms.CmdIMC2Chan()) #self.add(comms.CmdIMC2Chan())
self.add(comms.CmdIMCInfo()) #self.add(comms.CmdIMCInfo())
self.add(comms.CmdIMCTell()) #self.add(comms.CmdIMCTell())
self.add(comms.CmdRSS2Chan()) #self.add(comms.CmdRSS2Chan())

View file

@ -7,20 +7,24 @@ 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, ExternalChannelConnection
from src.comms import irc, imc2, rss #from src.comms import irc, imc2, rss
from src.players.models import PlayerDB
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
__all__ = ("CmdAddCom", "CmdDelCom", "CmdAllCom", __all__ = ("CmdAddCom", "CmdDelCom", "CmdAllCom",
"CmdChannels", "CmdCdestroy", "CmdCBoot", "CmdCemit", "CmdChannels", "CmdCdestroy", "CmdCBoot", "CmdCemit",
"CmdCWho", "CmdChannelCreate", "CmdClock", "CmdCdesc", "CmdCWho", "CmdChannelCreate", "CmdClock", "CmdCdesc",
"CmdPage", "CmdIRC2Chan", "CmdIMC2Chan", "CmdIMCInfo", "CmdPage", "CmdIRC2Chan")#, "CmdIMC2Chan", "CmdIMCInfo",
"CmdIMCTell", "CmdRSS2Chan") #"CmdIMCTell", "CmdRSS2Chan")
def find_channel(caller, channelname, silent=False, noaliases=False): def find_channel(caller, channelname, silent=False, noaliases=False):
@ -794,21 +798,19 @@ class CmdIRC2Chan(MuxCommand):
if 'list' in self.switches: if 'list' in self.switches:
# show all connections # show all connections
connections = ExternalChannelConnection.objects.filter(db_external_key__startswith='irc_') ircbots = [bot.typeclass for bot in PlayerDB.filter(db_isbot=True)]
if connections: if ircbots:
table = prettytable.PrettyTable(["Evennia channel", "IRC channel"]) string = "{wIRC connections:{n\n%s" % ircbots
for conn in connections: self.caller.msg(string)
table.add_row([conn.channel.key, " ".join(conn.external_config.split('|'))])
string = "{wIRC connections:{n\n%s" % table
self.msg(string)
else: else:
self.msg("No connections found.") self.msg("No irc bots found.")
return return
if not self.args or not self.rhs: if not self.args or not self.rhs:
string = "Usage: @irc2chan[/switches] <evennia_channel> = <ircnetwork> <port> <#irchannel> <botname>" string = "Usage: @irc2chan[/switches] <evennia_channel> = <ircnetwork> <port> <#irchannel> <botname>"
self.msg(string) self.msg(string)
return return
channel = self.lhs channel = self.lhs
self.rhs = self.rhs.replace('#', ' ') # to avoid Python comment issues self.rhs = self.rhs.replace('#', ' ') # to avoid Python comment issues
try: try:
@ -822,333 +824,320 @@ class CmdIRC2Chan(MuxCommand):
if('disconnect' in self.switches or 'remove' in self.switches or if('disconnect' in self.switches or 'remove' in self.switches or
'delete' in self.switches): 'delete' in self.switches):
chanmatch = find_channel(self.caller, channel, silent=True) botname = "ircbot-%s" % irc_botname
if chanmatch: matches = PlayerDB.filter(db_isbot=True, db_key=botname)
channel = chanmatch.key if matches:
matches[0].delete()
ok = irc.delete_connection(channel,
irc_network,
irc_port,
irc_channel,
irc_botname)
if not ok:
self.msg("IRC connection/bot could not be removed, does it exist?")
else:
self.msg("IRC connection destroyed.") self.msg("IRC connection destroyed.")
else:
self.msg("IRC connection/bot could not be removed, does it exist?")
return return
channel = find_channel(self.caller, channel) # create a new bot
if not channel: bot = create.create_player(bots.IRCBot, key=botname)
return bot.start(ev_channel=channel, irc_botname=irc_botname, irc_channel=irc_channel,
ok = irc.create_connection(channel, irc_network=irc_network, irc_port=irc_port)
irc_network,
irc_port,
irc_channel,
irc_botname)
if not ok:
self.msg("This IRC connection already exists.")
return
self.msg("Connection created. Starting IRC bot.") self.msg("Connection created. Starting IRC bot.")
class CmdIMC2Chan(MuxCommand): #class CmdIMC2Chan(MuxCommand):
""" # """
link an evennia channel to an external IMC2 channel # link an evennia channel to an external IMC2 channel
#
Usage: # Usage:
@imc2chan[/switches] <evennia_channel> = <imc2_channel> # @imc2chan[/switches] <evennia_channel> = <imc2_channel>
#
Switches: # Switches:
/disconnect - this clear the imc2 connection to the channel. # /disconnect - this clear the imc2 connection to the channel.
/remove - " # /remove - "
/list - show all imc2<->evennia mappings # /list - show all imc2<->evennia mappings
#
Example: # Example:
@imc2chan myimcchan = ievennia # @imc2chan myimcchan = ievennia
#
Connect an existing evennia channel to a channel on an IMC2 # Connect an existing evennia channel to a channel on an IMC2
network. The network contact information is defined in settings and # network. The network contact information is defined in settings and
should already be accessed at this point. Use @imcchanlist to see # should already be accessed at this point. Use @imcchanlist to see
available IMC channels. # available IMC channels.
#
""" # """
#
key = "@imc2chan" # key = "@imc2chan"
locks = "cmd:serversetting(IMC2_ENABLED) and pperm(Immortals)" # locks = "cmd:serversetting(IMC2_ENABLED) and pperm(Immortals)"
help_category = "Comms" # help_category = "Comms"
#
def func(self): # def func(self):
"Setup the imc-channel mapping" # "Setup the imc-channel mapping"
#
if not settings.IMC2_ENABLED: # if not settings.IMC2_ENABLED:
string = """IMC is not enabled. You need to activate it in game/settings.py.""" # string = """IMC is not enabled. You need to activate it in game/settings.py."""
self.msg(string) # self.msg(string)
return # return
#
if 'list' in self.switches: # if 'list' in self.switches:
# show all connections # # show all connections
connections = ExternalChannelConnection.objects.filter(db_external_key__startswith='imc2_') # connections = ExternalChannelConnection.objects.filter(db_external_key__startswith='imc2_')
if connections: # if connections:
table = prettytable.PrettyTable(["Evennia channel", "IMC channel"]) # table = prettytable.PrettyTable(["Evennia channel", "IMC channel"])
for conn in connections: # for conn in connections:
table.add_row([conn.channel.key, conn.external_config]) # table.add_row([conn.channel.key, conn.external_config])
string = "{wIMC connections:{n\n%s" % table # string = "{wIMC connections:{n\n%s" % table
self.msg(string) # self.msg(string)
else: # else:
self.msg("No connections found.") # self.msg("No connections found.")
return # return
#
if not self.args or not self.rhs: # if not self.args or not self.rhs:
string = "Usage: @imc2chan[/switches] <evennia_channel> = <imc2_channel>" # string = "Usage: @imc2chan[/switches] <evennia_channel> = <imc2_channel>"
self.msg(string) # self.msg(string)
return # return
#
channel = self.lhs # channel = self.lhs
imc2_channel = self.rhs # imc2_channel = self.rhs
#
if('disconnect' in self.switches or 'remove' in self.switches or # if('disconnect' in self.switches or 'remove' in self.switches or
'delete' in self.switches): # 'delete' in self.switches):
# we don't search for channels before this since we want # # we don't search for channels before this since we want
# to clear the link also if the channel no longer exists. # # to clear the link also if the channel no longer exists.
ok = imc2.delete_connection(channel, imc2_channel) # ok = imc2.delete_connection(channel, imc2_channel)
if not ok: # if not ok:
self.msg("IMC2 connection could not be removed, does it exist?") # self.msg("IMC2 connection could not be removed, does it exist?")
else: # else:
self.msg("IMC2 connection destroyed.") # self.msg("IMC2 connection destroyed.")
return # return
#
# actually get the channel object # # actually get the channel object
channel = find_channel(self.caller, channel) # channel = find_channel(self.caller, channel)
if not channel: # if not channel:
return # return
#
ok = imc2.create_connection(channel, imc2_channel) # ok = imc2.create_connection(channel, imc2_channel)
if not ok: # if not ok:
self.msg("The connection %s <-> %s already exists." % (channel.key, imc2_channel)) # self.msg("The connection %s <-> %s already exists." % (channel.key, imc2_channel))
return # return
self.msg("Created connection channel %s <-> IMC channel %s." % (channel.key, imc2_channel)) # self.msg("Created connection channel %s <-> IMC channel %s." % (channel.key, imc2_channel))
#
#
class CmdIMCInfo(MuxCommand): #class CmdIMCInfo(MuxCommand):
""" # """
get various IMC2 information # get various IMC2 information
#
Usage: # Usage:
@imcinfo[/switches] # @imcinfo[/switches]
@imcchanlist - list imc2 channels # @imcchanlist - list imc2 channels
@imclist - list connected muds # @imclist - list connected muds
@imcwhois <playername> - whois info about a remote player # @imcwhois <playername> - whois info about a remote player
#
Switches for @imcinfo: # Switches for @imcinfo:
channels - as @imcchanlist (default) # channels - as @imcchanlist (default)
games or muds - as @imclist # games or muds - as @imclist
whois - as @imcwhois (requires an additional argument) # whois - as @imcwhois (requires an additional argument)
update - force an update of all lists # update - force an update of all lists
#
Shows lists of games or channels on the IMC2 network. # Shows lists of games or channels on the IMC2 network.
""" # """
#
key = "@imcinfo" # key = "@imcinfo"
aliases = ["@imcchanlist", "@imclist", "@imcwhois"] # aliases = ["@imcchanlist", "@imclist", "@imcwhois"]
locks = "cmd: serversetting(IMC2_ENABLED) and pperm(Wizards)" # locks = "cmd: serversetting(IMC2_ENABLED) and pperm(Wizards)"
help_category = "Comms" # help_category = "Comms"
#
def func(self): # def func(self):
"Run the command" # "Run the command"
#
if not settings.IMC2_ENABLED: # if not settings.IMC2_ENABLED:
string = """IMC is not enabled. You need to activate it in game/settings.py.""" # string = """IMC is not enabled. You need to activate it in game/settings.py."""
self.msg(string) # self.msg(string)
return # return
#
if "update" in self.switches: # if "update" in self.switches:
# update the lists # # update the lists
import time # import time
from src.comms.imc2lib import imc2_packets as pck # from src.comms.imc2lib import imc2_packets as pck
from src.comms.imc2 import IMC2_MUDLIST, IMC2_CHANLIST, IMC2_CLIENT # from src.comms.imc2 import IMC2_MUDLIST, IMC2_CHANLIST, IMC2_CLIENT
# update connected muds # # update connected muds
IMC2_CLIENT.send_packet(pck.IMC2PacketKeepAliveRequest()) # IMC2_CLIENT.send_packet(pck.IMC2PacketKeepAliveRequest())
# prune inactive muds # # prune inactive muds
for name, mudinfo in IMC2_MUDLIST.mud_list.items(): # for name, mudinfo in IMC2_MUDLIST.mud_list.items():
if time.time() - mudinfo.last_updated > 3599: # if time.time() - mudinfo.last_updated > 3599:
del IMC2_MUDLIST.mud_list[name] # del IMC2_MUDLIST.mud_list[name]
# update channel list # # update channel list
IMC2_CLIENT.send_packet(pck.IMC2PacketIceRefresh()) # IMC2_CLIENT.send_packet(pck.IMC2PacketIceRefresh())
self.msg("IMC2 lists were re-synced.") # self.msg("IMC2 lists were re-synced.")
#
elif("games" in self.switches or "muds" in self.switches # elif("games" in self.switches or "muds" in self.switches
or self.cmdstring == "@imclist"): # or self.cmdstring == "@imclist"):
# list muds # # list muds
from src.comms.imc2 import IMC2_MUDLIST # from src.comms.imc2 import IMC2_MUDLIST
#
muds = IMC2_MUDLIST.get_mud_list() # muds = IMC2_MUDLIST.get_mud_list()
networks = set(mud.networkname for mud in muds) # networks = set(mud.networkname for mud in muds)
string = "" # string = ""
nmuds = 0 # nmuds = 0
for network in networks: # for network in networks:
table = prettytable.PrettyTable(["Name", "Url", "Host", "Port"]) # table = prettytable.PrettyTable(["Name", "Url", "Host", "Port"])
for mud in (mud for mud in muds if mud.networkname == network): # for mud in (mud for mud in muds if mud.networkname == network):
nmuds += 1 # nmuds += 1
table.add_row([mud.name, mud.url, mud.host, mud.port]) # table.add_row([mud.name, mud.url, mud.host, mud.port])
string += "\n{wMuds registered on %s:{n\n%s" % (network, table) # string += "\n{wMuds registered on %s:{n\n%s" % (network, table)
string += "\n %i Muds found." % nmuds # string += "\n %i Muds found." % nmuds
self.msg(string) # self.msg(string)
#
elif "whois" in self.switches or self.cmdstring == "@imcwhois": # elif "whois" in self.switches or self.cmdstring == "@imcwhois":
# find out about a player # # find out about a player
if not self.args: # if not self.args:
self.msg("Usage: @imcwhois <playername>") # self.msg("Usage: @imcwhois <playername>")
return # return
from src.comms.imc2 import IMC2_CLIENT # from src.comms.imc2 import IMC2_CLIENT
self.msg("Sending IMC whois request. If you receive no response, no matches were found.") # self.msg("Sending IMC whois request. If you receive no response, no matches were found.")
IMC2_CLIENT.msg_imc2(None, # IMC2_CLIENT.msg_imc2(None,
from_obj=self.caller, # from_obj=self.caller,
packet_type="imcwhois", # packet_type="imcwhois",
target=self.args) # target=self.args)
#
elif(not self.switches or "channels" in self.switches or # elif(not self.switches or "channels" in self.switches or
self.cmdstring == "@imcchanlist"): # self.cmdstring == "@imcchanlist"):
# show channels # # show channels
from src.comms.imc2 import IMC2_CHANLIST, IMC2_CLIENT # from src.comms.imc2 import IMC2_CHANLIST, IMC2_CLIENT
#
channels = IMC2_CHANLIST.get_channel_list() # channels = IMC2_CHANLIST.get_channel_list()
string = "" # string = ""
nchans = 0 # nchans = 0
table = prettytable.PrettyTable(["Full name", "Name", "Owner", "Perm", "Policy"]) # table = prettytable.PrettyTable(["Full name", "Name", "Owner", "Perm", "Policy"])
for chan in channels: # for chan in channels:
nchans += 1 # nchans += 1
table.add_row([chan.name, chan.localname, chan.owner, # table.add_row([chan.name, chan.localname, chan.owner,
chan.level, chan.policy]) # chan.level, chan.policy])
string += "\n{wChannels on %s:{n\n%s" % (IMC2_CLIENT.factory.network, table) # string += "\n{wChannels on %s:{n\n%s" % (IMC2_CLIENT.factory.network, table)
string += "\n%i Channels found." % nchans # string += "\n%i Channels found." % nchans
self.msg(string) # self.msg(string)
else: # else:
# no valid inputs # # no valid inputs
string = "Usage: imcinfo|imcchanlist|imclist" # string = "Usage: imcinfo|imcchanlist|imclist"
self.msg(string) # self.msg(string)
#
#
# unclear if this is working ... ## unclear if this is working ...
class CmdIMCTell(MuxCommand): #class CmdIMCTell(MuxCommand):
""" # """
send a page to a remote IMC player # send a page to a remote IMC player
#
Usage: # Usage:
imctell User@MUD = <msg> # imctell User@MUD = <msg>
imcpage " # imcpage "
#
Sends a page to a user on a remote MUD, connected # Sends a page to a user on a remote MUD, connected
over IMC2. # over IMC2.
""" # """
#
key = "imctell" # key = "imctell"
aliases = ["imcpage", "imc2tell", "imc2page"] # aliases = ["imcpage", "imc2tell", "imc2page"]
locks = "cmd: serversetting(IMC2_ENABLED)" # locks = "cmd: serversetting(IMC2_ENABLED)"
help_category = "Comms" # help_category = "Comms"
#
def func(self): # def func(self):
"Send tell across IMC" # "Send tell across IMC"
#
if not settings.IMC2_ENABLED: # if not settings.IMC2_ENABLED:
string = """IMC is not enabled. You need to activate it in game/settings.py.""" # string = """IMC is not enabled. You need to activate it in game/settings.py."""
self.msg(string) # self.msg(string)
return # return
#
from src.comms.imc2 import IMC2_CLIENT # from src.comms.imc2 import IMC2_CLIENT
#
if not self.args or not '@' in self.lhs or not self.rhs: # if not self.args or not '@' in self.lhs or not self.rhs:
string = "Usage: imctell User@Mud = <msg>" # string = "Usage: imctell User@Mud = <msg>"
self.msg(string) # self.msg(string)
return # return
target, destination = self.lhs.split("@", 1) # target, destination = self.lhs.split("@", 1)
message = self.rhs.strip() # message = self.rhs.strip()
data = {"target":target, "destination":destination} # data = {"target":target, "destination":destination}
#
# send to imc2 # # send to imc2
IMC2_CLIENT.msg_imc2(message, from_obj=self.caller, packet_type="imctell", **data) # IMC2_CLIENT.msg_imc2(message, from_obj=self.caller, packet_type="imctell", **data)
#
self.msg("You paged {c%s@%s{n (over IMC): '%s'." % (target, destination, message)) # self.msg("You paged {c%s@%s{n (over IMC): '%s'." % (target, destination, message))
#
#
# RSS connection ## RSS connection
class CmdRSS2Chan(MuxCommand): #class CmdRSS2Chan(MuxCommand):
""" # """
link an evennia channel to an external RSS feed # link an evennia channel to an external RSS feed
#
Usage: # Usage:
@rss2chan[/switches] <evennia_channel> = <rss_url> # @rss2chan[/switches] <evennia_channel> = <rss_url>
#
Switches: # Switches:
/disconnect - this will stop the feed and remove the connection to the # /disconnect - this will stop the feed and remove the connection to the
channel. # channel.
/remove - " # /remove - "
/list - show all rss->evennia mappings # /list - show all rss->evennia mappings
#
Example: # Example:
@rss2chan rsschan = http://code.google.com/feeds/p/evennia/updates/basic # @rss2chan rsschan = http://code.google.com/feeds/p/evennia/updates/basic
#
This creates an RSS reader that connects to a given RSS feed url. Updates # This creates an RSS reader that connects to a given RSS feed url. Updates
will be echoed as a title and news link to the given channel. The rate of # will be echoed as a title and news link to the given channel. The rate of
updating is set with the RSS_UPDATE_INTERVAL variable in settings (default # updating is set with the RSS_UPDATE_INTERVAL variable in settings (default
is every 10 minutes). # is every 10 minutes).
#
When disconnecting you need to supply both the channel and url again so as # When disconnecting you need to supply both the channel and url again so as
to identify the connection uniquely. # to identify the connection uniquely.
""" # """
#
key = "@rss2chan" # key = "@rss2chan"
locks = "cmd:serversetting(RSS_ENABLED) and pperm(Immortals)" # locks = "cmd:serversetting(RSS_ENABLED) and pperm(Immortals)"
help_category = "Comms" # help_category = "Comms"
#
def func(self): # def func(self):
"Setup the rss-channel mapping" # "Setup the rss-channel mapping"
#
if not settings.RSS_ENABLED: # if not settings.RSS_ENABLED:
string = """RSS is not enabled. You need to activate it in game/settings.py.""" # string = """RSS is not enabled. You need to activate it in game/settings.py."""
self.msg(string) # self.msg(string)
return # return
#
if 'list' in self.switches: # if 'list' in self.switches:
# show all connections # # show all connections
connections = ExternalChannelConnection.objects.filter(db_external_key__startswith='rss_') # connections = ExternalChannelConnection.objects.filter(db_external_key__startswith='rss_')
if connections: # if connections:
table = prettytable.PrettyTable(["Evennia channel", "RSS url"]) # table = prettytable.PrettyTable(["Evennia channel", "RSS url"])
for conn in connections: # for conn in connections:
table.add_row([conn.channel.key, conn.external_config.split('|')[0]]) # table.add_row([conn.channel.key, conn.external_config.split('|')[0]])
string = "{wConnections to RSS:{n\n%s" % table # string = "{wConnections to RSS:{n\n%s" % table
self.msg(string) # self.msg(string)
else: # else:
self.msg("No connections found.") # self.msg("No connections found.")
return # return
#
if not self.args or not self.rhs: # if not self.args or not self.rhs:
string = "Usage: @rss2chan[/switches] <evennia_channel> = <rss url>" # string = "Usage: @rss2chan[/switches] <evennia_channel> = <rss url>"
self.msg(string) # self.msg(string)
return # return
channel = self.lhs # channel = self.lhs
url = self.rhs # url = self.rhs
#
if('disconnect' in self.switches or 'remove' in self.switches or # if('disconnect' in self.switches or 'remove' in self.switches or
'delete' in self.switches): # 'delete' in self.switches):
chanmatch = find_channel(self.caller, channel, silent=True) # chanmatch = find_channel(self.caller, channel, silent=True)
if chanmatch: # if chanmatch:
channel = chanmatch.key # channel = chanmatch.key
#
ok = rss.delete_connection(channel, url) # ok = rss.delete_connection(channel, url)
if not ok: # if not ok:
self.msg("RSS connection/reader could not be removed, does it exist?") # self.msg("RSS connection/reader could not be removed, does it exist?")
else: # else:
self.msg("RSS connection destroyed.") # self.msg("RSS connection destroyed.")
return # return
#
channel = find_channel(self.caller, channel) # channel = find_channel(self.caller, channel)
if not channel: # if not channel:
return # return
interval = settings.RSS_UPDATE_INTERVAL # interval = settings.RSS_UPDATE_INTERVAL
if not interval: # if not interval:
interval = 10*60 # interval = 10*60
ok = rss.create_connection(channel, url, interval) # ok = rss.create_connection(channel, url, interval)
if not ok: # if not ok:
self.msg("This RSS connection already exists.") # self.msg("This RSS connection already exists.")
return # return
self.msg("Connection created. Starting RSS reader.") # self.msg("Connection created. Starting RSS reader.")

View file

@ -171,7 +171,7 @@ class Channel(TypeClass):
try: try:
# note our addition of the from_channel keyword here. This could be checked # note our addition of the from_channel keyword here. This could be checked
# by a custom player.msg() to treat channel-receives differently. # by a custom player.msg() to treat channel-receives differently.
player.msg(msg.message, from_obj=msg.senders, from_channel=self) player.msg(msg.message, from_obj=msg.senders, from_channel=self.id)
except AttributeError: except AttributeError:
try: try:
player.to_external(msg.message, player.to_external(msg.message,

View file

@ -5,7 +5,7 @@ Player that are controlled by the server.
""" """
from src.players.player import Player from src.players.player import Player
from src.scripts.script import Script from src.scripts.scripts import Script
from src.commands.command import Command from src.commands.command import Command
from src.commands.cmdset import CmdSet from src.commands.cmdset import CmdSet
from src.commands.cmdhandler import CMD_NOMATCH from src.commands.cmdhandler import CMD_NOMATCH