156
|
1 # This class implements the basic chat commands available in the chat interface.
|
|
2 #
|
|
3 # Defines:
|
|
4 # __init__(self,chat)
|
|
5 # docmd(self,text)
|
|
6 # on_help(self)
|
|
7 # on_whisper(self,text)
|
|
8 #
|
|
9
|
|
10
|
|
11 import string, time
|
|
12 import orpg.orpg_version
|
|
13 import orpg.orpg_windows
|
|
14 import traceback
|
|
15
|
|
16 from orpg.orpgCore import component
|
|
17 from orpg.tools.orpg_log import logger
|
|
18
|
|
19 ##--------------------------------------------------------------
|
|
20 ## dynamically loading module for extended developer commands
|
|
21 ## allows developers to work on new chat commands without
|
|
22 ## integrating them directly into the ORPG code allowing
|
|
23 ## updating of their code without merging changes
|
|
24 ## cmd_ext.py should NOT be included in the CVS or Actual Releases
|
|
25
|
|
26 try:
|
|
27 import cmd_ext
|
|
28 print "Importing Developer Extended Command Set"
|
|
29 except:
|
|
30 pass
|
|
31 ##----------------------------------------------------------------
|
|
32
|
|
33 ANTI_LOG_CHAR = '!'
|
|
34
|
|
35 class chat_commands:
|
|
36
|
|
37 # Initialization subroutine.
|
|
38 #
|
|
39 # !self : instance of self
|
|
40 # !chat : instance of the chat window to write to
|
|
41
|
|
42 def __init__(self,chat):
|
|
43 self.post = chat.Post
|
|
44 self.colorize = chat.colorize
|
|
45 self.session = chat.session
|
|
46 #self.send = chat.session.send
|
|
47 self.settings = chat.settings
|
|
48 self.chat = chat
|
|
49 self.cmdlist = {}
|
|
50 self.shortcmdlist = {}
|
|
51 self.defaultcmds()
|
|
52 self.defaultcmdalias()
|
|
53 # def __init__ - end
|
|
54 self.previous_whisper = []
|
|
55
|
|
56
|
|
57 # This subroutine will take a text string and attempt to match to a series
|
|
58 # of implemented emotions.
|
|
59 #
|
|
60 # !self : instance of self
|
|
61 # !text : string of text matching an implemented emotion
|
|
62
|
|
63 def addcommand(self, cmd, function, helpmsg):
|
|
64 if not self.cmdlist.has_key(cmd) and not self.shortcmdlist.has_key(cmd):
|
|
65 self.cmdlist[cmd] = {}
|
|
66 self.cmdlist[cmd]['function'] = function
|
|
67 self.cmdlist[cmd]['help'] = helpmsg
|
|
68 #print 'Command Added: ' + cmd
|
|
69
|
|
70
|
|
71 def addshortcmd(self, shortcmd, longcmd):
|
|
72 if not self.shortcmdlist.has_key(shortcmd) and not self.cmdlist.has_key(shortcmd):
|
|
73 self.shortcmdlist[shortcmd] = longcmd
|
|
74
|
|
75
|
|
76 def removecmd(self, cmd):
|
|
77 if self.cmdlist.has_key(cmd):
|
|
78 del self.cmdlist[cmd]
|
|
79 elif self.shortcmdlist.has_key(cmd):
|
|
80 del self.shortcmdlist[cmd]
|
|
81
|
|
82 #print 'Command Removed: ' + cmd
|
|
83
|
|
84
|
|
85
|
|
86 def defaultcmds(self):
|
|
87 self.addcommand('/help', self.on_help, '- Displays this help message')
|
|
88 self.addcommand('/version', self.on_version, ' - Displays current version of OpenRPG.')
|
|
89 self.addcommand('/me', self.chat.emote_message, ' - Alias for **yourname does something.**')
|
|
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.')
|
|
91 self.addcommand('/load', self.on_load, 'filename - Loads settings from another ini file from the myfiles directory.')
|
|
92 self.addcommand('/role', self.on_role, '[player_id = GM | Player | Lurker] - Get player roles from ther server, self.or change the role of a player.')
|
|
93 self.addcommand('/font', self.on_font, 'fontname - Sets the font.')
|
|
94 self.addcommand('/fontsize', self.on_fontsize, 'size - Sets the size of your fonts. Recomended 8 or better for the size.')
|
|
95 self.addcommand('/close', self.on_close, 'Close the chat tab')
|
|
96 self.addcommand('/set', self.on_set, '[setting[=value]] - Displays one or all settings, self.or sets a setting.')
|
|
97 self.addcommand('/whisper', self.on_whisper, 'player_id_number, ... = message - Whisper to player(s). Can contain multiple IDs.')
|
|
98 self.addcommand('/gw', self.on_groupwhisper, 'group_name=message - Type /gw help for more information')
|
|
99 self.addcommand('/gm', self.on_gmwhisper, 'message - Whispers to all GMs in the room')
|
|
100 self.addcommand('/name', self.on_name, 'name - Change your name.')
|
|
101 self.addcommand('/time', self.on_time, '- Display the local and GMT time and date.')
|
|
102 self.addcommand('/status', self.on_status, 'your_status - Set your online status (afk,away,etc..).')
|
|
103 self.addcommand('/dieroller', self.on_dieroller, '- Set your dieroller or list the available rollers.')
|
|
104 self.addcommand('/log', self.on_log, '[ on | off | to <em>filename</em> ] - Check log state, additionally turn logging on, self.off, self.or set the log filename prefix.')
|
|
105 self.addcommand('/update', self.on_update, '[get] - Get the latest version of OpenRPG.')
|
|
106 self.addcommand('/moderate', self.on_moderate, '[ on | off ][player_id=on|off] - Show who can speak in a moderated room, self.or turn room moderation on or off.')
|
|
107 self.addcommand('/tab', self.invoke_tab, 'player_id - Creates a tab so you can whisper rolls to youror what ever')
|
|
108 self.addcommand('/ping', self.on_ping, '- Ask for a response from the server.')
|
|
109 self.addcommand('/admin', self.on_remote_admin, '- Remote admin commands')
|
|
110 self.addcommand('/description', self.on_description, 'message - Creates a block of text, used for room descriptions and such')
|
|
111 self.addcommand('/sound', self.on_sound, 'Sound_URL - Plays a sound for all clients in the room.')
|
|
112 self.addcommand('/purge', self.on_purge, 'This will clear the entire chat window')
|
|
113 self.addcommand('/advfilter', self.on_filter, 'This will toggle the Advanced Filter')
|
|
114
|
|
115
|
|
116 def defaultcmdalias(self):
|
|
117 self.addshortcmd('/?', '/help')
|
|
118 self.addshortcmd('/he', '/me')
|
|
119 self.addshortcmd('/she', '/me')
|
|
120 self.addshortcmd('/i', '/ignore')
|
|
121 self.addshortcmd('/w', '/whisper')
|
|
122 self.addshortcmd('/nick', '/name')
|
|
123 self.addshortcmd('/date', '/time')
|
|
124 self.addshortcmd('/desc', '/description')
|
|
125 self.addshortcmd('/d', '/description')
|
|
126
|
|
127 #This is just an example or a differant way the shorcmd can be used
|
|
128 self.addshortcmd('/sleep', '/me falls asleep')
|
|
129
|
|
130
|
|
131 def docmd(self,text):
|
|
132 cmdsearch = string.split(text,None,1)
|
|
133 cmd = string.lower(cmdsearch[0])
|
|
134 start = len(cmd)
|
|
135 end = len(text)
|
|
136 cmdargs = text[start+1:end]
|
|
137
|
|
138 if self.cmdlist.has_key(cmd):
|
|
139 self.cmdlist[cmd]['function'](cmdargs)
|
|
140 elif self.shortcmdlist.has_key(cmd):
|
|
141 self.docmd(self.shortcmdlist[cmd] + " " + cmdargs)
|
|
142 else:
|
|
143 msg = "Sorry I don't know what %s is!" % (cmd)
|
|
144 self.chat.InfoPost(msg)
|
|
145
|
|
146
|
|
147 def on_filter(self, cmdargs):
|
|
148 #print self.chat.advancedFilter
|
|
149 test = not self.chat.advancedFilter
|
|
150 #print test
|
|
151
|
|
152 for tab in self.chat.parent.whisper_tabs:
|
|
153 tab.advancedFilter = not self.chat.advancedFilter
|
|
154
|
|
155 for tab in self.chat.parent.null_tabs:
|
|
156 tab.advancedFilter = not self.chat.advancedFilter
|
|
157
|
|
158 for tab in self.chat.parent.group_tabs:
|
|
159 tab.advancedFilter = not self.chat.advancedFilter
|
|
160
|
|
161 if self.chat.parent.GMChatPanel != None:
|
|
162 self.chat.parent.GMChatPanel.advancedFilter = not self.chat.advancedFilter
|
|
163
|
|
164 self.chat.advancedFilter = not self.chat.advancedFilter
|
|
165
|
|
166 if self.chat.advancedFilter:
|
|
167 self.chat.InfoPost("Advanced Filtering has been turned On")
|
|
168 else:
|
|
169 self.chat.InfoPost("Advanced Filtering has been turned Off")
|
|
170
|
|
171
|
|
172 def on_purge(self, cmdargs):
|
|
173 self.chat.PurgeChat()
|
|
174 self.chat.InfoPost('Chat Buffer has been Purged!')
|
|
175
|
|
176
|
|
177 def on_sound(self, cmdargs):
|
|
178 if len(cmdargs) < 8:
|
|
179 self.chat.InfoPost("You must provide a URL for the file name, it does not work for just local sound files")
|
|
180 return
|
|
181 args = string.split(cmdargs, None, -1)
|
|
182
|
|
183 if args[0] == 'loop':
|
|
184 snd = args[1].replace('&', '&')
|
|
185 loop = '1'
|
|
186 else:
|
|
187 snd = cmdargs.replace('&', '&')
|
|
188 loop = ''
|
|
189
|
|
190 type = 'remote'
|
|
191
|
|
192 (name, ip, id, text_status, version, protocol_version, client_string, role) = self.session.get_my_info()
|
|
193 group_id = self.session.group_id
|
|
194 if (role != 'Lurker' and group_id != '0') or self.session.get_status() != 1:
|
|
195 try:
|
|
196 self.chat.sound_player.play(snd, type, loop)
|
|
197 if type == 'remote':
|
|
198 snd_xml = '<sound url="' + snd + '" group_id="' + group_id + '" from="' + id + '" loop="' + str(loop) + '" />'
|
|
199 self.session.send_sound(snd_xml)
|
|
200 except Exception, e:
|
|
201 print e
|
|
202 self.chat.InfoPost("Invalid sound file!")
|
|
203 elif role == 'Lurker':
|
|
204 self.chat.InfoPost("You must be a player or a GM to send a sound file!")
|
|
205 elif group_id == '0':
|
|
206 self.chat.InfoPost("You cannot send sound files to the lobby!")
|
|
207 else:
|
|
208 self.chat.InfoPost("Something dun fuckered up Frank!")
|
|
209
|
|
210
|
|
211 def on_version(self, cmdargs=""):
|
|
212 self.chat.InfoPost("Version is OpenRPG " + self.chat.version)
|
|
213
|
|
214
|
|
215 def on_load(self, cmdargs):
|
|
216 args = string.split(cmdargs,None,-1)
|
|
217 try:
|
|
218 self.settings.setup_ini(args[0])
|
|
219 self.settings.reload_settings(self.chat)
|
|
220 self.chat.InfoPost("Settings Loaded from file " + args[0] )
|
|
221 except Exception,e:
|
|
222 print e
|
|
223 self.chat.InfoPost("ERROR Loading settings")
|
|
224
|
|
225
|
|
226 def on_font(self, cmdargs):
|
|
227 try:
|
|
228 fontsettings = self.chat.set_default_font(fontname=cmdargs, fontsize=None)
|
|
229 except:
|
|
230 self.chat.InfoPost("ERROR setting default font")
|
|
231
|
|
232
|
|
233 def on_fontsize(self, cmdargs):
|
|
234 args = string.split(cmdargs,None,-1)
|
|
235 try:
|
|
236 fontsettings = self.chat.set_default_font(fontname=None, fontsize=int(args[0]))
|
|
237 except Exception, e:
|
|
238 print e
|
|
239 self.chat.InfoPost("ERROR setting default font size")
|
|
240
|
|
241
|
|
242 def on_close(self, cmdargs):
|
|
243 try:
|
|
244 chatpanel = self.chat
|
|
245 if (chatpanel.sendtarget == "all"):
|
|
246 chatpanel.InfoPost("Error: cannot close public chat tab.")
|
|
247 else:
|
|
248 chatpanel.chat_timer.Stop()
|
|
249 chatpanel.parent.onCloseTab(0)
|
|
250 except:
|
|
251 self.chat.InfoPost("Error: cannot close private chat tab.")
|
|
252
|
|
253
|
|
254 def on_time(self, cmdargs):
|
|
255 local_time = time.localtime()
|
|
256 gmt_time = time.gmtime()
|
|
257 format_string = "%A %b %d, %Y %I:%M:%S%p"
|
|
258 self.chat.InfoPost("<br />Local: " + time.strftime(format_string)+\
|
|
259 "<br />GMT: "+time.strftime(format_string,gmt_time))
|
|
260
|
|
261
|
|
262 def on_dieroller(self, cmdargs):
|
|
263 args = string.split(cmdargs,None,-1)
|
|
264 rm = component.get('DiceManager')
|
|
265 try:
|
|
266 rm.setRoller(args[0])
|
|
267 self.chat.SystemPost("You have changed your die roller to the <b>\"" + args[0] + "\"</b> roller.")
|
|
268 self.settings.set_setting('dieroller',args[0])
|
|
269 except Exception, e:
|
|
270 print e
|
|
271 self.chat.InfoPost("Available die rollers: " + str(rm.listRollers()))
|
|
272 self.chat.InfoPost("You are using the <b>\"" + rm.getRoller() + "\"</b> die roller.")
|
|
273
|
|
274
|
|
275 def on_ping(self, cmdargs):
|
|
276 ct = time.clock()
|
|
277 msg = "<ping player='"+self.session.id+"' time='"+str(ct)+"' />"
|
|
278 self.session.outbox.put(msg)
|
|
279
|
|
280
|
|
281 def on_log(self,cmdargs):
|
|
282 args = string.split(cmdargs,None,-1)
|
|
283 logfile = self.settings.get_setting( 'GameLogPrefix' )
|
|
284
|
|
285 if len( args ) == 0:
|
|
286 self.postLoggingState()
|
|
287 elif args[0] == "on" and logfile != '':
|
|
288 try:
|
|
289 while logfile[ 0 ] == ANTI_LOG_CHAR:
|
|
290 #print logfile
|
|
291 logfile = logfile[ 1: ]
|
|
292 except IndexError,e:
|
|
293 self.chat.SystemPost("log filename is blank, system will *not* be logging until a valid filename is specified" )
|
|
294 self.settings.set_setting( 'GameLogPrefix', logfile )
|
|
295 return
|
|
296 self.settings.set_setting( 'GameLogPrefix', logfile )
|
|
297 self.postLoggingState()
|
|
298 elif args[0] == "off":
|
|
299 logfile = ANTI_LOG_CHAR+logfile
|
|
300 self.settings.set_setting( 'GameLogPrefix', logfile )
|
|
301 self.postLoggingState()
|
|
302 elif args[0] == "to":
|
|
303 if len( args ) > 1:
|
|
304 logfile = args[1]
|
|
305 self.settings.set_setting( 'GameLogPrefix', logfile )
|
|
306 else:
|
|
307 self.chat.SystemPost('You must also specify a filename with the <em>/log to</em> command.' )
|
|
308 self.postLoggingState()
|
|
309 else:
|
|
310 self.chat.InfoPost("Unknown logging command, use 'on' or 'off'" )
|
|
311
|
|
312
|
|
313 def postLoggingState( self ):
|
|
314 logfile = self.settings.get_setting( 'GameLogPrefix' )
|
|
315 try:
|
|
316 if logfile[0] != ANTI_LOG_CHAR: comment = 'is'
|
|
317 else: comment = 'is not'
|
|
318 except: comment = 'is not'
|
|
319 suffix = time.strftime( '-%d-%m-%y.html', time.localtime( time.time() ) )
|
|
320 self.chat.InfoPost('Log filename is "%s%s", system is %s logging.' % (logfile, suffix, comment) )
|
|
321
|
|
322 # This subroutine will set the players netork status.
|
|
323 #
|
|
324 #!self : instance of self
|
|
325
|
|
326
|
|
327 def on_name(self, cmdargs):
|
|
328 #only 20 chars no more! :)
|
|
329 if cmdargs == "":
|
|
330 self.chat.InfoPost("**Incorrect syntax for name.")
|
|
331 else:
|
|
332 #txt = txt[:50]
|
|
333 self.settings.set_setting('player', cmdargs)
|
|
334 self.session.set_name(str(cmdargs))
|
|
335
|
|
336 # def on_status - end
|
|
337 # This subroutine will set the players netork status.
|
|
338 #
|
|
339 # !self : instance of self
|
|
340
|
|
341 def on_status(self, cmdargs):
|
|
342 if cmdargs == "":
|
|
343 self.chat.InfoPost("Incorrect synatx for status.")
|
|
344 else:
|
|
345 #only 20 chars no more! :)
|
|
346 txt = cmdargs[:20]
|
|
347 self.session.set_text_status(str(txt))
|
|
348 # def on_status - end
|
|
349
|
|
350
|
|
351 def on_set(self, cmdargs):
|
|
352 args = string.split(cmdargs,None,-1)
|
|
353 keys = self.settings.get_setting_keys()
|
|
354 #print keys
|
|
355 if len(args) == 0:
|
|
356 line = "<table border='2'>"
|
|
357 for m in keys:
|
|
358 line += "<tr><td>" + str(m) + "</td><td> " + str(self.settings.get_setting(m)) + "</td></tr>"
|
|
359 line += "</table>"
|
|
360 self.chat.InfoPost(line)
|
|
361 else:
|
|
362 split_name_from_data = cmdargs.find("=")
|
|
363 if split_name_from_data == -1:
|
|
364 for m in keys:
|
|
365 if m == args[0]:
|
|
366 return_string = "<table border='2'><tr><td>" + args[0] + "</td><td>"\
|
|
367 + self.settings.get_setting(args[0]) + "</td></tr></table>"
|
|
368 self.chat.InfoPost(return_string)
|
|
369 else:
|
|
370 name = cmdargs[:split_name_from_data].strip()
|
|
371 for m in keys:
|
|
372 if m == name:
|
|
373 setting = cmdargs[split_name_from_data+1:].strip()
|
|
374 self.settings.set_setting(name,setting)
|
|
375 return_string = name + " changed to " + setting
|
|
376 self.chat.InfoPost(return_string)
|
|
377 self.session.set_name(self.settings.get_setting("player"))
|
|
378 self.chat.set_colors()
|
|
379 self.chat.set_buffersize()
|
|
380
|
|
381 # This subroutine will display the correct usage of the different emotions.
|
|
382 #
|
|
383 #!self : instance of self
|
|
384
|
|
385
|
|
386 def on_help(self, cmdargs=""):
|
|
387 cmds = self.cmdlist.keys()
|
|
388 cmds.sort()
|
|
389 shortcmds = self.shortcmdlist.keys()
|
|
390 shortcmds.sort()
|
|
391 msg = '<br /><b>Command Alias List:</b>'
|
|
392 for shortcmd in shortcmds:
|
|
393 msg += '<br /><b><font color="#0000CC">%s</font></b> is short for <font color="#000000">%s</font>' % (shortcmd, self.shortcmdlist[shortcmd])
|
|
394 msg += '<br /><br /><b>Command List:</b>'
|
|
395 for cmd in cmds:
|
|
396 msg += '<br /><b><font color="#000000">%s</font></b>' % (cmd)
|
|
397 for shortcmd in shortcmds:
|
|
398 if self.shortcmdlist[shortcmd] == cmd:
|
|
399 msg += ', <b><font color="#0000CC">%s</font></b>' % (shortcmd)
|
|
400 msg += ' %s' % (self.cmdlist[cmd]['help'])
|
|
401 self.chat.InfoPost(msg)
|
|
402
|
|
403 # This subroutine will either show the list of currently ignored users
|
|
404 # !self : instance of self
|
|
405 # !text : string that is comprised of a list of users to toggle the ignore flag
|
|
406
|
|
407
|
|
408 def on_ignore(self, cmdargs):
|
|
409 args = string.split(cmdargs,None,-1)
|
|
410 (ignore_list, ignore_name) = self.session.get_ignore_list()
|
|
411 ignore_output = self.colorize(self.chat.syscolor,"<br /><u>Player IDs Currently being Ignored:</u><br />")
|
|
412 if cmdargs == "":
|
|
413 if len(ignore_list) == 0:
|
|
414 ignore_output += self.colorize(self.chat.infocolor,"No players are currently being ignored.<br />")
|
|
415 else:
|
|
416 for m in ignore_list:
|
|
417 ignore_txt = m + " " + ignore_name[ignore_list.index(m)] + "<br />"
|
|
418 ignore_output += self.colorize(self.chat.infocolor,ignore_txt)
|
|
419 self.chat.Post(ignore_output)
|
|
420 else:
|
|
421 players = cmdargs.split(",")
|
|
422 for m in players:
|
|
423 try:
|
|
424 id = `int(m)`
|
|
425 (result, id, name) = self.session.toggle_ignore(id)
|
|
426 if result == 0:
|
|
427 self.chat.InfoPost("Player " + name + " with ID:" + id + " no longer ignored")
|
|
428 if result == 1:
|
|
429 self.chat.InfoPost("Player " + name + " with ID:" + id + " now being ignored")
|
|
430 except:
|
|
431 self.chat.InfoPost(m + " was ignored because it is an invalid player ID")
|
|
432 traceback.print_exc()
|
|
433
|
|
434
|
|
435 def on_role(self, cmdargs):
|
|
436 if cmdargs == "":
|
|
437 self.session.display_roles()
|
|
438 return
|
|
439 delim = cmdargs.find("=")
|
|
440 if delim < 0:
|
|
441 self.chat.InfoPost("**Incorrect synatax for Role." + str(delim))
|
|
442 return
|
|
443 player_ids = string.split(cmdargs[:delim],",")
|
|
444 role = cmdargs[delim+1:].strip()
|
|
445 role = role.lower()
|
|
446 if (role.lower() == "player") or (role.lower() == "gm") or (role.lower() == "lurker"):
|
|
447 if role.lower() == "player": role = "Player"
|
|
448 elif role.lower() == "gm": role = "GM"
|
|
449 else: role = "Lurker"
|
|
450 try:
|
|
451 role_pwd = self.session.orpgFrame_callback.password_manager.GetPassword("admin",int(self.session.group_id))
|
|
452 if role_pwd != None:
|
|
453 for m in player_ids:
|
|
454 self.session.set_role(m.strip(),role,role_pwd)
|
|
455 except: traceback.print_exc()
|
|
456 # return
|
|
457
|
|
458 # This subroutine implements the whisper functionality that enables a user
|
|
459 # to whisper to another user.
|
|
460 #
|
|
461 # !self : instance of self
|
|
462 # !text : string that is comprised of a list of users and the message to
|
|
463 #whisper.
|
|
464
|
|
465
|
|
466 def on_whisper(self, cmdargs):
|
|
467 delim = cmdargs.find("=")
|
|
468
|
|
469 if delim < 0:
|
|
470 if self.previous_whisper: player_ids = self.previous_whisper
|
|
471 else:
|
|
472 self.chat.InfoPost("**Incorrect syntax for whisper." + str(delim))
|
|
473 return
|
|
474 else: player_ids = string.split(cmdargs[:delim], ",")
|
|
475 self.previous_whisper = player_ids
|
|
476 mesg = string.strip(cmdargs[delim+1:])
|
|
477 self.chat.whisper_to_players(mesg,player_ids)
|
|
478
|
|
479 #---------------------------------------------------------
|
|
480 # [START] Digitalxero Multi Whisper Group 1/1/05
|
|
481 #---------------------------------------------------------
|
|
482
|
|
483 def on_groupwhisper(self, cmdargs):
|
|
484 args = string.split(cmdargs,None,-1)
|
|
485 delim = cmdargs.find("=")
|
|
486
|
|
487 if delim > 0: group_ids = string.split(cmdargs[:delim], ",")
|
|
488 elif args[0] == "add":
|
|
489 if not orpg.player_list.WG_LIST.has_key(args[2]):
|
|
490 orpg.player_list.WG_LIST[args[2]] = {}
|
|
491 orpg.player_list.WG_LIST[args[2]][int(args[1])] = int(args[1])
|
|
492 return
|
|
493 elif args[0] == "remove" or args[0] == "delete":
|
|
494 del orpg.player_list.WG_LIST[args[2]][int(args[1])]
|
|
495 if len(orpg.player_list.WG_LIST[args[2]]) == 0:
|
|
496 del orpg.player_list.WG_LIST[args[2]]
|
|
497 return
|
|
498 elif args[0] == "create" or args[0] == "new_group":
|
|
499 if not orpg.player_list.WG_LIST.has_key(args[1]):
|
|
500 orpg.player_list.WG_LIST[args[1]] = {}
|
|
501 return
|
|
502 elif args[0] == "list":
|
|
503 if orpg.player_list.WG_LIST.has_key(args[1]):
|
|
504 for n in orpg.player_list.WG_LIST[args[1]]:
|
|
505 player = self.session.get_player_info(str(n))
|
|
506 self.chat.InfoPost(str(player[0]))
|
|
507 else:
|
|
508 self.chat.InfoPost("Invalid Whisper Group Name")
|
|
509 return
|
|
510 elif args[0] == "clear":
|
|
511 if orpg.player_list.WG_LIST.has_key(args[1]):
|
|
512 orpg.player_list.WG_LIST[args[1]].clear()
|
|
513 else:
|
|
514 self.chat.InfoPost("Invalid Whisper Group Name")
|
|
515 return
|
|
516 elif args[0] == "clearall":
|
|
517 orpg.player_list.WG_LIST.clear()
|
|
518 return
|
|
519 else:
|
|
520 self.chat.InfoPost("<b>/gw add</b> (player_id) (group_name) - Adds [player_id] to [group_name]")
|
|
521 self.chat.InfoPost("<b>/gw remove</b> (player_id) (group_name) - Removes [player_id] from [group_name]")
|
|
522 self.chat.InfoPost("<b>/gw</b> (group_name)<b>=</b>(message) - Sends [message] to [group_name]")
|
|
523 self.chat.InfoPost("<b>/gw create</b> (group_name) - Creates a whisper group called [group_name]")
|
|
524 self.chat.InfoPost("<b>/gw list</b> (group_name) - Lists all players in [group_name]")
|
|
525 self.chat.InfoPost("<b>/gw clear</b> (group_name) - Removes all players from [group_name]")
|
|
526 self.chat.InfoPost("<b>/gw clearall</b> - Removes all existing whisper groups")
|
|
527 return
|
|
528 msg = string.strip(cmdargs[delim+1:])
|
|
529 for gid in group_ids:
|
|
530 idList = ""
|
|
531 for n in orpg.player_list.WG_LIST[gid]:
|
|
532 if idList == "": idList = str(n)
|
|
533 else: idList = str(n) + ", " + idList
|
|
534 self.on_whisper(idList + "=" + self.settings.get_setting("gwtext") + msg)
|
|
535
|
|
536 #---------------------------------------------------------
|
|
537 # [END] Digitalxero Multi Whisper Group 1/1/05
|
|
538 #---------------------------------------------------------
|
|
539
|
|
540
|
|
541 def on_gmwhisper(self, cmdargs):
|
|
542 if cmdargs == "":
|
|
543 self.chat.InfoPost("**Incorrect syntax for GM Whisper.")
|
|
544 else:
|
|
545 the_gms = self.chat.get_gms()
|
|
546 if len(the_gms):
|
|
547 gmstring = ""
|
|
548 for each_gm in the_gms:
|
|
549 if gmstring != "": gmstring += ","
|
|
550 gmstring += each_gm
|
|
551 self.on_whisper(gmstring + "=" + cmdargs)
|
|
552 else: self.chat.InfoPost("**No GMs to Whisper to.")
|
|
553
|
|
554
|
|
555 def on_moderate(self, cmdargs):
|
|
556 if cmdargs != "":
|
|
557 pos = cmdargs.find("=")
|
|
558 if (pos < 0):
|
|
559 plist = ""
|
|
560 if cmdargs.lower() == "on": action = "enable"
|
|
561 elif cmdargs.lower() == "off": action="disable"
|
|
562 else:
|
|
563 self.chat.InfoPost("Wrong syntax for moderate command!")
|
|
564 return
|
|
565 else:
|
|
566 plist = string.strip(cmdargs[:pos])
|
|
567 tag = string.strip(cmdargs[pos+1:])
|
|
568 if tag.lower() == "on": action = "addvoice"
|
|
569 elif tag.lower() == "off": action = "delvoice"
|
|
570 else:
|
|
571 self.chat.InfoPost("Wrong syntax for moderate command!")
|
|
572 return
|
|
573 pwd = self.session.orpgFrame_callback.password_manager.GetPassword("admin",int(self.session.group_id))
|
|
574 if pwd != None:
|
|
575 msg = "<moderate"
|
|
576 msg += " action = '" + action + "'"
|
|
577 msg +=" from = '" + self.session.id + "' pwd='" + pwd + "'"
|
|
578 if (plist != ""): msg += " users='"+plist+"'"
|
|
579 msg += " />"
|
|
580 self.session.outbox.put(msg)
|
|
581 pass
|
|
582 else:
|
|
583 msg = "<moderate action='list' from='"+self.session.id+"' />"
|
|
584 self.session.outbox.put(msg)
|
|
585 self.session.update()
|
|
586
|
|
587
|
|
588 def on_update(self, cmdargs):
|
|
589 self.chat.InfoPost("This command is no longer valid")
|
|
590
|
|
591
|
|
592 def on_description(self, cmdargs):
|
|
593 if len(cmdargs) <= 0:
|
|
594 self.chat.InfoPost("**No description text to display." + str(delim))
|
|
595 return
|
|
596 mesg = "<table bgcolor='#c0c0c0' border='3' cellpadding='5' cellspacing='0' width='100%'><tr><td><font color='#000000'>"
|
|
597 mesg += string.strip(cmdargs)
|
|
598 mesg += "</font></td></tr></table>"
|
|
599 self.chat.Post(mesg)
|
|
600 self.chat.send_chat_message(mesg)
|
|
601
|
|
602
|
|
603 def invoke_tab(self, cmdargs):
|
|
604 ######START mDuo13's Tab Initiator########
|
|
605 try:
|
|
606 int(cmdargs)
|
|
607 playerid = cmdargs.strip()
|
|
608 # Check to see if parent notebook already has a private tab for player
|
|
609 for panel in self.chat.parent.whisper_tabs:
|
|
610 if (panel.sendtarget == playerid):
|
|
611 self.chat.Post("Cannot invoke tab: Tab already exists.")
|
|
612 return
|
|
613 try: displaypanel = self.chat.parent.create_whisper_tab(playerid)
|
|
614 except:
|
|
615 self.chat.Post("That ID# is not valid.")
|
|
616 return
|
|
617 nidx = self.chat.parent.get_tab_index(displaypanel)
|
|
618 self.chat.parent.newMsg(nidx)
|
|
619 return
|
|
620 except:
|
|
621 displaypanel = self.chat.parent.create_null_tab(cmdargs)
|
|
622 nidx = self.chat.parent.get_tab_index(displaypanel)
|
|
623 self.chat.parent.newMsg(nidx)
|
|
624 return
|
|
625 #######END mDuo13's Tab Initiator#########
|
|
626
|
|
627
|
|
628
|
|
629 def on_remote_admin(self, cmdargs):
|
|
630 args = string.split(cmdargs,None,-1)
|
|
631 #handles remote administration commands
|
|
632 try:
|
|
633 pass_state = 0
|
|
634 pwd = self.session.orpgFrame_callback.password_manager.GetSilentPassword("server")
|
|
635 if pwd != None:
|
|
636 pass_state = 1
|
|
637 else: pwd = "<i>[NONE]</i>"
|
|
638
|
|
639 if len( args ) == 0:
|
|
640 #raw command return state info
|
|
641 msg = "<br /><b>Remote Administrator Config:</b>"
|
|
642 if pass_state != 1 : msg += " Password not set. Remote admin functions disabled<br />"
|
|
643 else: msg += " Enabled. Using password '"+pwd+"'<br />"
|
|
644 self.chat.SystemPost(msg)
|
|
645 return
|
|
646
|
|
647 if pass_state != 1 and args[0] != "set":
|
|
648 #no commands under this point will execute unless an admin password has been previously set
|
|
649 self.chat.SystemPost("Command ignored. No remote administrator password set!!")
|
|
650 return
|
|
651 msgbase = "<admin id='"+self.session.id+"' group_id='"+self.session.group_id+"' pwd='"+pwd+"'"
|
|
652 if args[0] == "set":
|
|
653 if len( args ) > 1:
|
|
654 self.session.orpgFrame_callback.password_manager.server = str( args[1] )
|
|
655 self.chat.SystemPost( "Remote administration commands using password: "+str(self.session.orpgFrame_callback.password_manager.GetSilentPassword("server"))+"" )
|
|
656 else:
|
|
657 pwd = self.session.orpgFrame_callback.password_manager.GetPassword("server")
|
|
658 if pwd != None:
|
|
659 self.chat.SystemPost( "Remote administration commands using password: "+pwd+"" )
|
|
660 elif len(args) == 1:
|
|
661 admin_command = {'banlist': ' cmd="banlist" />',
|
|
662 'help': " cmd='help' />",
|
|
663 'roompasswords': " cmd='roompasswords' />",
|
|
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:
|
135
|
684 admin_command = {'message':" cmd='message' to_id='"+ str(args[1])+"' msg='"+ string.join(args[2:])+"' />",
|
156
|
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)
|
|
691
|
|
692 elif args[0] == "banip":
|
|
693 #Ban a player from the server
|
|
694 try: bname = str(args[2])
|
|
695 except: bname = 'Unknown'
|
|
696 msg = msgbase + ' cmd="banip" bip="' + str(args[1]) + '" bname="' + bname + '"/>'
|
|
697 self.session.outbox.put(msg)
|
|
698
|
|
699 elif args[0] == "createroom":
|
|
700 #request creation of a (temporary) persistant room
|
|
701 if len(args) < 2:
|
|
702 self.chat.SystemPost( "You must supply a name and boot password at least. <br />/admin createroom <name> <boot password> [password]" )
|
|
703 return
|
|
704 if len(args) < 3:
|
|
705 self.chat.SystemPost( "You must supply a boot password also.<br />/admin createroom <name> <boot password> [password]" )
|
|
706 return
|
|
707 if len(args) < 4: args.append("")
|
|
708 msg = msgbase + " cmd='createroom' name='"+str(args[1])+"' boot='"+ str(args[2])+"' pass='"+ str(args[3])+"' />"
|
|
709 self.session.outbox.put(msg)
|
|
710
|
|
711 else: self.chat.InfoPost("Unknown administrator command" )
|
|
712 #command_function = {'banip': self.admin.r_admin_banip, 'createroom': self.r_admin_createroom,}
|
|
713 except:
|
|
714 self.chat.InfoPost("An error has occured while processing a Remote Administrator command!")
|
|
715 traceback.print_exc()
|