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