comparison orpg/chat/commands.py @ 135:dcf4fbe09b70 beta

Traipse Beta 'OpenRPG' {091010-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) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core 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 default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana **Pretty important update that can help remove thousands of dead children from your gametree. **Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! **New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author sirebral
date Tue, 10 Nov 2009 14:11:28 -0600
parents 68c7bd272f27
children 3b6888bb53b5
comparison
equal deleted inserted replaced
101:394ebb3b6a0f 135:dcf4fbe09b70
6 # on_help(self) 6 # on_help(self)
7 # on_whisper(self,text) 7 # on_whisper(self,text)
8 # 8 #
9 9
10 10
11 import string 11 import string, time
12 import time
13 import orpg.orpg_version 12 import orpg.orpg_version
14 import orpg.orpg_windows 13 import orpg.orpg_windows
15 import traceback 14 import traceback
16 15
17 from orpg.orpgCore import component 16 from orpg.orpgCore import component
18 from orpg.tools.orpg_log import logger 17 from orpg.tools.orpg_log import logger
19 from orpg.tools.decorators import debugging
20 18
21 ##-------------------------------------------------------------- 19 ##--------------------------------------------------------------
22 ## dynamically loading module for extended developer commands 20 ## dynamically loading module for extended developer commands
23 ## allows developers to work on new chat commands without 21 ## allows developers to work on new chat commands without
24 ## integrating them directly into the ORPG code allowing 22 ## integrating them directly into the ORPG code allowing
38 36
39 # Initialization subroutine. 37 # Initialization subroutine.
40 # 38 #
41 # !self : instance of self 39 # !self : instance of self
42 # !chat : instance of the chat window to write to 40 # !chat : instance of the chat window to write to
43 @debugging 41
44 def __init__(self,chat): 42 def __init__(self,chat):
45 self.post = chat.Post 43 self.post = chat.Post
46 self.colorize = chat.colorize 44 self.colorize = chat.colorize
47 self.session = chat.session 45 self.session = chat.session
48 #self.send = chat.session.send 46 #self.send = chat.session.send
59 # This subroutine will take a text string and attempt to match to a series 57 # This subroutine will take a text string and attempt to match to a series
60 # of implemented emotions. 58 # of implemented emotions.
61 # 59 #
62 # !self : instance of self 60 # !self : instance of self
63 # !text : string of text matching an implemented emotion 61 # !text : string of text matching an implemented emotion
64 @debugging 62
65 def addcommand(self, cmd, function, helpmsg): 63 def addcommand(self, cmd, function, helpmsg):
66 if not self.cmdlist.has_key(cmd) and not self.shortcmdlist.has_key(cmd): 64 if not self.cmdlist.has_key(cmd) and not self.shortcmdlist.has_key(cmd):
67 self.cmdlist[cmd] = {} 65 self.cmdlist[cmd] = {}
68 self.cmdlist[cmd]['function'] = function 66 self.cmdlist[cmd]['function'] = function
69 self.cmdlist[cmd]['help'] = helpmsg 67 self.cmdlist[cmd]['help'] = helpmsg
70 #print 'Command Added: ' + cmd 68 #print 'Command Added: ' + cmd
71 69
72 @debugging 70
73 def addshortcmd(self, shortcmd, longcmd): 71 def addshortcmd(self, shortcmd, longcmd):
74 if not self.shortcmdlist.has_key(shortcmd) and not self.cmdlist.has_key(shortcmd): 72 if not self.shortcmdlist.has_key(shortcmd) and not self.cmdlist.has_key(shortcmd):
75 self.shortcmdlist[shortcmd] = longcmd 73 self.shortcmdlist[shortcmd] = longcmd
76 74
77 @debugging 75
78 def removecmd(self, cmd): 76 def removecmd(self, cmd):
79 if self.cmdlist.has_key(cmd): 77 if self.cmdlist.has_key(cmd):
80 del self.cmdlist[cmd] 78 del self.cmdlist[cmd]
81 elif self.shortcmdlist.has_key(cmd): 79 elif self.shortcmdlist.has_key(cmd):
82 del self.shortcmdlist[cmd] 80 del self.shortcmdlist[cmd]
83 81
84 #print 'Command Removed: ' + cmd 82 #print 'Command Removed: ' + cmd
85 83
86 84
87 @debugging 85
88 def defaultcmds(self): 86 def defaultcmds(self):
89 self.addcommand('/help', self.on_help, '- Displays this help message') 87 self.addcommand('/help', self.on_help, '- Displays this help message')
90 self.addcommand('/version', self.on_version, ' - Displays current version of OpenRPG.') 88 self.addcommand('/version', self.on_version, ' - Displays current version of OpenRPG.')
91 self.addcommand('/me', self.chat.emote_message, ' - Alias for **yourname does something.**') 89 self.addcommand('/me', self.chat.emote_message, ' - Alias for **yourname does something.**')
92 self.addcommand('/ignore', self.on_ignore, '[player_id,player_id,... | ignored_ip,ignored_ip,... | list] - Toggle ignore for user associated with that player ID. Using the IP will remove only not toggle.') 90 self.addcommand('/ignore', self.on_ignore, '[player_id,player_id,... | ignored_ip,ignored_ip,... | list] - Toggle ignore for user associated with that player ID. Using the IP will remove only not toggle.')
112 self.addcommand('/description', self.on_description, 'message - Creates a block of text, used for room descriptions and such') 110 self.addcommand('/description', self.on_description, 'message - Creates a block of text, used for room descriptions and such')
113 self.addcommand('/sound', self.on_sound, 'Sound_URL - Plays a sound for all clients in the room.') 111 self.addcommand('/sound', self.on_sound, 'Sound_URL - Plays a sound for all clients in the room.')
114 self.addcommand('/purge', self.on_purge, 'This will clear the entire chat window') 112 self.addcommand('/purge', self.on_purge, 'This will clear the entire chat window')
115 self.addcommand('/advfilter', self.on_filter, 'This will toggle the Advanced Filter') 113 self.addcommand('/advfilter', self.on_filter, 'This will toggle the Advanced Filter')
116 114
117 @debugging 115
118 def defaultcmdalias(self): 116 def defaultcmdalias(self):
119 self.addshortcmd('/?', '/help') 117 self.addshortcmd('/?', '/help')
120 self.addshortcmd('/he', '/me') 118 self.addshortcmd('/he', '/me')
121 self.addshortcmd('/she', '/me') 119 self.addshortcmd('/she', '/me')
122 self.addshortcmd('/i', '/ignore') 120 self.addshortcmd('/i', '/ignore')
127 self.addshortcmd('/d', '/description') 125 self.addshortcmd('/d', '/description')
128 126
129 #This is just an example or a differant way the shorcmd can be used 127 #This is just an example or a differant way the shorcmd can be used
130 self.addshortcmd('/sleep', '/me falls asleep') 128 self.addshortcmd('/sleep', '/me falls asleep')
131 129
132 @debugging 130
133 def docmd(self,text): 131 def docmd(self,text):
134 cmdsearch = string.split(text,None,1) 132 cmdsearch = string.split(text,None,1)
135 cmd = string.lower(cmdsearch[0]) 133 cmd = string.lower(cmdsearch[0])
136 start = len(cmd) 134 start = len(cmd)
137 end = len(text) 135 end = len(text)
143 self.docmd(self.shortcmdlist[cmd] + " " + cmdargs) 141 self.docmd(self.shortcmdlist[cmd] + " " + cmdargs)
144 else: 142 else:
145 msg = "Sorry I don't know what %s is!" % (cmd) 143 msg = "Sorry I don't know what %s is!" % (cmd)
146 self.chat.InfoPost(msg) 144 self.chat.InfoPost(msg)
147 145
148 @debugging 146
149 def on_filter(self, cmdargs): 147 def on_filter(self, cmdargs):
150 #print self.chat.advancedFilter 148 #print self.chat.advancedFilter
151 test = not self.chat.advancedFilter 149 test = not self.chat.advancedFilter
152 #print test 150 #print test
153 151
168 if self.chat.advancedFilter: 166 if self.chat.advancedFilter:
169 self.chat.InfoPost("Advanced Filtering has been turned On") 167 self.chat.InfoPost("Advanced Filtering has been turned On")
170 else: 168 else:
171 self.chat.InfoPost("Advanced Filtering has been turned Off") 169 self.chat.InfoPost("Advanced Filtering has been turned Off")
172 170
173 @debugging 171
174 def on_purge(self, cmdargs): 172 def on_purge(self, cmdargs):
175 self.chat.PurgeChat() 173 self.chat.PurgeChat()
176 self.chat.InfoPost('Chat Buffer has been Purged!') 174 self.chat.InfoPost('Chat Buffer has been Purged!')
177 175
178 @debugging 176
179 def on_sound(self, cmdargs): 177 def on_sound(self, cmdargs):
180 if len(cmdargs) < 8: 178 if len(cmdargs) < 8:
181 self.chat.InfoPost("You must provide a URL for the file name, it does not work for just local sound files") 179 self.chat.InfoPost("You must provide a URL for the file name, it does not work for just local sound files")
182 return 180 return
183 args = string.split(cmdargs, None, -1) 181 args = string.split(cmdargs, None, -1)
207 elif group_id == '0': 205 elif group_id == '0':
208 self.chat.InfoPost("You cannot send sound files to the lobby!") 206 self.chat.InfoPost("You cannot send sound files to the lobby!")
209 else: 207 else:
210 self.chat.InfoPost("Something dun fuckered up Frank!") 208 self.chat.InfoPost("Something dun fuckered up Frank!")
211 209
212 @debugging 210
213 def on_version(self, cmdargs=""): 211 def on_version(self, cmdargs=""):
214 self.chat.InfoPost("Version is OpenRPG " + self.chat.version) 212 self.chat.InfoPost("Version is OpenRPG " + self.chat.version)
215 213
216 @debugging 214
217 def on_load(self, cmdargs): 215 def on_load(self, cmdargs):
218 args = string.split(cmdargs,None,-1) 216 args = string.split(cmdargs,None,-1)
219 try: 217 try:
220 self.settings.setup_ini(args[0]) 218 self.settings.setup_ini(args[0])
221 self.settings.reload_settings(self.chat) 219 self.settings.reload_settings(self.chat)
222 self.chat.InfoPost("Settings Loaded from file " + args[0] ) 220 self.chat.InfoPost("Settings Loaded from file " + args[0] )
223 except Exception,e: 221 except Exception,e:
224 print e 222 print e
225 self.chat.InfoPost("ERROR Loading settings") 223 self.chat.InfoPost("ERROR Loading settings")
226 224
227 @debugging 225
228 def on_font(self, cmdargs): 226 def on_font(self, cmdargs):
229 try: 227 try:
230 fontsettings = self.chat.set_default_font(fontname=cmdargs, fontsize=None) 228 fontsettings = self.chat.set_default_font(fontname=cmdargs, fontsize=None)
231 except: 229 except:
232 self.chat.InfoPost("ERROR setting default font") 230 self.chat.InfoPost("ERROR setting default font")
233 231
234 @debugging 232
235 def on_fontsize(self, cmdargs): 233 def on_fontsize(self, cmdargs):
236 args = string.split(cmdargs,None,-1) 234 args = string.split(cmdargs,None,-1)
237 try: 235 try:
238 fontsettings = self.chat.set_default_font(fontname=None, fontsize=int(args[0])) 236 fontsettings = self.chat.set_default_font(fontname=None, fontsize=int(args[0]))
239 except Exception, e: 237 except Exception, e:
240 print e 238 print e
241 self.chat.InfoPost("ERROR setting default font size") 239 self.chat.InfoPost("ERROR setting default font size")
242 240
243 @debugging 241
244 def on_close(self, cmdargs): 242 def on_close(self, cmdargs):
245 try: 243 try:
246 chatpanel = self.chat 244 chatpanel = self.chat
247 if (chatpanel.sendtarget == "all"): 245 if (chatpanel.sendtarget == "all"):
248 chatpanel.InfoPost("Error: cannot close public chat tab.") 246 chatpanel.InfoPost("Error: cannot close public chat tab.")
250 chatpanel.chat_timer.Stop() 248 chatpanel.chat_timer.Stop()
251 chatpanel.parent.onCloseTab(0) 249 chatpanel.parent.onCloseTab(0)
252 except: 250 except:
253 self.chat.InfoPost("Error: cannot close private chat tab.") 251 self.chat.InfoPost("Error: cannot close private chat tab.")
254 252
255 @debugging 253
256 def on_time(self, cmdargs): 254 def on_time(self, cmdargs):
257 local_time = time.localtime() 255 local_time = time.localtime()
258 gmt_time = time.gmtime() 256 gmt_time = time.gmtime()
259 format_string = "%A %b %d, %Y %I:%M:%S%p" 257 format_string = "%A %b %d, %Y %I:%M:%S%p"
260 self.chat.InfoPost("<br />Local: " + time.strftime(format_string)+\ 258 self.chat.InfoPost("<br />Local: " + time.strftime(format_string)+\
261 "<br />GMT: "+time.strftime(format_string,gmt_time)) 259 "<br />GMT: "+time.strftime(format_string,gmt_time))
262 260
263 @debugging 261
264 def on_dieroller(self, cmdargs): 262 def on_dieroller(self, cmdargs):
265 args = string.split(cmdargs,None,-1) 263 args = string.split(cmdargs,None,-1)
266 rm = component.get('DiceManager') 264 rm = component.get('DiceManager')
267 try: 265 try:
268 rm.setRoller(args[0]) 266 rm.setRoller(args[0])
271 except Exception, e: 269 except Exception, e:
272 print e 270 print e
273 self.chat.InfoPost("Available die rollers: " + str(rm.listRollers())) 271 self.chat.InfoPost("Available die rollers: " + str(rm.listRollers()))
274 self.chat.InfoPost("You are using the <b>\"" + rm.getRoller() + "\"</b> die roller.") 272 self.chat.InfoPost("You are using the <b>\"" + rm.getRoller() + "\"</b> die roller.")
275 273
276 @debugging 274
277 def on_ping(self, cmdargs): 275 def on_ping(self, cmdargs):
278 ct = time.clock() 276 ct = time.clock()
279 msg = "<ping player='"+self.session.id+"' time='"+str(ct)+"' />" 277 msg = "<ping player='"+self.session.id+"' time='"+str(ct)+"' />"
280 self.session.outbox.put(msg) 278 self.session.outbox.put(msg)
281 279
282 @debugging 280
283 def on_log(self,cmdargs): 281 def on_log(self,cmdargs):
284 args = string.split(cmdargs,None,-1) 282 args = string.split(cmdargs,None,-1)
285 logfile = self.settings.get_setting( 'GameLogPrefix' ) 283 logfile = self.settings.get_setting( 'GameLogPrefix' )
286 284
287 if len( args ) == 0: 285 if len( args ) == 0:
309 self.chat.SystemPost('You must also specify a filename with the <em>/log to</em> command.' ) 307 self.chat.SystemPost('You must also specify a filename with the <em>/log to</em> command.' )
310 self.postLoggingState() 308 self.postLoggingState()
311 else: 309 else:
312 self.chat.InfoPost("Unknown logging command, use 'on' or 'off'" ) 310 self.chat.InfoPost("Unknown logging command, use 'on' or 'off'" )
313 311
314 @debugging 312
315 def postLoggingState( self ): 313 def postLoggingState( self ):
316 logfile = self.settings.get_setting( 'GameLogPrefix' ) 314 logfile = self.settings.get_setting( 'GameLogPrefix' )
317 try: 315 try:
318 if logfile[0] != ANTI_LOG_CHAR: 316 if logfile[0] != ANTI_LOG_CHAR: comment = 'is'
319 comment = 'is' 317 else: comment = 'is not'
320 else: 318 except: comment = 'is not'
321 comment = 'is not'
322 except:
323 comment = 'is not'
324 suffix = time.strftime( '-%d-%m-%y.html', time.localtime( time.time() ) ) 319 suffix = time.strftime( '-%d-%m-%y.html', time.localtime( time.time() ) )
325 self.chat.InfoPost('Log filename is "%s%s", system is %s logging.' % (logfile, suffix, comment) ) 320 self.chat.InfoPost('Log filename is "%s%s", system is %s logging.' % (logfile, suffix, comment) )
326 321
327 # This subroutine will set the players netork status. 322 # This subroutine will set the players netork status.
328 # 323 #
329 #!self : instance of self 324 #!self : instance of self
330 325
331 @debugging 326
332 def on_name(self, cmdargs): 327 def on_name(self, cmdargs):
333 #only 20 chars no more! :) 328 #only 20 chars no more! :)
334 if cmdargs == "": 329 if cmdargs == "":
335 self.chat.InfoPost("**Incorrect syntax for name.") 330 self.chat.InfoPost("**Incorrect syntax for name.")
336 else: 331 else:
337 #txt = txt[:50] 332 #txt = txt[:50]
338 self.settings.set_setting('player', cmdargs) 333 self.settings.set_setting('player', cmdargs)
339 self.session.set_name(str(cmdargs)) 334 self.session.set_name(str(cmdargs))
340 335
341 # def on_status - end 336 # def on_status - end
342
343 # This subroutine will set the players netork status. 337 # This subroutine will set the players netork status.
344 # 338 #
345 # !self : instance of self 339 # !self : instance of self
346 @debugging 340
347 def on_status(self, cmdargs): 341 def on_status(self, cmdargs):
348 if cmdargs == "": 342 if cmdargs == "":
349 self.chat.InfoPost("Incorrect synatx for status.") 343 self.chat.InfoPost("Incorrect synatx for status.")
350 else: 344 else:
351 #only 20 chars no more! :) 345 #only 20 chars no more! :)
352 txt = cmdargs[:20] 346 txt = cmdargs[:20]
353 self.session.set_text_status(str(txt)) 347 self.session.set_text_status(str(txt))
354 # def on_status - end 348 # def on_status - end
355 349
356 @debugging 350
357 def on_set(self, cmdargs): 351 def on_set(self, cmdargs):
358 args = string.split(cmdargs,None,-1) 352 args = string.split(cmdargs,None,-1)
359 keys = self.settings.get_setting_keys() 353 keys = self.settings.get_setting_keys()
360 #print keys 354 #print keys
361 if len(args) == 0: 355 if len(args) == 0:
386 380
387 # This subroutine will display the correct usage of the different emotions. 381 # This subroutine will display the correct usage of the different emotions.
388 # 382 #
389 #!self : instance of self 383 #!self : instance of self
390 384
391 @debugging 385
392 def on_help(self, cmdargs=""): 386 def on_help(self, cmdargs=""):
393 cmds = self.cmdlist.keys() 387 cmds = self.cmdlist.keys()
394 cmds.sort() 388 cmds.sort()
395 shortcmds = self.shortcmdlist.keys() 389 shortcmds = self.shortcmdlist.keys()
396 shortcmds.sort() 390 shortcmds.sort()
402 msg += '<br /><b><font color="#000000">%s</font></b>' % (cmd) 396 msg += '<br /><b><font color="#000000">%s</font></b>' % (cmd)
403 for shortcmd in shortcmds: 397 for shortcmd in shortcmds:
404 if self.shortcmdlist[shortcmd] == cmd: 398 if self.shortcmdlist[shortcmd] == cmd:
405 msg += ', <b><font color="#0000CC">%s</font></b>' % (shortcmd) 399 msg += ', <b><font color="#0000CC">%s</font></b>' % (shortcmd)
406 msg += ' %s' % (self.cmdlist[cmd]['help']) 400 msg += ' %s' % (self.cmdlist[cmd]['help'])
407
408 self.chat.InfoPost(msg) 401 self.chat.InfoPost(msg)
409 402
410 # This subroutine will either show the list of currently ignored users 403 # This subroutine will either show the list of currently ignored users
411 # !self : instance of self 404 # !self : instance of self
412 # !text : string that is comprised of a list of users to toggle the ignore flag 405 # !text : string that is comprised of a list of users to toggle the ignore flag
413 406
414 @debugging 407
415 def on_ignore(self, cmdargs): 408 def on_ignore(self, cmdargs):
416 args = string.split(cmdargs,None,-1) 409 args = string.split(cmdargs,None,-1)
417 (ignore_list, ignore_name) = self.session.get_ignore_list() 410 (ignore_list, ignore_name) = self.session.get_ignore_list()
418 ignore_output = self.colorize(self.chat.syscolor,"<br /><u>Player IDs Currently being Ignored:</u><br />") 411 ignore_output = self.colorize(self.chat.syscolor,"<br /><u>Player IDs Currently being Ignored:</u><br />")
419 if cmdargs == "": 412 if cmdargs == "":
436 self.chat.InfoPost("Player " + name + " with ID:" + id + " now being ignored") 429 self.chat.InfoPost("Player " + name + " with ID:" + id + " now being ignored")
437 except: 430 except:
438 self.chat.InfoPost(m + " was ignored because it is an invalid player ID") 431 self.chat.InfoPost(m + " was ignored because it is an invalid player ID")
439 traceback.print_exc() 432 traceback.print_exc()
440 433
441 @debugging 434
442 def on_role(self, cmdargs): 435 def on_role(self, cmdargs):
443 if cmdargs == "": 436 if cmdargs == "":
444 self.session.display_roles() 437 self.session.display_roles()
445 return 438 return
446 delim = cmdargs.find("=") 439 delim = cmdargs.find("=")
457 try: 450 try:
458 role_pwd = self.session.orpgFrame_callback.password_manager.GetPassword("admin",int(self.session.group_id)) 451 role_pwd = self.session.orpgFrame_callback.password_manager.GetPassword("admin",int(self.session.group_id))
459 if role_pwd != None: 452 if role_pwd != None:
460 for m in player_ids: 453 for m in player_ids:
461 self.session.set_role(m.strip(),role,role_pwd) 454 self.session.set_role(m.strip(),role,role_pwd)
462 except: 455 except: traceback.print_exc()
463 traceback.print_exc()
464 # return 456 # return
465 457
466 # This subroutine implements the whisper functionality that enables a user 458 # This subroutine implements the whisper functionality that enables a user
467 # to whisper to another user. 459 # to whisper to another user.
468 # 460 #
469 # !self : instance of self 461 # !self : instance of self
470 # !text : string that is comprised of a list of users and the message to 462 # !text : string that is comprised of a list of users and the message to
471 #whisper. 463 #whisper.
472 464
473 @debugging 465
474 def on_whisper(self, cmdargs): 466 def on_whisper(self, cmdargs):
475 delim = cmdargs.find("=") 467 delim = cmdargs.find("=")
476 468
477 if delim < 0: 469 if delim < 0:
478 if self.previous_whisper: 470 if self.previous_whisper: player_ids = self.previous_whisper
479 player_ids = self.previous_whisper
480 else: 471 else:
481 self.chat.InfoPost("**Incorrect syntax for whisper." + str(delim)) 472 self.chat.InfoPost("**Incorrect syntax for whisper." + str(delim))
482 return 473 return
483 else: 474 else: player_ids = string.split(cmdargs[:delim], ",")
484 player_ids = string.split(cmdargs[:delim], ",")
485 self.previous_whisper = player_ids 475 self.previous_whisper = player_ids
486 mesg = string.strip(cmdargs[delim+1:]) 476 mesg = string.strip(cmdargs[delim+1:])
487 self.chat.whisper_to_players(mesg,player_ids) 477 self.chat.whisper_to_players(mesg,player_ids)
488 478
489 #--------------------------------------------------------- 479 #---------------------------------------------------------
490 # [START] Digitalxero Multi Whisper Group 1/1/05 480 # [START] Digitalxero Multi Whisper Group 1/1/05
491 #--------------------------------------------------------- 481 #---------------------------------------------------------
492 @debugging 482
493 def on_groupwhisper(self, cmdargs): 483 def on_groupwhisper(self, cmdargs):
494 args = string.split(cmdargs,None,-1) 484 args = string.split(cmdargs,None,-1)
495 delim = cmdargs.find("=") 485 delim = cmdargs.find("=")
496 486
497 if delim > 0: 487 if delim > 0: group_ids = string.split(cmdargs[:delim], ",")
498 group_ids = string.split(cmdargs[:delim], ",")
499 elif args[0] == "add": 488 elif args[0] == "add":
500 if not orpg.player_list.WG_LIST.has_key(args[2]): 489 if not orpg.player_list.WG_LIST.has_key(args[2]):
501 orpg.player_list.WG_LIST[args[2]] = {} 490 orpg.player_list.WG_LIST[args[2]] = {}
502 orpg.player_list.WG_LIST[args[2]][int(args[1])] = int(args[1]) 491 orpg.player_list.WG_LIST[args[2]][int(args[1])] = int(args[1])
503 return 492 return
538 return 527 return
539 msg = string.strip(cmdargs[delim+1:]) 528 msg = string.strip(cmdargs[delim+1:])
540 for gid in group_ids: 529 for gid in group_ids:
541 idList = "" 530 idList = ""
542 for n in orpg.player_list.WG_LIST[gid]: 531 for n in orpg.player_list.WG_LIST[gid]:
543 if idList == "": 532 if idList == "": idList = str(n)
544 idList = str(n) 533 else: idList = str(n) + ", " + idList
545 else:
546 idList = str(n) + ", " + idList
547 self.on_whisper(idList + "=" + self.settings.get_setting("gwtext") + msg) 534 self.on_whisper(idList + "=" + self.settings.get_setting("gwtext") + msg)
548 535
549 #--------------------------------------------------------- 536 #---------------------------------------------------------
550 # [END] Digitalxero Multi Whisper Group 1/1/05 537 # [END] Digitalxero Multi Whisper Group 1/1/05
551 #--------------------------------------------------------- 538 #---------------------------------------------------------
552 539
553 @debugging 540
554 def on_gmwhisper(self, cmdargs): 541 def on_gmwhisper(self, cmdargs):
555 if cmdargs == "": 542 if cmdargs == "":
556 self.chat.InfoPost("**Incorrect syntax for GM Whisper.") 543 self.chat.InfoPost("**Incorrect syntax for GM Whisper.")
557 else: 544 else:
558 the_gms = self.chat.get_gms() 545 the_gms = self.chat.get_gms()
559 if len(the_gms): 546 if len(the_gms):
560 gmstring = "" 547 gmstring = ""
561 for each_gm in the_gms: 548 for each_gm in the_gms:
562 if gmstring != "": 549 if gmstring != "": gmstring += ","
563 gmstring += ","
564 gmstring += each_gm 550 gmstring += each_gm
565 self.on_whisper(gmstring + "=" + cmdargs) 551 self.on_whisper(gmstring + "=" + cmdargs)
566 else: 552 else: self.chat.InfoPost("**No GMs to Whisper to.")
567 self.chat.InfoPost("**No GMs to Whisper to.") 553
568 554
569 @debugging
570 def on_moderate(self, cmdargs): 555 def on_moderate(self, cmdargs):
571 if cmdargs != "": 556 if cmdargs != "":
572 pos = cmdargs.find("=") 557 pos = cmdargs.find("=")
573 if (pos < 0): 558 if (pos < 0):
574 plist = "" 559 plist = ""
575 if cmdargs.lower() == "on": 560 if cmdargs.lower() == "on": action = "enable"
576 action = "enable" 561 elif cmdargs.lower() == "off": action="disable"
577 elif cmdargs.lower() == "off":
578 action="disable"
579 else: 562 else:
580 self.chat.InfoPost("Wrong syntax for moderate command!") 563 self.chat.InfoPost("Wrong syntax for moderate command!")
581 return 564 return
582 else: 565 else:
583 plist = string.strip(cmdargs[:pos]) 566 plist = string.strip(cmdargs[:pos])
584 tag = string.strip(cmdargs[pos+1:]) 567 tag = string.strip(cmdargs[pos+1:])
585 if tag.lower() == "on": 568 if tag.lower() == "on": action = "addvoice"
586 action = "addvoice" 569 elif tag.lower() == "off": action = "delvoice"
587 elif tag.lower() == "off":
588 action = "delvoice"
589 else: 570 else:
590 self.chat.InfoPost("Wrong syntax for moderate command!") 571 self.chat.InfoPost("Wrong syntax for moderate command!")
591 return 572 return
592 pwd = self.session.orpgFrame_callback.password_manager.GetPassword("admin",int(self.session.group_id)) 573 pwd = self.session.orpgFrame_callback.password_manager.GetPassword("admin",int(self.session.group_id))
593 if pwd != None: 574 if pwd != None:
594 msg = "<moderate" 575 msg = "<moderate"
595 msg += " action = '" + action + "'" 576 msg += " action = '" + action + "'"
596 msg +=" from = '" + self.session.id + "' pwd='" + pwd + "'" 577 msg +=" from = '" + self.session.id + "' pwd='" + pwd + "'"
597 if (plist != ""): 578 if (plist != ""): msg += " users='"+plist+"'"
598 msg += " users='"+plist+"'"
599 msg += " />" 579 msg += " />"
600 self.session.outbox.put(msg) 580 self.session.outbox.put(msg)
601 pass 581 pass
602 else: 582 else:
603 msg = "<moderate action='list' from='"+self.session.id+"' />" 583 msg = "<moderate action='list' from='"+self.session.id+"' />"
604 self.session.outbox.put(msg) 584 self.session.outbox.put(msg)
605 self.session.update() 585 self.session.update()
606 586
607 @debugging 587
608 def on_update(self, cmdargs): 588 def on_update(self, cmdargs):
609 self.chat.InfoPost("This command is no longer valid") 589 self.chat.InfoPost("This command is no longer valid")
610 590
611 @debugging 591
612 def on_description(self, cmdargs): 592 def on_description(self, cmdargs):
613 if len(cmdargs) <= 0: 593 if len(cmdargs) <= 0:
614 self.chat.InfoPost("**No description text to display." + str(delim)) 594 self.chat.InfoPost("**No description text to display." + str(delim))
615 return 595 return
616 mesg = "<table bgcolor='#c0c0c0' border='3' cellpadding='5' cellspacing='0' width='100%'><tr><td><font color='#000000'>" 596 mesg = "<table bgcolor='#c0c0c0' border='3' cellpadding='5' cellspacing='0' width='100%'><tr><td><font color='#000000'>"
617 mesg += string.strip(cmdargs) 597 mesg += string.strip(cmdargs)
618 mesg += "</font></td></tr></table>" 598 mesg += "</font></td></tr></table>"
619 self.chat.Post(mesg) 599 self.chat.Post(mesg)
620 self.chat.send_chat_message(mesg) 600 self.chat.send_chat_message(mesg)
621 601
622 @debugging 602
623 def invoke_tab(self, cmdargs): 603 def invoke_tab(self, cmdargs):
624 ######START mDuo13's Tab Initiator######## 604 ######START mDuo13's Tab Initiator########
625 try: 605 try:
626 int(cmdargs) 606 int(cmdargs)
627 playerid = cmdargs.strip() 607 playerid = cmdargs.strip()
628 # Check to see if parent notebook already has a private tab for player 608 # Check to see if parent notebook already has a private tab for player
629 for panel in self.chat.parent.whisper_tabs: 609 for panel in self.chat.parent.whisper_tabs:
630 if (panel.sendtarget == playerid): 610 if (panel.sendtarget == playerid):
631 self.chat.Post("Cannot invoke tab: Tab already exists.") 611 self.chat.Post("Cannot invoke tab: Tab already exists.")
632 return 612 return
633 try: 613 try: displaypanel = self.chat.parent.create_whisper_tab(playerid)
634 displaypanel = self.chat.parent.create_whisper_tab(playerid)
635 except: 614 except:
636 self.chat.Post("That ID# is not valid.") 615 self.chat.Post("That ID# is not valid.")
637 return 616 return
638 nidx = self.chat.parent.get_tab_index(displaypanel) 617 nidx = self.chat.parent.get_tab_index(displaypanel)
639 self.chat.parent.newMsg(nidx) 618 self.chat.parent.newMsg(nidx)
643 nidx = self.chat.parent.get_tab_index(displaypanel) 622 nidx = self.chat.parent.get_tab_index(displaypanel)
644 self.chat.parent.newMsg(nidx) 623 self.chat.parent.newMsg(nidx)
645 return 624 return
646 #######END mDuo13's Tab Initiator######### 625 #######END mDuo13's Tab Initiator#########
647 626
648 @debugging 627
628
649 def on_remote_admin(self, cmdargs): 629 def on_remote_admin(self, cmdargs):
650 args = string.split(cmdargs,None,-1) 630 args = string.split(cmdargs,None,-1)
651 #handles remote administration commands 631 #handles remote administration commands
652 try: 632 try:
653 pass_state = 0 633 pass_state = 0
658 638
659 if len( args ) == 0: 639 if len( args ) == 0:
660 #raw command return state info 640 #raw command return state info
661 msg = "<br /><b>Remote Administrator Config:</b>" 641 msg = "<br /><b>Remote Administrator Config:</b>"
662 if pass_state != 1 : msg += " Password not set. Remote admin functions disabled<br />" 642 if pass_state != 1 : msg += " Password not set. Remote admin functions disabled<br />"
663 else: 643 else: msg += " Enabled. Using password '"+pwd+"'<br />"
664 msg += " Enabled. Using password \""+pwd+"\"<br />"
665 self.chat.SystemPost(msg) 644 self.chat.SystemPost(msg)
666 return 645 return
667 646
668 if pass_state != 1 and args[0] != "set": 647 if pass_state != 1 and args[0] != "set":
669 #no commands under this point will execute unless an admin password has been previously set 648 #no commands under this point will execute unless an admin password has been previously set
670 self.chat.SystemPost("Command ignored. No remote administrator password set!!") 649 self.chat.SystemPost("Command ignored. No remote administrator password set!!")
671 return 650 return
672 msgbase = "<admin id=\""+self.session.id+"\" group_id=\""+self.session.group_id+"\" pwd=\""+pwd+"\" " 651 msgbase = "<admin id='"+self.session.id+"' group_id='"+self.session.group_id+"' pwd='"+pwd+"'"
673 if args[0] == "set": 652 if args[0] == "set":
674 if len( args ) > 1: 653 if len( args ) > 1:
675 self.session.orpgFrame_callback.password_manager.server = str( args[1] ) 654 self.session.orpgFrame_callback.password_manager.server = str( args[1] )
676 self.chat.SystemPost( "Remote administration commands using password: \""+str(self.session.orpgFrame_callback.password_manager.GetSilentPassword("server"))+"\"" ) 655 self.chat.SystemPost( "Remote administration commands using password: "+str(self.session.orpgFrame_callback.password_manager.GetSilentPassword("server"))+"" )
677 else: 656 else:
678 pwd = self.session.orpgFrame_callback.password_manager.GetPassword("server") 657 pwd = self.session.orpgFrame_callback.password_manager.GetPassword("server")
679 if pwd != None: 658 if pwd != None:
680 self.chat.SystemPost( "Remote administration commands using password: \""+pwd+"\"" ) 659 self.chat.SystemPost( "Remote administration commands using password: "+pwd+"" )
681 660 elif len(args) == 1:
682 elif args[0] == "ban": 661 admin_command = {'banlist': ' cmd="banlist" />',
683 #Ban a player from the server 662 'help': " cmd='help' />",
684 msg = msgbase + ' cmd="ban" bid="' + str(args[1]) + '" />' 663 'roompasswords': " cmd='roompasswords' />",
685 self.session.outbox.put(msg) 664 'uptime': " cmd='uptime' />",
665 'list': " cmd='list' />",
666 'killserver': " cmd='killserver' />",
667 'savemaps': ' cmd="savemaps" />'
668 }
669 if admin_command.has_key(args[0]):
670 msg = msgbase + admin_command[args[0]]
671 self.session.outbox.put(msg)
672
673 elif len(args) == 2:
674 admin_command = {'ban': ' cmd="ban" bid="' + str(args[1]) + '" />',
675 'unban': ' cmd="unban" ip="' + str(args[1]) + '" />',
676 'broadcast': " cmd='broadcast' msg='"+ string.join(args[1:])+"' />",
677 'killgroup': " cmd='killgroup' gid='"+ str(args[1])+"' />"
678 }
679 if admin_command.has_key(args[0]):
680 msg = msgbase + admin_command[args[0]]
681 self.session.outbox.put(msg)
682
683 elif len(args) == 3:
684 admin_command = {'message':" cmd='message' to_id='"+ str(args[1])+"' msg='"+ string.join(args[2:])+"' />",
685 'nameroom': " cmd='nameroom' rmid='"+ str(args[1])+"' name='"+ string.join(args[2:])+"' />",
686 'passwd': " cmd='passwd' gid='"+str(args[1])+"' pass='"+ str(args[2])+"' />"
687 }
688 if admin_command.has_key(args[0]):
689 msg = msgbase + admin_command[args[0]]
690 self.session.outbox.put(msg)
686 691
687 elif args[0] == "banip": 692 elif args[0] == "banip":
688 #Ban a player from the server 693 #Ban a player from the server
689 try: 694 try: bname = str(args[2])
690 bname = str(args[2]) 695 except: bname = 'Unknown'
691 except:
692 bname = 'Unknown'
693 msg = msgbase + ' cmd="banip" bip="' + str(args[1]) + '" bname="' + bname + '"/>' 696 msg = msgbase + ' cmd="banip" bip="' + str(args[1]) + '" bname="' + bname + '"/>'
694 self.session.outbox.put(msg)
695
696 elif args[0] == "unban":
697 #remove a group from the server and drop all players within the group
698 msg = msgbase + ' cmd="unban" ip="' + str(args[1]) + '" />'
699 self.session.outbox.put(msg)
700
701 elif args[0] == "banlist":
702 #remove a group from the server and drop all players within the group
703 msg = msgbase + ' cmd="banlist" />'
704 self.session.outbox.put(msg)
705
706 elif args[0] == "help":
707 #request help from server
708 msg = msgbase + " cmd=\"help\" />"
709 self.session.outbox.put(msg)
710
711 elif args[0] == "nameroom":
712 #reqest room renaming on server
713 msg = msgbase + " cmd=\"nameroom\" rmid=\""+ str(args[1])+"\" name=\""+ string.join(args[2:])+"\" />"
714 self.session.outbox.put(msg)
715
716 elif args[0] == "roompasswords":
717 #reqest room renaming on server
718 msg = msgbase + " cmd=\"roompasswords\"/>"
719 self.session.outbox.put(msg)
720
721 elif args[0] == "message":
722 #send message to a specific player on the server via the system administrator
723 msg = msgbase + " cmd=\"message\" to_id=\""+ str(args[1])+"\" msg=\""+ string.join(args[2:])+"\" />"
724 self.session.outbox.put(msg)
725
726 elif args[0] == "broadcast":
727 #send a message to all players on server from the system administrator
728 msg = msgbase + " cmd=\"broadcast\" msg=\""+ string.join(args[1:])+"\" />"
729 self.session.outbox.put(msg)
730
731 elif args[0] == "killgroup":
732 #remove a group from the server and drop all players within the group
733 msg = msgbase + " cmd=\"killgroup\" gid=\""+ str(args[1])+"\" />"
734 self.session.outbox.put(msg)
735
736 elif args[0] == "uptime":
737 #request uptime report from server
738 msg = msgbase + " cmd=\"uptime\" />"
739 self.session.outbox.put(msg) 697 self.session.outbox.put(msg)
740 698
741 elif args[0] == "createroom": 699 elif args[0] == "createroom":
742 #request creation of a (temporary) persistant room 700 #request creation of a (temporary) persistant room
743 if len(args) < 2: 701 if len(args) < 2:
745 return 703 return
746 if len(args) < 3: 704 if len(args) < 3:
747 self.chat.SystemPost( "You must supply a boot password also.<br />/admin createroom &lt;name&gt; &lt;boot password&gt; [password]" ) 705 self.chat.SystemPost( "You must supply a boot password also.<br />/admin createroom &lt;name&gt; &lt;boot password&gt; [password]" )
748 return 706 return
749 if len(args) < 4: args.append("") 707 if len(args) < 4: args.append("")
750 msg = msgbase + " cmd=\"createroom\" name=\""+str(args[1])+"\" boot=\""+ str(args[2])+"\" pass=\""+ str(args[3])+"\" />" 708 msg = msgbase + " cmd='createroom' name='"+str(args[1])+"' boot='"+ str(args[2])+"' pass='"+ str(args[3])+"' />"
751 self.session.outbox.put(msg) 709 self.session.outbox.put(msg)
752 710
753 elif args[0] == "passwd": 711 else: self.chat.InfoPost("Unknown administrator command" )
754 #request boot password change on a room 712 #command_function = {'banip': self.admin.r_admin_banip, 'createroom': self.r_admin_createroom,}
755 msg = msgbase + " cmd=\"passwd\" gid=\""+str(args[1])+"\" pass=\""+ str(args[2])+"\" />"
756 self.session.outbox.put(msg)
757
758 elif args[0] == "list":
759 #request a list of rooms and players from server
760 msg = msgbase + " cmd=\"list\" />"
761 self.session.outbox.put(msg)
762
763 elif args[0] == "killserver":
764 #remotely kill the server
765 msg = msgbase + " cmd=\"killserver\" />"
766 self.session.outbox.put(msg)
767
768 elif args[0] == "savemaps":
769 msg = msgbase + ' cmd="savemaps" />'
770 self.session.outbox.put(msg)
771
772 else:
773 self.chat.InfoPost("Unknown administrator command" )
774 except: 713 except:
775 self.chat.InfoPost("An error has occured while processing a Remote Administrator command!") 714 self.chat.InfoPost("An error has occured while processing a Remote Administrator command!")
776 traceback.print_exc() 715 traceback.print_exc()