From 0fddf433dc124d486a6fe949a175ea1109150b10 Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 12 Apr 2013 14:27:36 +0200 Subject: [PATCH] Updated all Player-level commands to properly relay messages using self.msg rather than caller.msg (the former will properly relay to the right sessid without needing any extra arguments). --- src/commands/cmdhandler.py | 3 +- src/commands/default/admin.py | 20 ++-- src/commands/default/building.py | 4 +- src/commands/default/comms.py | 199 ++++++++++++++----------------- src/commands/default/help.py | 34 +++--- src/commands/default/player.py | 9 +- src/commands/default/system.py | 12 +- src/comms/channelhandler.py | 8 +- src/server/webclient.py | 2 +- 9 files changed, 137 insertions(+), 154 deletions(-) diff --git a/src/commands/cmdhandler.py b/src/commands/cmdhandler.py index 0931f20d4e..cb257c0f9e 100644 --- a/src/commands/cmdhandler.py +++ b/src/commands/cmdhandler.py @@ -172,7 +172,7 @@ def cmdhandler(caller, raw_string, testing=False, sessid=None): raw_string - the command string given on the command line testing - if we should actually execute the command or not. if True, the command instance will be returned instead. - + sessid - the session id calling this handler, if any Note that this function returns a deferred! """ try: # catch bugs in cmdhandler itself @@ -240,6 +240,7 @@ def cmdhandler(caller, raw_string, testing=False, sessid=None): if syscmd: # replace system command with custom version cmd = syscmd + cmd.sessid = sessid sysarg = "%s:%s" % (cmdname, args) raise ExecSystemCommand(cmd, sysarg) diff --git a/src/commands/default/admin.py b/src/commands/default/admin.py index da6c78d15e..38110bfbef 100644 --- a/src/commands/default/admin.py +++ b/src/commands/default/admin.py @@ -293,7 +293,7 @@ class CmdDelPlayer(MuxCommand): caller = caller.player if not args: - caller.msg("Usage: @delplayer[/delobj] [: reason]") + self.msg("Usage: @delplayer[/delobj] [: reason]") return reason = "" @@ -318,7 +318,7 @@ class CmdDelPlayer(MuxCommand): user = User.objects.get(username__iexact=args) except Exception: string = "No Player nor User found matching '%s'." % args - caller.msg(string) + self.msg(string) return try: player = user.get_profile() @@ -327,7 +327,7 @@ class CmdDelPlayer(MuxCommand): if player and not player.access(caller, 'delete'): string = "You don't have the permissions to delete this player." - caller.msg(string) + self.msg(string) return string = "" @@ -339,7 +339,7 @@ class CmdDelPlayer(MuxCommand): string = "Player %s was deleted." % name else: string += "The User %s was deleted. It had no Player associated with it." % name - caller.msg(string) + self.msg(string) return elif utils.is_iter(players): @@ -356,13 +356,13 @@ class CmdDelPlayer(MuxCommand): if not player.access(caller, 'delete'): string = "You don't have the permissions to delete that player." - caller.msg(string) + self.msg(string) return uname = user.username # boot the player then delete if character and character.has_player: - caller.msg("Booting and informing player ...") + self.msg("Booting and informing player ...") string = "\nYour account '%s' is being *permanently* deleted.\n" % uname if reason: string += " Reason given:\n '%s'" % reason @@ -374,7 +374,7 @@ class CmdDelPlayer(MuxCommand): session.disconnect() user.delete() player.delete() - caller.msg("Player %s was successfully deleted." % uname) + self.msg("Player %s was successfully deleted." % uname) class CmdEmit(MuxCommand): @@ -459,7 +459,7 @@ class CmdEmit(MuxCommand): class CmdNewPassword(MuxCommand): """ - @setpassword + @userpassword Usage: @userpassword = @@ -477,7 +477,7 @@ class CmdNewPassword(MuxCommand): caller = self.caller if not self.rhs: - caller.msg("Usage: @userpassword = ") + self.msg("Usage: @userpassword = ") return # the player search also matches 'me' etc. @@ -486,7 +486,7 @@ class CmdNewPassword(MuxCommand): return player.user.set_password(self.rhs) player.user.save() - caller.msg("%s - new password set to '%s'." % (player.name, self.rhs)) + self.msg("%s - new password set to '%s'." % (player.name, self.rhs)) if player.character != caller: player.msg("%s has changed your password to '%s'." % (caller.name, self.rhs)) diff --git a/src/commands/default/building.py b/src/commands/default/building.py index 3878380ea4..61cd74349c 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -1700,7 +1700,7 @@ class CmdExamine(ObjManipCommand): to format and output the result. """ string = self.format_output(obj, cmdset) - caller.msg(string.strip()) + self.msg(string.strip()) if not self.args: # If no arguments are provided, examine the invoker's location. @@ -1713,7 +1713,7 @@ class CmdExamine(ObjManipCommand): # using callback for printing result whenever function returns. get_and_merge_cmdsets(obj).addCallback(get_cmdset_callback) else: - caller.msg("You need to supply a target to examine.") + self.msg("You need to supply a target to examine.") return # we have given a specific target object diff --git a/src/commands/default/comms.py b/src/commands/default/comms.py index 73fdbd6e29..0627c9cc27 100644 --- a/src/commands/default/comms.py +++ b/src/commands/default/comms.py @@ -15,7 +15,7 @@ from src.utils import create, utils from src.commands.default.muxcommand import MuxCommand, MuxPlayerCommand # limit symbol import for API -__all__ = ("CommCommand", "CmdAddCom", "CmdDelCom", "CmdAllCom", +__all__ = ("CmdAddCom", "CmdDelCom", "CmdAllCom", "CmdChannels", "CmdCdestroy", "CmdCBoot", "CmdCemit", "CmdCWho", "CmdChannelCreate", "CmdCset", "CmdCdesc", "CmdPage", "CmdIRC2Chan", "CmdIMC2Chan", "CmdIMCInfo", @@ -33,34 +33,15 @@ def find_channel(caller, channelname, silent=False, noaliases=False): if channels: return channels[0] if not silent: - caller.msg("Channel '%s' not found." % channelname) + self.msg("Channel '%s' not found." % channelname) return None elif len(channels) > 1: matches = ", ".join(["%s(%s)" % (chan.key, chan.id) for chan in channels]) if not silent: - caller.msg("Multiple channels match (be more specific): \n%s" % matches) + self.msg("Multiple channels match (be more specific): \n%s" % matches) return None return channels[0] -class CommCommand(MuxCommand): - """ - This is a parent for comm-commands. Since - These commands are to be available to the - Player, we make sure to homogenize the caller - here, so it's always seen as a player to the - command body. - """ - - def parse(self): - "overload parts of parse" - - # run parent - super(CommCommand, self).parse() - # fix obj->player - if utils.inherits_from(self.caller, "src.objects.objects.Object"): - # an object. Convert it to its player. - self.caller = self.caller.player - class CmdAddCom(MuxCommand): """ addcom - subscribe to a channel with optional alias @@ -87,7 +68,7 @@ class CmdAddCom(MuxCommand): player = caller if not args: - caller.msg("Usage: addcom [alias =] channelname.") + self.msg("Usage: addcom [alias =] channelname.") return if self.rhs: @@ -105,7 +86,7 @@ class CmdAddCom(MuxCommand): # check permissions if not channel.access(player, 'listen'): - caller.msg("%s: You are not allowed to listen to this channel." % channel.key) + self.msg("%s: You are not allowed to listen to this channel." % channel.key) return string = "" @@ -113,7 +94,7 @@ class CmdAddCom(MuxCommand): # we want to connect as well. if not channel.connect_to(player): # if this would have returned True, the player is connected - caller.msg("%s: You are not allowed to join this channel." % channel.key) + self.msg("%s: You are not allowed to join this channel." % channel.key) return else: string += "You now listen to the channel %s. " % channel.key @@ -124,10 +105,10 @@ class CmdAddCom(MuxCommand): # create a nick and add it to the caller. caller.nicks.add(alias, channel.key, nick_type="channel") string += " You can now refer to the channel %s with the alias '%s'." - caller.msg(string % (channel.key, alias)) + self.msg(string % (channel.key, alias)) else: string += " No alias added." - caller.msg(string) + self.msg(string) class CmdDelCom(MuxCommand): @@ -154,7 +135,7 @@ class CmdDelCom(MuxCommand): player = caller if not self.args: - caller.msg("Usage: delcom ") + self.msg("Usage: delcom ") return ostring = self.args.lower() @@ -162,7 +143,7 @@ class CmdDelCom(MuxCommand): if channel: # we have given a channel name - unsubscribe if not channel.has_connection(player): - caller.msg("You are not listening to that channel.") + self.msg("You are not listening to that channel.") return chkey = channel.key.lower() # find all nicks linked to this channel and delete them @@ -170,20 +151,20 @@ class CmdDelCom(MuxCommand): if nick.db_real.lower() == chkey]: nick.delete() channel.disconnect_from(player) - caller.msg("You stop listening to channel '%s'. Eventual aliases were removed." % channel.key) + self.msg("You stop listening to channel '%s'. Eventual aliases were removed." % channel.key) return else: # we are removing a channel nick channame = caller.nicks.get(ostring, nick_type="channel") channel = find_channel(caller, channame, silent=True) if not channel: - caller.msg("No channel with alias '%s' was found." % ostring) + self.msg("No channel with alias '%s' was found." % ostring) else: if caller.nicks.has(ostring, nick_type="channel"): caller.nicks.delete(ostring, nick_type="channel") - caller.msg("Your alias '%s' for channel %s was cleared." % (ostring, channel.key)) + self.msg("Your alias '%s' for channel %s was cleared." % (ostring, channel.key)) else: - caller.msg("You had no such alias defined for this channel.") + self.msg("You had no such alias defined for this channel.") class CmdAllCom(MuxCommand): """ @@ -210,7 +191,7 @@ class CmdAllCom(MuxCommand): args = self.args if not args: caller.execute_cmd("@channels") - caller.msg("(Usage: allcom on | off | who | destroy)") + self.msg("(Usage: allcom on | off | who | destroy)") return if args == "on": @@ -241,10 +222,10 @@ class CmdAllCom(MuxCommand): string += " " + ", ".join([conn.player.key for conn in conns]) else: string += " " - caller.msg(string.strip()) + self.msg(string.strip()) else: # wrong input - caller.msg("Usage: allcom on | off | who | clear") + self.msg("Usage: allcom on | off | who | clear") class CmdChannels(MuxCommand): """ @@ -271,7 +252,7 @@ class CmdChannels(MuxCommand): # all channels we have available to listen to channels = [chan for chan in Channel.objects.get_all_channels() if chan.access(caller, 'listen')] if not channels: - caller.msg("No channels available.") + self.msg("No channels available.") return # all channel we are already subscribed to subs = [conn.channel for conn in PlayerChannelConnection.objects.get_all_player_connections(caller)] @@ -295,7 +276,7 @@ class CmdChannels(MuxCommand): string += "\n{w" + "".join(row) + "{n" else: string += "\n" + "".join(row) - self.caller.msg(string) + self.msg(string) string = "\nChannel subscriptions:" if not subs: @@ -315,7 +296,7 @@ class CmdChannels(MuxCommand): string += "\n{w" + "".join(row) + "{n" else: string += "\n" + "".join(row) - caller.msg(string) + self.msg(string) class CmdCdestroy(MuxCommand): """ @@ -336,14 +317,14 @@ class CmdCdestroy(MuxCommand): caller = self.caller if not self.args: - caller.msg("Usage: @cdestroy ") + self.msg("Usage: @cdestroy ") return channel = find_channel(caller, self.args) if not channel: - caller.msg("Could not find channel %s." % self.args) + self.msg("Could not find channel %s." % self.args) return if not channel.access(caller, 'control'): - caller.msg("You are not allowed to do that.") + self.msg("You are not allowed to do that.") return message = "%s is being destroyed. Make sure to change your aliases." % channel @@ -351,7 +332,7 @@ class CmdCdestroy(MuxCommand): channel.msg(msgobj) channel.delete() CHANNELHANDLER.update() - caller.msg("%s was destroyed." % channel) + self.msg("%s was destroyed." % channel) class CmdCBoot(MuxCommand): """ @@ -376,7 +357,7 @@ class CmdCBoot(MuxCommand): if not self.args or not self.rhs: string = "Usage: @cboot[/quiet] = [:reason]" - self.caller.msg(string) + self.msg(string) return channel = find_channel(self.caller, self.lhs) @@ -388,18 +369,18 @@ class CmdCBoot(MuxCommand): searchstring = playername.lstrip('*') else: searchstring = self.rhs.lstrip('*') - player = self.caller.search(searchstring, player=True) + player = self.search(searchstring, player=True) if not player: return if reason: reason = " (reason: %s)" % reason if not channel.access(self.caller, "control"): string = "You don't control this channel." - self.caller.msg(string) + self.msg(string) return if not PlayerChannelConnection.objects.has_connection(player, channel): string = "Player %s is not connected to channel %s." % (player.key, channel.key) - self.caller.msg(string) + self.msg(string) return if not "quiet" in self.switches: string = "%s boots %s from channel.%s" % (self.caller, player.key, reason) @@ -440,24 +421,24 @@ class CmdCemit(MuxCommand): if not self.args or not self.rhs: string = "Usage: @cemit[/switches] = " - self.caller.msg(string) + self.msg(string) return channel = find_channel(self.caller, self.lhs) if not channel: return if not channel.access(self.caller, "control"): string = "You don't control this channel." - self.caller.msg(string) + self.msg(string) return message = self.rhs if "sendername" in self.switches: - message = "%s: %s" % (self.caller.key, message) + message = "%s: %s" % (self.key, message) if not "noheader" in self.switches: message = "[%s] %s" % (channel.key, message) channel.msg(message) if not "quiet" in self.switches: string = "Sent to channel %s: %s" % (channel.key, message) - self.caller.msg(string) + self.msg(string) class CmdCWho(MuxCommand): """ @@ -477,7 +458,7 @@ class CmdCWho(MuxCommand): if not self.args: string = "Usage: @cwho " - self.caller.msg(string) + self.msg(string) return channel = find_channel(self.caller, self.lhs) @@ -485,7 +466,7 @@ class CmdCWho(MuxCommand): return if not channel.access(self.caller, "listen"): string = "You can't access this channel." - self.caller.msg(string) + self.msg(string) string = "\n{CChannel subscriptions{n" string += "\n{w%s:{n\n" % channel.key conns = PlayerChannelConnection.objects.get_all_connections(channel) @@ -493,7 +474,7 @@ class CmdCWho(MuxCommand): string += " " + ", ".join([conn.player.key for conn in conns]) else: string += " " - self.caller.msg(string.strip()) + self.msg(string.strip()) class CmdChannelCreate(MuxCommand): """ @@ -516,7 +497,7 @@ class CmdChannelCreate(MuxCommand): caller = self.caller if not self.args: - caller.msg("Usage @ccreate [;alias;alias..] = description") + self.msg("Usage @ccreate [;alias;alias..] = description") return description = "" @@ -533,13 +514,13 @@ class CmdChannelCreate(MuxCommand): for alias in aliases.split(';') if alias.strip()] channel = Channel.objects.channel_search(channame) if channel: - caller.msg("A channel with that name already exists.") + self.msg("A channel with that name already exists.") return # Create and set the channel up lockstring = "send:all();listen:all();control:id(%s)" % caller.id new_chan = create.create_channel(channame, aliases, description, locks=lockstring) new_chan.connect_to(caller) - caller.msg("Created channel %s and connected to it." % new_chan.key) + self.msg("Created channel %s and connected to it." % new_chan.key) class CmdCset(MuxCommand): @@ -563,7 +544,7 @@ class CmdCset(MuxCommand): if not self.args: string = "Usage: @cset channel [= lockstring]" - self.caller.msg(string) + self.msg(string) return channel = find_channel(self.caller, self.lhs) @@ -573,19 +554,19 @@ class CmdCset(MuxCommand): # no =, so just view the current locks string = "Current locks on %s:" % channel.key string = "%s\n %s" % (string, channel.locks) - self.caller.msg(string) + self.msg(string) return # we want to add/change a lock. if not channel.access(self.caller, "control"): string = "You don't control this channel." - self.caller.msg(string) + self.msg(string) return # Try to add the lock channel.locks.add(self.rhs) string = "Lock(s) applied. " string += "Current locks on %s:" % channel.key string = "%s\n %s" % (string, channel.locks) - self.caller.msg(string) + self.msg(string) class CmdCdesc(MuxCommand): @@ -609,20 +590,20 @@ class CmdCdesc(MuxCommand): caller = self.caller if not self.rhs: - caller.msg("Usage: @cdesc = ") + self.msg("Usage: @cdesc = ") return channel = find_channel(caller, self.lhs) if not channel: - caller.msg("Channel '%s' not found." % self.lhs) + self.msg("Channel '%s' not found." % self.lhs) return #check permissions if not caller.access(caller, 'control'): - caller.msg("You cant admin this channel.") + self.msg("You cant admin this channel.") return # set the description channel.desc = self.rhs channel.save() - caller.msg("Description of channel '%s' set to '%s'." % (channel.key, self.rhs)) + self.msg("Description of channel '%s' set to '%s'." % (channel.key, self.rhs)) class CmdPage(MuxPlayerCommand): """ @@ -661,10 +642,10 @@ class CmdPage(MuxPlayerCommand): if 'last' in self.switches: if pages_we_sent: recv = ",".join(obj.key for obj in pages_we_sent[-1].receivers) - caller.msg("You last paged {c%s{n:%s" % (recv, pages_we_sent[-1].message)) + self.msg("You last paged {c%s{n:%s" % (recv, pages_we_sent[-1].message)) return else: - caller.msg("You haven't paged anyone yet.") + self.msg("You haven't paged anyone yet.") return if not self.args or not self.rhs: @@ -676,7 +657,7 @@ class CmdPage(MuxPlayerCommand): try: number = int(self.args) except ValueError: - caller.msg("Usage: tell [ = msg]") + self.msg("Usage: tell [ = msg]") return if len(pages) > number: @@ -694,7 +675,7 @@ class CmdPage(MuxPlayerCommand): string = "Your latest pages:\n %s" % lastpages else: string = "You haven't paged anyone yet." - caller.msg(string) + self.msg(string) return @@ -706,7 +687,7 @@ class CmdPage(MuxPlayerCommand): if pages_we_sent: receivers = pages_we_sent[-1].receivers else: - caller.msg("Who do you want to page?") + self.msg("Who do you want to page?") return else: receivers = self.lhslist @@ -718,12 +699,12 @@ class CmdPage(MuxPlayerCommand): elif hasattr(receiver, 'character'): pobj = receiver.character else: - caller.msg("Who do you want to page?") + self.msg("Who do you want to page?") return if pobj: recobjs.append(pobj) if not recobjs: - caller.msg("Noone found to page.") + self.msg("Noone found to page.") return header = "{wPlayer{n {c%s{n {wpages:{n" % caller.key @@ -751,8 +732,8 @@ class CmdPage(MuxPlayerCommand): else: received.append("{c%s{n" % pobj.name) if rstrings: - caller.msg(rstrings = "\n".join(rstrings)) - caller.msg("You paged %s with: '%s'." % (", ".join(received), message)) + self.msg(rstrings = "\n".join(rstrings)) + self.msg("You paged %s with: '%s'." % (", ".join(received), message)) class CmdIRC2Chan(MuxCommand): @@ -786,7 +767,7 @@ class CmdIRC2Chan(MuxCommand): if not settings.IRC_ENABLED: string = """IRC is not enabled. You need to activate it in game/settings.py.""" - self.caller.msg(string) + self.msg(string) return if 'list' in self.switches: @@ -804,14 +785,14 @@ class CmdIRC2Chan(MuxCommand): string += "{w%s{n" % "".join(row) else: string += "\n" + "".join(row) - self.caller.msg(string) + self.msg(string) else: - self.caller.msg("No connections found.") + self.msg("No connections found.") return if not self.args or not self.rhs: string = "Usage: @irc2chan[/switches] = <#irchannel> " - self.caller.msg(string) + self.msg(string) return channel = self.lhs self.rhs = self.rhs.replace('#', ' ') # to avoid Python comment issues @@ -820,7 +801,7 @@ class CmdIRC2Chan(MuxCommand): irc_channel = "#%s" % irc_channel except Exception: string = "IRC bot definition '%s' is not valid." % self.rhs - self.caller.msg(string) + self.msg(string) return if 'disconnect' in self.switches or 'remove' in self.switches or 'delete' in self.switches: @@ -830,9 +811,9 @@ class CmdIRC2Chan(MuxCommand): ok = irc.delete_connection(channel, irc_network, irc_port, irc_channel, irc_botname) if not ok: - self.caller.msg("IRC connection/bot could not be removed, does it exist?") + self.msg("IRC connection/bot could not be removed, does it exist?") else: - self.caller.msg("IRC connection destroyed.") + self.msg("IRC connection destroyed.") return channel = find_channel(self.caller, channel) @@ -840,9 +821,9 @@ class CmdIRC2Chan(MuxCommand): return ok = irc.create_connection(channel, irc_network, irc_port, irc_channel, irc_botname) if not ok: - self.caller.msg("This IRC connection already exists.") + self.msg("This IRC connection already exists.") return - self.caller.msg("Connection created. Starting IRC bot.") + self.msg("Connection created. Starting IRC bot.") class CmdIMC2Chan(MuxCommand): """ @@ -875,7 +856,7 @@ class CmdIMC2Chan(MuxCommand): if not settings.IMC2_ENABLED: string = """IMC is not enabled. You need to activate it in game/settings.py.""" - self.caller.msg(string) + self.msg(string) return if 'list' in self.switches: @@ -894,14 +875,14 @@ class CmdIMC2Chan(MuxCommand): string += "{w%s{n" % "".join(row) else: string += "\n" + "".join(row) - self.caller.msg(string) + self.msg(string) else: - self.caller.msg("No connections found.") + self.msg("No connections found.") return if not self.args or not self.rhs: string = "Usage: @imc2chan[/switches] = " - self.caller.msg(string) + self.msg(string) return channel = self.lhs @@ -912,9 +893,9 @@ class CmdIMC2Chan(MuxCommand): # also if the channel no longer exists. ok = imc2.delete_connection(channel, imc2_channel) if not ok: - self.caller.msg("IMC2 connection could not be removed, does it exist?") + self.msg("IMC2 connection could not be removed, does it exist?") else: - self.caller.msg("IMC2 connection destroyed.") + self.msg("IMC2 connection destroyed.") return # actually get the channel object @@ -924,9 +905,9 @@ class CmdIMC2Chan(MuxCommand): ok = imc2.create_connection(channel, imc2_channel) if not ok: - self.caller.msg("The connection %s <-> %s already exists." % (channel.key, imc2_channel)) + self.msg("The connection %s <-> %s already exists." % (channel.key, imc2_channel)) return - self.caller.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): @@ -958,7 +939,7 @@ class CmdIMCInfo(MuxCommand): if not settings.IMC2_ENABLED: string = """IMC is not enabled. You need to activate it in game/settings.py.""" - self.caller.msg(string) + self.msg(string) return if "update" in self.switches: @@ -974,7 +955,7 @@ class CmdIMCInfo(MuxCommand): del IMC2_MUDLIST.mud_list[name] # update channel list IMC2_CLIENT.send_packet(pck.IMC2PacketIceRefresh()) - self.caller.msg("IMC2 lists were re-synced.") + self.msg("IMC2 lists were re-synced.") elif "games" in self.switches or "muds" in self.switches or self.cmdstring == "@imclist": # list muds @@ -1000,15 +981,15 @@ class CmdIMCInfo(MuxCommand): else: string += "\n" + "".join(row) string += "\n %i Muds found." % nmuds - self.caller.msg(string) + self.msg(string) elif "whois" in self.switches or self.cmdstring == "@imcwhois": # find out about a player if not self.args: - self.caller.msg("Usage: @imcwhois ") + self.msg("Usage: @imcwhois ") return from src.comms.imc2 import IMC2_CLIENT - self.caller.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, from_obj=self.caller, packet_type="imcwhois", data={"target":self.args}) elif not self.switches or "channels" in self.switches or self.cmdstring == "@imcchanlist": @@ -1034,12 +1015,12 @@ class CmdIMCInfo(MuxCommand): else: string += "\n" + "".join(row) string += "\n %i Channels found." % nchans - self.caller.msg(string) + self.msg(string) else: # no valid inputs string = "Usage: imcinfo|imcchanlist|imclist" - self.caller.msg(string) + self.msg(string) # unclear if this is working ... class CmdIMCTell(MuxCommand): @@ -1064,14 +1045,14 @@ class CmdIMCTell(MuxCommand): if not settings.IMC2_ENABLED: string = """IMC is not enabled. You need to activate it in game/settings.py.""" - self.caller.msg(string) + self.msg(string) return from src.comms.imc2 import IMC2_CLIENT if not self.args or not '@' in self.lhs or not self.rhs: string = "Usage: imctell User@Mud = " - self.caller.msg(string) + self.msg(string) return target, destination = self.lhs.split("@", 1) message = self.rhs.strip() @@ -1080,7 +1061,7 @@ class CmdIMCTell(MuxCommand): # send to imc2 IMC2_CLIENT.msg_imc2(message, from_obj=self.caller, packet_type="imctell", data=data) - self.caller.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 @@ -1116,7 +1097,7 @@ class CmdRSS2Chan(MuxCommand): if not settings.RSS_ENABLED: string = """RSS is not enabled. You need to activate it in game/settings.py.""" - self.caller.msg(string) + self.msg(string) return if 'list' in self.switches: @@ -1134,14 +1115,14 @@ class CmdRSS2Chan(MuxCommand): string += "{w%s{n" % "".join(row) else: string += "\n" + "".join(row) - self.caller.msg(string) + self.msg(string) else: - self.caller.msg("No connections found.") + self.msg("No connections found.") return if not self.args or not self.rhs: string = "Usage: @rss2chan[/switches] = " - self.caller.msg(string) + self.msg(string) return channel = self.lhs url = self.rhs @@ -1153,9 +1134,9 @@ class CmdRSS2Chan(MuxCommand): ok = rss.delete_connection(channel, url) if not ok: - self.caller.msg("RSS connection/reader could not be removed, does it exist?") + self.msg("RSS connection/reader could not be removed, does it exist?") else: - self.caller.msg("RSS connection destroyed.") + self.msg("RSS connection destroyed.") return channel = find_channel(self.caller, channel) @@ -1166,6 +1147,6 @@ class CmdRSS2Chan(MuxCommand): interval = 10*60 ok = rss.create_connection(channel, url, interval) if not ok: - self.caller.msg("This RSS connection already exists.") + self.msg("This RSS connection already exists.") return - self.caller.msg("Connection created. Starting RSS reader.") + self.msg("Connection created. Starting RSS reader.") diff --git a/src/commands/default/help.py b/src/commands/default/help.py index d214ea3774..9ab2e466ed 100644 --- a/src/commands/default/help.py +++ b/src/commands/default/help.py @@ -113,7 +113,7 @@ class CmdHelp(Command): [hdict_cmd[cmd.help_category].append(cmd.key) for cmd in all_cmds] [hdict_topic[topic.help_category].append(topic.key) for topic in all_topics] # report back - caller.msg(format_help_list(hdict_cmd, hdict_topic)) + self.msg(format_help_list(hdict_cmd, hdict_topic)) return # Try to access a particular command @@ -129,23 +129,23 @@ class CmdHelp(Command): # try an exact command auto-help match match = [cmd for cmd in all_cmds if cmd == query] if len(match) == 1: - caller.msg(format_help_entry(match[0].key, match[0].__doc__, aliases=match[0].aliases, suggested=suggestions)) + self.msg(format_help_entry(match[0].key, match[0].__doc__, aliases=match[0].aliases, suggested=suggestions)) return # try an exact database help entry match match = list(HelpEntry.objects.find_topicmatch(query, exact=True)) if len(match) == 1: - caller.msg(format_help_entry(match[0].key, match[0].entrytext, suggested=suggestions)) + self.msg(format_help_entry(match[0].key, match[0].entrytext, suggested=suggestions)) return # try to see if a category name was entered if query in all_categories: - caller.msg(format_help_list({query:[cmd.key for cmd in all_cmds if cmd.help_category==query]}, + self.msg(format_help_list({query:[cmd.key for cmd in all_cmds if cmd.help_category==query]}, {query:[topic.key for topic in all_topics if topic.help_category==query]})) return # no exact matches found. Just give suggestions. - caller.msg(format_help_entry("", "No help entry found for '%s'" % query, None, suggested=suggestions)) + self.msg(format_help_entry("", "No help entry found for '%s'" % query, None, suggested=suggestions)) class CmdSetHelp(MuxCommand): """ @@ -187,7 +187,7 @@ class CmdSetHelp(MuxCommand): lhslist = self.lhslist if not self.args: - caller.msg("Usage: @sethelp/[add|del|append|merge] [,category[,locks,..] = ") + self.msg("Usage: @sethelp/[add|del|append|merge] [,category[,locks,..] = ") return topicstr = "" @@ -201,7 +201,7 @@ class CmdSetHelp(MuxCommand): pass if not topicstr: - caller.msg("You have to define a topic!") + self.msg("You have to define a topic!") return # check if we have an old entry with the same name try: @@ -212,29 +212,29 @@ class CmdSetHelp(MuxCommand): if 'append' in switches or "merge" in switches: # merge/append operations if not old_entry: - caller.msg("Could not find topic '%s'. You must give an exact name." % topicstr) + self.msg("Could not find topic '%s'. You must give an exact name." % topicstr) return if not self.rhs: - caller.msg("You must supply text to append/merge.") + self.msg("You must supply text to append/merge.") return if 'merge' in switches: old_entry.entrytext += " " + self.rhs else: old_entry.entrytext += "\n\n%s" % self.rhs - caller.msg("Entry updated:\n%s" % old_entry.entrytext) + self.msg("Entry updated:\n%s" % old_entry.entrytext) return if 'delete' in switches or 'del' in switches: # delete the help entry if not old_entry: - caller.msg("Could not find topic '%s'" % topicstr) + self.msg("Could not find topic '%s'" % topicstr) return old_entry.delete() - caller.msg("Deleted help entry '%s'." % topicstr) + self.msg("Deleted help entry '%s'." % topicstr) return # at this point it means we want to add a new help entry. if not self.rhs: - caller.msg("You must supply a help text to add.") + self.msg("You must supply a help text to add.") return if old_entry: if 'for' in switches or 'force' in switches: @@ -245,14 +245,14 @@ class CmdSetHelp(MuxCommand): old_entry.locks.clear() old_entry.locks.add(lockstring) old_entry.save() - caller.msg("Overwrote the old topic '%s' with a new one." % topicstr) + self.msg("Overwrote the old topic '%s' with a new one." % topicstr) else: - caller.msg("Topic '%s' already exists. Use /force to overwrite or /append or /merge to add text to it." % topicstr) + self.msg("Topic '%s' already exists. Use /force to overwrite or /append or /merge to add text to it." % topicstr) else: # no old entry. Create a new one. new_entry = create.create_help_entry(topicstr, self.rhs, category, lockstring) if new_entry: - caller.msg("Topic '%s' was successfully created." % topicstr) + self.msg("Topic '%s' was successfully created." % topicstr) else: - caller.msg("Error when creating topic '%s'! Maybe it already exists?" % topicstr) + self.msg("Error when creating topic '%s'! Maybe it already exists?" % topicstr) diff --git a/src/commands/default/player.py b/src/commands/default/player.py index 322f7ac988..9dc4008b0b 100644 --- a/src/commands/default/player.py +++ b/src/commands/default/player.py @@ -307,14 +307,15 @@ class CmdSessions(MuxPlayerCommand): player = self.caller sessions = player.get_all_sessions() - table = [["sessid"], ["host"], ["puppet/character"], ["location"]] + table = [["sessid"], ['protocol'], ["host"], ["puppet/character"], ["location"]] for sess in sorted(sessions, key=lambda x:x.sessid): sessid = sess.sessid char = player.get_puppet(sessid) table[0].append(str(sess.sessid)) - table[1].append(str(sess.address[0])) - table[2].append(char and str(char) or "None") - table[3].append(char and str(char.location) or "N/A") + table[1].append(str(sess.protocol_key)) + table[2].append(type(sess.address)==tuple and sess.address[0] or sess.address) + table[3].append(char and str(char) or "None") + table[4].append(char and str(char.location) or "N/A") ftable = utils.format_table(table, 5) string = "{wYour current session(s):{n" for ir, row in enumerate(ftable): diff --git a/src/commands/default/system.py b/src/commands/default/system.py index 2063cf4a59..032ffea172 100644 --- a/src/commands/default/system.py +++ b/src/commands/default/system.py @@ -101,7 +101,7 @@ class CmdShutdown(MuxCommand): self.caller.sessions[0] except Exception: return - self.caller.msg('Shutting down server ...') + self.msg('Shutting down server ...') announcement = "\nServer is being SHUT DOWN!\n" if self.args: announcement += "%s\n" % self.args @@ -150,7 +150,7 @@ class CmdPy(MuxCommand): if not pycode: string = "Usage: @py " - caller.msg(string) + self.msg(string) return # check if caller is a player @@ -164,9 +164,9 @@ class CmdPy(MuxCommand): 'inherits_from':utils.inherits_from} try: - caller.msg(">>> %s" % pycode, data={"raw":True}, sessid=self.sessid) + self.msg(">>> %s" % pycode, data={"raw":True}, sessid=self.sessid) except TypeError: - caller.msg(">>> %s" % pycode, data={"raw":True}) + self.msg(">>> %s" % pycode, data={"raw":True}) mode = "eval" @@ -197,9 +197,9 @@ class CmdPy(MuxCommand): if ret != None: try: - caller.msg(ret, sessid=self.sessid) + self.msg(ret, sessid=self.sessid) except TypeError: - caller.msg(ret) + self.msg(ret) # helper function. Kept outside so it can be imported and run diff --git a/src/comms/channelhandler.py b/src/comms/channelhandler.py index 227494c1b5..8173aeb5fc 100644 --- a/src/comms/channelhandler.py +++ b/src/comms/channelhandler.py @@ -62,20 +62,20 @@ class ChannelCommand(command.Command): channelkey, msg = self.args caller = self.caller if not msg: - caller.msg("Say what?") + self.msg("Say what?") return channel = Channel.objects.get_channel(channelkey) if not channel: - caller.msg("Channel '%s' not found." % channelkey) + self.msg("Channel '%s' not found." % channelkey) return if not channel.has_connection(caller): string = "You are not connected to channel '%s'." - caller.msg(string % channelkey) + self.msg(string % channelkey) return if not channel.access(caller, 'send'): string = "You are not permitted to send to channel '%s'." - caller.msg(string % channelkey) + self.msg(string % channelkey) return msg = "[%s] %s: %s" % (channel.key, caller.name, msg) # we can't use the utils.create function to make the Msg, diff --git a/src/server/webclient.py b/src/server/webclient.py index e7acf3f9a3..8c84bba2f7 100644 --- a/src/server/webclient.py +++ b/src/server/webclient.py @@ -121,7 +121,7 @@ class WebClient(resource.Resource): sess = WebClientSession() sess.client = self - sess.init_session("comet", remote_addr, self.sessionhandler) + sess.init_session("webclient", remote_addr, self.sessionhandler) sess.suid = suid sess.sessionhandler.connect(sess) return jsonify({'msg':host_string, 'suid':suid})