Mercurial > traipse
diff orpg/chat/commands.py @ 18:97265586402b ornery-orc
Traipse 'OpenRPG' {090827-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc''s main goal is to offer more advanced features and enhance the productivity of the user.
Update Summary:
Update Manager is now in version 0.8. While not every button works, users can now browse the different revisions and their different changesets. The code has been refined some with feature from Core added to it. A Crash report is now created if the users software crashes. Update Manager has been moved to the Traipse Suite menu item, and a Debug Console as been added as well.
author | sirebral |
---|---|
date | Thu, 27 Aug 2009 01:04:43 -0500 |
parents | 4385a7d0efd1 |
children | 51428d30c59e |
line wrap: on
line diff
--- a/orpg/chat/commands.py Thu Aug 13 13:14:10 2009 -0500 +++ b/orpg/chat/commands.py Thu Aug 27 01:04:43 2009 -0500 @@ -12,7 +12,10 @@ import time import orpg.orpg_version import orpg.orpg_windows -import traceback +import traceback + +from orpg.tools.orpg_log import logger +from orpg.tools.decorators import debugging ##-------------------------------------------------------------- ## dynamically loading module for extended developer commands @@ -35,7 +38,8 @@ # Initialization subroutine. # # !self : instance of self - # !chat : instance of the chat window to write to + # !chat : instance of the chat window to write to + @debugging def __init__(self,chat): self.post = chat.Post self.colorize = chat.colorize @@ -55,18 +59,21 @@ # of implemented emotions. # # !self : instance of self - # !text : string of text matching an implemented emotion + # !text : string of text matching an implemented emotion + @debugging def addcommand(self, cmd, function, helpmsg): if not self.cmdlist.has_key(cmd) and not self.shortcmdlist.has_key(cmd): self.cmdlist[cmd] = {} self.cmdlist[cmd]['function'] = function self.cmdlist[cmd]['help'] = helpmsg #print 'Command Added: ' + cmd - + + @debugging def addshortcmd(self, shortcmd, longcmd): if not self.shortcmdlist.has_key(shortcmd) and not self.cmdlist.has_key(shortcmd): self.shortcmdlist[shortcmd] = longcmd - + + @debugging def removecmd(self, cmd): if self.cmdlist.has_key(cmd): del self.cmdlist[cmd] @@ -75,7 +82,8 @@ #print 'Command Removed: ' + cmd - + + @debugging def defaultcmds(self): self.addcommand('/help', self.on_help, '- Displays this help message') self.addcommand('/version', self.on_version, ' - Displays current version of OpenRPG.') @@ -104,7 +112,8 @@ self.addcommand('/sound', self.on_sound, 'Sound_URL - Plays a sound for all clients in the room.') self.addcommand('/purge', self.on_purge, 'This will clear the entire chat window') self.addcommand('/advfilter', self.on_filter, 'This will toggle the Advanced Filter') - + + @debugging def defaultcmdalias(self): self.addshortcmd('/?', '/help') self.addshortcmd('/he', '/me') @@ -118,8 +127,8 @@ #This is just an example or a differant way the shorcmd can be used self.addshortcmd('/sleep', '/me falls asleep') - - + + @debugging def docmd(self,text): cmdsearch = string.split(text,None,1) cmd = string.lower(cmdsearch[0]) @@ -134,7 +143,8 @@ else: msg = "Sorry I don't know what %s is!" % (cmd) self.chat.InfoPost(msg) - + + @debugging def on_filter(self, cmdargs): #print self.chat.advancedFilter test = not self.chat.advancedFilter @@ -158,11 +168,13 @@ self.chat.InfoPost("Advanced Filtering has been turned On") else: self.chat.InfoPost("Advanced Filtering has been turned Off") - + + @debugging def on_purge(self, cmdargs): self.chat.PurgeChat() self.chat.InfoPost('Chat Buffer has been Purged!') - + + @debugging def on_sound(self, cmdargs): if len(cmdargs) < 8: self.chat.InfoPost("You must provide a URL for the file name, it does not work for just local sound files") @@ -195,10 +207,12 @@ self.chat.InfoPost("You cannot send sound files to the lobby!") else: self.chat.InfoPost("Something dun fuckered up Frank!") - + + @debugging def on_version(self, cmdargs=""): self.chat.InfoPost("Version is OpenRPG " + self.chat.version) - + + @debugging def on_load(self, cmdargs): args = string.split(cmdargs,None,-1) try: @@ -208,13 +222,15 @@ except Exception,e: print e self.chat.InfoPost("ERROR Loading settings") - + + @debugging def on_font(self, cmdargs): try: fontsettings = self.chat.set_default_font(fontname=cmdargs, fontsize=None) except: self.chat.InfoPost("ERROR setting default font") - + + @debugging def on_fontsize(self, cmdargs): args = string.split(cmdargs,None,-1) try: @@ -222,7 +238,8 @@ except Exception, e: print e self.chat.InfoPost("ERROR setting default font size") - + + @debugging def on_close(self, cmdargs): try: chatpanel = self.chat @@ -233,14 +250,16 @@ chatpanel.parent.onCloseTab(0) except: self.chat.InfoPost("Error: cannot close private chat tab.") - + + @debugging def on_time(self, cmdargs): local_time = time.localtime() gmt_time = time.gmtime() format_string = "%A %b %d, %Y %I:%M:%S%p" self.chat.InfoPost("<br />Local: " + time.strftime(format_string)+\ "<br />GMT: "+time.strftime(format_string,gmt_time)) - + + @debugging def on_dieroller(self, cmdargs): args = string.split(cmdargs,None,-1) rm = self.chat.DiceManager @@ -252,12 +271,14 @@ print e self.chat.InfoPost("Available die rollers: " + str(rm.listRollers())) self.chat.InfoPost("You are using the <b>\"" + rm.getRoller() + "\"</b> die roller.") - + + @debugging def on_ping(self, cmdargs): ct = time.clock() msg = "<ping player='"+self.session.id+"' time='"+str(ct)+"' />" self.session.outbox.put(msg) - + + @debugging def on_log(self,cmdargs): args = string.split(cmdargs,None,-1) logfile = self.settings.get_setting( 'GameLogPrefix' ) @@ -288,7 +309,8 @@ self.postLoggingState() else: self.chat.InfoPost("Unknown logging command, use 'on' or 'off'" ) - + + @debugging def postLoggingState( self ): logfile = self.settings.get_setting( 'GameLogPrefix' ) try: @@ -304,7 +326,8 @@ # This subroutine will set the players netork status. # #!self : instance of self - + + @debugging def on_name(self, cmdargs): #only 20 chars no more! :) if cmdargs == "": @@ -318,7 +341,8 @@ # This subroutine will set the players netork status. # - # !self : instance of self + # !self : instance of self + @debugging def on_status(self, cmdargs): if cmdargs == "": self.chat.InfoPost("Incorrect synatx for status.") @@ -327,7 +351,8 @@ txt = cmdargs[:20] self.session.set_text_status(str(txt)) # def on_status - end - + + @debugging def on_set(self, cmdargs): args = string.split(cmdargs,None,-1) keys = self.settings.get_setting_keys() @@ -361,7 +386,8 @@ # This subroutine will display the correct usage of the different emotions. # #!self : instance of self - + + @debugging def on_help(self, cmdargs=""): cmds = self.cmdlist.keys() cmds.sort() @@ -383,7 +409,8 @@ # This subroutine will either show the list of currently ignored users # !self : instance of self # !text : string that is comprised of a list of users to toggle the ignore flag - + + @debugging def on_ignore(self, cmdargs): args = string.split(cmdargs,None,-1) (ignore_list, ignore_name) = self.session.get_ignore_list() @@ -409,7 +436,8 @@ except: self.chat.InfoPost(m + " was ignored because it is an invalid player ID") traceback.print_exc() - + + @debugging def on_role(self, cmdargs): if cmdargs == "": self.session.display_roles() @@ -440,7 +468,8 @@ # !self : instance of self # !text : string that is comprised of a list of users and the message to #whisper. - + + @debugging def on_whisper(self, cmdargs): delim = cmdargs.find("=") @@ -458,7 +487,8 @@ #--------------------------------------------------------- # [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- +#--------------------------------------------------------- + @debugging def on_groupwhisper(self, cmdargs): args = string.split(cmdargs,None,-1) delim = cmdargs.find("=") @@ -518,7 +548,8 @@ #--------------------------------------------------------- # [END] Digitalxero Multi Whisper Group 1/1/05 #--------------------------------------------------------- - + + @debugging def on_gmwhisper(self, cmdargs): if cmdargs == "": self.chat.InfoPost("**Incorrect syntax for GM Whisper.") @@ -533,7 +564,8 @@ self.on_whisper(gmstring + "=" + cmdargs) else: self.chat.InfoPost("**No GMs to Whisper to.") - + + @debugging def on_moderate(self, cmdargs): if cmdargs != "": pos = cmdargs.find("=") @@ -570,10 +602,12 @@ msg = "<moderate action='list' from='"+self.session.id+"' />" self.session.outbox.put(msg) self.session.update() - + + @debugging def on_update(self, cmdargs): self.chat.InfoPost("This command is no longer valid") - + + @debugging def on_description(self, cmdargs): if len(cmdargs) <= 0: self.chat.InfoPost("**No description text to display." + str(delim)) @@ -583,7 +617,8 @@ mesg += "</font></td></tr></table>" self.chat.Post(mesg) self.chat.send_chat_message(mesg) - + + @debugging def invoke_tab(self, cmdargs): ######START mDuo13's Tab Initiator######## try: @@ -608,7 +643,8 @@ self.chat.parent.newMsg(nidx) return #######END mDuo13's Tab Initiator######### - + + @debugging def on_remote_admin(self, cmdargs): args = string.split(cmdargs,None,-1) #handles remote administration commands