diff orpg/chat/commands.py @ 184:dcae32e219f1 beta

Traipse Beta 'OpenRPG' {100117-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 (Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Sun, 17 Jan 2010 21:37:34 -0600
parents 3b6888bb53b5
children 13054be69834
line wrap: on
line diff
--- a/orpg/chat/commands.py	Fri Jan 15 23:01:42 2010 -0600
+++ b/orpg/chat/commands.py	Sun Jan 17 21:37:34 2010 -0600
@@ -7,7 +7,6 @@
 #   on_whisper(self,text)
 #
 
-
 import string, time
 import orpg.orpg_version
 import orpg.orpg_windows
@@ -26,63 +25,41 @@
 try:
     import cmd_ext
     print "Importing Developer Extended Command Set"
-except:
-    pass
+except: pass
 ##----------------------------------------------------------------
 
 ANTI_LOG_CHAR = '!'
 
 class chat_commands:
 
-    # Initialization subroutine.
-    #
-    # !self : instance of self
-    # !chat : instance of the chat window to write to
-    
     def __init__(self,chat):
         self.post = chat.Post
         self.colorize = chat.colorize
         self.session = chat.session
-        #self.send = chat.session.send
         self.settings = chat.settings
         self.chat = chat
         self.cmdlist = {}
         self.shortcmdlist = {}
         self.defaultcmds()
         self.defaultcmdalias()
-        # def __init__ - end
         self.previous_whisper = []
 
-
-        # This subroutine will take a text string and attempt to match to a series
-        # of implemented emotions.
-        #
-        # !self : instance of self
-        # !text : string of text matching an implemented emotion
-    
     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
 
-    
     def addshortcmd(self, shortcmd, longcmd):
         if not self.shortcmdlist.has_key(shortcmd) and not self.cmdlist.has_key(shortcmd):
             self.shortcmdlist[shortcmd] = longcmd
 
-    
     def removecmd(self, cmd):
         if self.cmdlist.has_key(cmd):
             del self.cmdlist[cmd]
         elif self.shortcmdlist.has_key(cmd):
             del self.shortcmdlist[cmd]
 
-        #print 'Command Removed: ' + cmd
-
-
-    
     def defaultcmds(self):
         self.addcommand('/help', self.on_help, '- Displays this help message')
         self.addcommand('/version', self.on_version, ' - Displays current version of OpenRPG.')
@@ -112,7 +89,6 @@
         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')
 
-    
     def defaultcmdalias(self):
         self.addshortcmd('/?', '/help')
         self.addshortcmd('/he', '/me')
@@ -123,18 +99,14 @@
         self.addshortcmd('/date', '/time')
         self.addshortcmd('/desc', '/description')
         self.addshortcmd('/d', '/description')
-
-        #This is just an example or a differant way the shorcmd can be used
         self.addshortcmd('/sleep', '/me falls asleep')
 
-    
     def docmd(self,text):
         cmdsearch = string.split(text,None,1)
         cmd = string.lower(cmdsearch[0])
         start = len(cmd)
         end = len(text)
         cmdargs = text[start+1:end]
-
         if self.cmdlist.has_key(cmd):
             self.cmdlist[cmd]['function'](cmdargs)
         elif self.shortcmdlist.has_key(cmd):
@@ -143,37 +115,26 @@
             msg = "Sorry I don't know what %s is!" % (cmd)
             self.chat.InfoPost(msg)
 
-    
     def on_filter(self, cmdargs):
-        #print self.chat.advancedFilter
         test = not self.chat.advancedFilter
-        #print test
-
         for tab in self.chat.parent.whisper_tabs:
             tab.advancedFilter = not self.chat.advancedFilter
-
         for tab in self.chat.parent.null_tabs:
             tab.advancedFilter = not self.chat.advancedFilter
-
         for tab in self.chat.parent.group_tabs:
             tab.advancedFilter = not self.chat.advancedFilter
-
         if self.chat.parent.GMChatPanel != None:
             self.chat.parent.GMChatPanel.advancedFilter = not self.chat.advancedFilter
-
         self.chat.advancedFilter = not self.chat.advancedFilter
-
         if self.chat.advancedFilter:
             self.chat.InfoPost("Advanced Filtering has been turned On")
         else:
             self.chat.InfoPost("Advanced Filtering has been turned Off")
 
-    
     def on_purge(self, cmdargs):
         self.chat.PurgeChat()
         self.chat.InfoPost('Chat Buffer has been Purged!')
 
-    
     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")
@@ -186,9 +147,7 @@
         else:
             snd = cmdargs.replace('&', '&amp;')
             loop = ''
-
         type = 'remote'
-
         (name, ip, id, text_status, version, protocol_version, client_string, role) = self.session.get_my_info()
         group_id = self.session.group_id
         if (role != 'Lurker' and group_id != '0') or self.session.get_status() != 1:
@@ -207,11 +166,9 @@
         else:
             self.chat.InfoPost("Something dun fuckered up Frank!")
 
-    
     def on_version(self, cmdargs=""):
         self.chat.InfoPost("Version is OpenRPG " + self.chat.version)
 
-    
     def on_load(self, cmdargs):
         args = string.split(cmdargs,None,-1)
         try:
@@ -222,14 +179,12 @@
             print e
             self.chat.InfoPost("ERROR Loading settings")
 
-    
     def on_font(self, cmdargs):
         try:
             fontsettings = self.chat.set_default_font(fontname=cmdargs, fontsize=None)
         except:
             self.chat.InfoPost("ERROR setting default font")
 
-    
     def on_fontsize(self, cmdargs):
         args = string.split(cmdargs,None,-1)
         try:
@@ -238,7 +193,6 @@
             print e
             self.chat.InfoPost("ERROR setting default font size")
 
-    
     def on_close(self, cmdargs):
         try:
             chatpanel = self.chat
@@ -250,7 +204,6 @@
         except:
             self.chat.InfoPost("Error:  cannot close private chat tab.")
 
-    
     def on_time(self, cmdargs):
         local_time = time.localtime()
         gmt_time = time.gmtime()
@@ -258,7 +211,6 @@
         self.chat.InfoPost("<br />Local: " + time.strftime(format_string)+\
                            "<br />GMT: "+time.strftime(format_string,gmt_time))
 
-    
     def on_dieroller(self, cmdargs):
         args = string.split(cmdargs,None,-1)
         rm = component.get('DiceManager')
@@ -271,17 +223,14 @@
             self.chat.InfoPost("Available die rollers: " + str(rm.listRollers()))
             self.chat.InfoPost("You are using the <b>\"" + rm.getRoller() + "\"</b> die roller.")
 
-    
     def on_ping(self, cmdargs):
         ct = time.clock()
         msg = "<ping player='"+self.session.id+"' time='"+str(ct)+"' />"
         self.session.outbox.put(msg)
 
-    
     def on_log(self,cmdargs):
         args = string.split(cmdargs,None,-1)
         logfile = self.settings.get_setting( 'GameLogPrefix' )
-
         if len( args ) == 0:
             self.postLoggingState()
         elif args[0] == "on" and logfile != '':
@@ -309,7 +258,6 @@
         else:
             self.chat.InfoPost("Unknown logging command, use 'on' or 'off'"  )
 
-    
     def postLoggingState( self ):
         logfile = self.settings.get_setting( 'GameLogPrefix' )
         try:
@@ -319,39 +267,23 @@
         suffix = time.strftime( '-%d-%m-%y.html', time.localtime( time.time() ) )
         self.chat.InfoPost('Log filename is "%s%s", system is %s logging.' % (logfile, suffix, comment) )
 
-        # This subroutine will set the players netork status.
-        #
-        #!self : instance of self
-
-    
     def on_name(self, cmdargs):
-        #only 20 chars no more! :)
         if cmdargs == "":
             self.chat.InfoPost("**Incorrect syntax for name.")
         else:
-            #txt = txt[:50]
             self.settings.set_setting('player', cmdargs)
             self.session.set_name(str(cmdargs))
 
-    # def on_status - end
-        # This subroutine will set the players netork status.
-        #
-        # !self : instance of self
-    
     def on_status(self, cmdargs):
         if cmdargs ==  "":
             self.chat.InfoPost("Incorrect synatx for status.")
         else:
-        #only 20 chars no more! :)
             txt = cmdargs[:20]
             self.session.set_text_status(str(txt))
-    # def on_status - end
 
-    
     def on_set(self, cmdargs):
         args = string.split(cmdargs,None,-1)
         keys = self.settings.get_setting_keys()
-        #print keys
         if len(args) == 0:
             line = "<table border='2'>"
             for m in keys:
@@ -378,11 +310,6 @@
                         self.chat.set_colors()
                         self.chat.set_buffersize()
 
-        # This subroutine will display the correct usage of the different emotions.
-        #
-        #!self : instance of self
-
-    
     def on_help(self, cmdargs=""):
         cmds = self.cmdlist.keys()
         cmds.sort()
@@ -400,11 +327,6 @@
             msg += ' %s' % (self.cmdlist[cmd]['help'])
         self.chat.InfoPost(msg)
 
-        # 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
-
-    
     def on_ignore(self, cmdargs):
         args = string.split(cmdargs,None,-1)
         (ignore_list, ignore_name) = self.session.get_ignore_list()
@@ -431,7 +353,6 @@
                     self.chat.InfoPost(m + " was ignored because it is an invalid player ID")
                     traceback.print_exc()
 
-    
     def on_role(self, cmdargs):
         if cmdargs == "":
             self.session.display_roles()
@@ -453,16 +374,7 @@
                     for m in player_ids:
                         self.session.set_role(m.strip(),role,role_pwd)
             except:  traceback.print_exc()
-#        return
 
-        # This subroutine implements the whisper functionality that enables a user
-        # to whisper to another user.
-        #
-        # !self : instance of self
-        # !text : string that is comprised of a list of users and the message to
-        #whisper.
-
-    
     def on_whisper(self, cmdargs):
         delim = cmdargs.find("=")
 
@@ -476,10 +388,6 @@
         mesg = string.strip(cmdargs[delim+1:])
         self.chat.whisper_to_players(mesg,player_ids)
 
-#---------------------------------------------------------
-# [START] Digitalxero Multi Whisper Group 1/1/05
-#---------------------------------------------------------
-    
     def on_groupwhisper(self, cmdargs):
         args = string.split(cmdargs,None,-1)
         delim = cmdargs.find("=")
@@ -533,11 +441,6 @@
                 else: idList = str(n) + ", " + idList
             self.on_whisper(idList + "=" + self.settings.get_setting("gwtext") + msg)
 
-#---------------------------------------------------------
-# [END] Digitalxero Multi Whisper Group 1/1/05
-#---------------------------------------------------------
-
-    
     def on_gmwhisper(self, cmdargs):
         if cmdargs == "":
             self.chat.InfoPost("**Incorrect syntax for GM Whisper.")
@@ -551,7 +454,6 @@
                 self.on_whisper(gmstring + "=" + cmdargs)
             else: self.chat.InfoPost("**No GMs to Whisper to.")
 
-    
     def on_moderate(self, cmdargs):
         if cmdargs != "":
             pos = cmdargs.find("=")
@@ -584,11 +486,9 @@
             self.session.outbox.put(msg)
         self.session.update()
 
-    
     def on_update(self, cmdargs):
         self.chat.InfoPost("This command is no longer valid")
 
-    
     def on_description(self, cmdargs):
         if len(cmdargs) <= 0:
             self.chat.InfoPost("**No description text to display." + str(delim))
@@ -599,13 +499,10 @@
         self.chat.Post(mesg)
         self.chat.send_chat_message(mesg)
 
-    
     def invoke_tab(self, cmdargs):
-        ######START mDuo13's Tab Initiator########
         try:
             int(cmdargs)
             playerid = cmdargs.strip()
-            # Check to see if parent notebook already has a private tab for player
             for panel in self.chat.parent.whisper_tabs:
                 if (panel.sendtarget == playerid):
                     self.chat.Post("Cannot invoke tab: Tab already exists.")
@@ -622,30 +519,22 @@
             nidx = self.chat.parent.get_tab_index(displaypanel)
             self.chat.parent.newMsg(nidx)
             return
-        #######END mDuo13's Tab Initiator#########
 
-
-    
     def on_remote_admin(self, cmdargs):
         args = string.split(cmdargs,None,-1)
-        #handles remote administration commands
         try:
             pass_state = 0
             pwd = self.session.orpgFrame_callback.password_manager.GetSilentPassword("server")
             if  pwd != None:
                 pass_state = 1
             else: pwd = "<i>[NONE]</i>"
-
             if len( args ) == 0:
-                #raw command return state info
                 msg = "<br /><b>Remote Administrator Config:</b>"
                 if pass_state != 1 : msg += " Password not set. Remote admin functions disabled<br />"
                 else: msg += " Enabled. Using password '"+pwd+"'<br />"
                 self.chat.SystemPost(msg)
                 return
-
             if pass_state != 1 and args[0] != "set":
-                #no commands under this point will execute unless an admin password has been previously set
                 self.chat.SystemPost("Command ignored. No remote administrator password set!!")
                 return
             msgbase = "<admin id='"+self.session.id+"' group_id='"+self.session.group_id+"' pwd='"+pwd+"'"
@@ -690,14 +579,12 @@
                     self.session.outbox.put(msg)
 
             elif args[0] == "banip":
-                #Ban a player from the server
                 try: bname = str(args[2])
                 except: bname = 'Unknown'
                 msg = msgbase + ' cmd="banip" bip="' + str(args[1]) + '" bname="' + bname + '"/>'
                 self.session.outbox.put(msg)
 
             elif args[0] == "createroom":
-                #request creation of a (temporary) persistant room
                 if len(args) < 2:
                     self.chat.SystemPost( "You must supply a name and boot password at least. <br />/admin createroom &lt;name&gt; &lt;boot password&gt; [password]" )
                     return
@@ -709,7 +596,6 @@
                 self.session.outbox.put(msg)
 
             else: self.chat.InfoPost("Unknown administrator command"  )
-            #command_function = {'banip': self.admin.r_admin_banip, 'createroom': self.r_admin_createroom,}
         except:
             self.chat.InfoPost("An error has occured while processing a Remote Administrator command!")
             traceback.print_exc()