Mercurial > traipse_dev
comparison orpg/chat/commands.py @ 195:b633f4c64aae alpha
Traipse Alpha 'OpenRPG' {100219-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 (Patch-2)
New Features:
New Namespace method with two new syntaxes
Fixes:
Fix to Server GUI startup errors
Fix to Server GUI Rooms tab updating
Fix to Chat and Settings if non existant die roller is picked
Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated
Fix to Alias Lib's Export to Tree, Open, Save features
Fix to alias node, now works properly
Fix to Splitter node, minor GUI cleanup
author | sirebral |
---|---|
date | Sat, 24 Apr 2010 08:37:20 -0500 |
parents | bf799efe7a8a |
children | 50af54dbd6a6 |
comparison
equal
deleted
inserted
replaced
182:4b2884f29a72 | 195:b633f4c64aae |
---|---|
5 # docmd(self,text) | 5 # docmd(self,text) |
6 # on_help(self) | 6 # on_help(self) |
7 # on_whisper(self,text) | 7 # on_whisper(self,text) |
8 # | 8 # |
9 | 9 |
10 | |
11 import string, time | 10 import string, time |
12 import orpg.orpg_version | 11 import orpg.orpg_version |
13 import orpg.orpg_windows | 12 import orpg.orpg_windows |
14 import traceback | 13 import traceback |
15 | 14 |
24 ## cmd_ext.py should NOT be included in the CVS or Actual Releases | 23 ## cmd_ext.py should NOT be included in the CVS or Actual Releases |
25 | 24 |
26 try: | 25 try: |
27 import cmd_ext | 26 import cmd_ext |
28 print "Importing Developer Extended Command Set" | 27 print "Importing Developer Extended Command Set" |
29 except: | 28 except: pass |
30 pass | |
31 ##---------------------------------------------------------------- | 29 ##---------------------------------------------------------------- |
32 | 30 |
33 ANTI_LOG_CHAR = '!' | 31 ANTI_LOG_CHAR = '!' |
34 | 32 |
35 class chat_commands: | 33 class chat_commands: |
36 | 34 |
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): | 35 def __init__(self,chat): |
43 self.post = chat.Post | 36 self.post = chat.Post |
44 self.colorize = chat.colorize | 37 self.colorize = chat.colorize |
45 self.session = chat.session | 38 self.session = chat.session |
46 #self.send = chat.session.send | |
47 self.settings = chat.settings | 39 self.settings = chat.settings |
48 self.chat = chat | 40 self.chat = chat |
49 self.cmdlist = {} | 41 self.cmdlist = {} |
50 self.shortcmdlist = {} | 42 self.shortcmdlist = {} |
51 self.defaultcmds() | 43 self.defaultcmds() |
52 self.defaultcmdalias() | 44 self.defaultcmdalias() |
53 # def __init__ - end | |
54 self.previous_whisper = [] | 45 self.previous_whisper = [] |
55 | 46 |
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): | 47 def addcommand(self, cmd, function, helpmsg): |
64 if not self.cmdlist.has_key(cmd) and not self.shortcmdlist.has_key(cmd): | 48 if not self.cmdlist.has_key(cmd) and not self.shortcmdlist.has_key(cmd): |
65 self.cmdlist[cmd] = {} | 49 self.cmdlist[cmd] = {} |
66 self.cmdlist[cmd]['function'] = function | 50 self.cmdlist[cmd]['function'] = function |
67 self.cmdlist[cmd]['help'] = helpmsg | 51 self.cmdlist[cmd]['help'] = helpmsg |
68 #print 'Command Added: ' + cmd | 52 |
69 | |
70 | |
71 def addshortcmd(self, shortcmd, longcmd): | 53 def addshortcmd(self, shortcmd, longcmd): |
72 if not self.shortcmdlist.has_key(shortcmd) and not self.cmdlist.has_key(shortcmd): | 54 if not self.shortcmdlist.has_key(shortcmd) and not self.cmdlist.has_key(shortcmd): |
73 self.shortcmdlist[shortcmd] = longcmd | 55 self.shortcmdlist[shortcmd] = longcmd |
74 | 56 |
75 | |
76 def removecmd(self, cmd): | 57 def removecmd(self, cmd): |
77 if self.cmdlist.has_key(cmd): | 58 if self.cmdlist.has_key(cmd): |
78 del self.cmdlist[cmd] | 59 del self.cmdlist[cmd] |
79 elif self.shortcmdlist.has_key(cmd): | 60 elif self.shortcmdlist.has_key(cmd): |
80 del self.shortcmdlist[cmd] | 61 del self.shortcmdlist[cmd] |
81 | 62 |
82 #print 'Command Removed: ' + cmd | |
83 | |
84 | |
85 | |
86 def defaultcmds(self): | 63 def defaultcmds(self): |
87 self.addcommand('/help', self.on_help, '- Displays this help message') | 64 self.addcommand('/help', self.on_help, '- Displays this help message') |
88 self.addcommand('/version', self.on_version, ' - Displays current version of OpenRPG.') | 65 self.addcommand('/version', self.on_version, ' - Displays current version of OpenRPG.') |
89 self.addcommand('/me', self.chat.emote_message, ' - Alias for **yourname does something.**') | 66 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.') | 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.') |
110 self.addcommand('/description', self.on_description, 'message - Creates a block of text, used for room descriptions and such') | 87 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.') | 88 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') | 89 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') | 90 self.addcommand('/advfilter', self.on_filter, 'This will toggle the Advanced Filter') |
114 | 91 |
115 | |
116 def defaultcmdalias(self): | 92 def defaultcmdalias(self): |
117 self.addshortcmd('/?', '/help') | 93 self.addshortcmd('/?', '/help') |
118 self.addshortcmd('/he', '/me') | 94 self.addshortcmd('/he', '/me') |
119 self.addshortcmd('/she', '/me') | 95 self.addshortcmd('/she', '/me') |
120 self.addshortcmd('/i', '/ignore') | 96 self.addshortcmd('/i', '/ignore') |
121 self.addshortcmd('/w', '/whisper') | 97 self.addshortcmd('/w', '/whisper') |
122 self.addshortcmd('/nick', '/name') | 98 self.addshortcmd('/nick', '/name') |
123 self.addshortcmd('/date', '/time') | 99 self.addshortcmd('/date', '/time') |
124 self.addshortcmd('/desc', '/description') | 100 self.addshortcmd('/desc', '/description') |
125 self.addshortcmd('/d', '/description') | 101 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') | 102 self.addshortcmd('/sleep', '/me falls asleep') |
129 | 103 |
130 | |
131 def docmd(self,text): | 104 def docmd(self,text): |
132 cmdsearch = string.split(text,None,1) | 105 cmdsearch = string.split(text,None,1) |
133 cmd = string.lower(cmdsearch[0]) | 106 cmd = string.lower(cmdsearch[0]) |
134 start = len(cmd) | 107 start = len(cmd) |
135 end = len(text) | 108 end = len(text) |
136 cmdargs = text[start+1:end] | 109 cmdargs = text[start+1:end] |
137 | |
138 if self.cmdlist.has_key(cmd): | 110 if self.cmdlist.has_key(cmd): |
139 self.cmdlist[cmd]['function'](cmdargs) | 111 self.cmdlist[cmd]['function'](cmdargs) |
140 elif self.shortcmdlist.has_key(cmd): | 112 elif self.shortcmdlist.has_key(cmd): |
141 self.docmd(self.shortcmdlist[cmd] + " " + cmdargs) | 113 self.docmd(self.shortcmdlist[cmd] + " " + cmdargs) |
142 else: | 114 else: |
143 msg = "Sorry I don't know what %s is!" % (cmd) | 115 msg = "Sorry I don't know what %s is!" % (cmd) |
144 self.chat.InfoPost(msg) | 116 self.chat.InfoPost(msg) |
145 | 117 |
146 | |
147 def on_filter(self, cmdargs): | 118 def on_filter(self, cmdargs): |
148 #print self.chat.advancedFilter | |
149 test = not self.chat.advancedFilter | 119 test = not self.chat.advancedFilter |
150 #print test | |
151 | |
152 for tab in self.chat.parent.whisper_tabs: | 120 for tab in self.chat.parent.whisper_tabs: |
153 tab.advancedFilter = not self.chat.advancedFilter | 121 tab.advancedFilter = not self.chat.advancedFilter |
154 | |
155 for tab in self.chat.parent.null_tabs: | 122 for tab in self.chat.parent.null_tabs: |
156 tab.advancedFilter = not self.chat.advancedFilter | 123 tab.advancedFilter = not self.chat.advancedFilter |
157 | |
158 for tab in self.chat.parent.group_tabs: | 124 for tab in self.chat.parent.group_tabs: |
159 tab.advancedFilter = not self.chat.advancedFilter | 125 tab.advancedFilter = not self.chat.advancedFilter |
160 | |
161 if self.chat.parent.GMChatPanel != None: | 126 if self.chat.parent.GMChatPanel != None: |
162 self.chat.parent.GMChatPanel.advancedFilter = not self.chat.advancedFilter | 127 self.chat.parent.GMChatPanel.advancedFilter = not self.chat.advancedFilter |
163 | |
164 self.chat.advancedFilter = not self.chat.advancedFilter | 128 self.chat.advancedFilter = not self.chat.advancedFilter |
165 | |
166 if self.chat.advancedFilter: | 129 if self.chat.advancedFilter: |
167 self.chat.InfoPost("Advanced Filtering has been turned On") | 130 self.chat.InfoPost("Advanced Filtering has been turned On") |
168 else: | 131 else: |
169 self.chat.InfoPost("Advanced Filtering has been turned Off") | 132 self.chat.InfoPost("Advanced Filtering has been turned Off") |
170 | 133 |
171 | |
172 def on_purge(self, cmdargs): | 134 def on_purge(self, cmdargs): |
173 self.chat.PurgeChat() | 135 self.chat.PurgeChat() |
174 self.chat.InfoPost('Chat Buffer has been Purged!') | 136 self.chat.InfoPost('Chat Buffer has been Purged!') |
175 | 137 |
176 | |
177 def on_sound(self, cmdargs): | 138 def on_sound(self, cmdargs): |
178 if len(cmdargs) < 8: | 139 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") | 140 self.chat.InfoPost("You must provide a URL for the file name, it does not work for just local sound files") |
180 return | 141 return |
181 args = string.split(cmdargs, None, -1) | 142 args = string.split(cmdargs, None, -1) |
184 snd = args[1].replace('&', '&') | 145 snd = args[1].replace('&', '&') |
185 loop = '1' | 146 loop = '1' |
186 else: | 147 else: |
187 snd = cmdargs.replace('&', '&') | 148 snd = cmdargs.replace('&', '&') |
188 loop = '' | 149 loop = '' |
189 | |
190 type = 'remote' | 150 type = 'remote' |
191 | |
192 (name, ip, id, text_status, version, protocol_version, client_string, role) = self.session.get_my_info() | 151 (name, ip, id, text_status, version, protocol_version, client_string, role) = self.session.get_my_info() |
193 group_id = self.session.group_id | 152 group_id = self.session.group_id |
194 if (role != 'Lurker' and group_id != '0') or self.session.get_status() != 1: | 153 if (role != 'Lurker' and group_id != '0') or self.session.get_status() != 1: |
195 try: | 154 try: |
196 self.chat.sound_player.play(snd, type, loop) | 155 self.chat.sound_player.play(snd, type, loop) |
205 elif group_id == '0': | 164 elif group_id == '0': |
206 self.chat.InfoPost("You cannot send sound files to the lobby!") | 165 self.chat.InfoPost("You cannot send sound files to the lobby!") |
207 else: | 166 else: |
208 self.chat.InfoPost("Something dun fuckered up Frank!") | 167 self.chat.InfoPost("Something dun fuckered up Frank!") |
209 | 168 |
210 | |
211 def on_version(self, cmdargs=""): | 169 def on_version(self, cmdargs=""): |
212 self.chat.InfoPost("Version is OpenRPG " + self.chat.version) | 170 self.chat.InfoPost("Version is OpenRPG " + self.chat.version) |
213 | 171 |
214 | |
215 def on_load(self, cmdargs): | 172 def on_load(self, cmdargs): |
216 args = string.split(cmdargs,None,-1) | 173 args = string.split(cmdargs,None,-1) |
217 try: | 174 try: |
218 self.settings.setup_ini(args[0]) | 175 self.settings.setup_ini(args[0]) |
219 self.settings.reload_settings(self.chat) | 176 self.settings.reload_settings(self.chat) |
220 self.chat.InfoPost("Settings Loaded from file " + args[0] ) | 177 self.chat.InfoPost("Settings Loaded from file " + args[0] ) |
221 except Exception,e: | 178 except Exception,e: |
222 print e | 179 print e |
223 self.chat.InfoPost("ERROR Loading settings") | 180 self.chat.InfoPost("ERROR Loading settings") |
224 | 181 |
225 | |
226 def on_font(self, cmdargs): | 182 def on_font(self, cmdargs): |
227 try: | 183 try: |
228 fontsettings = self.chat.set_default_font(fontname=cmdargs, fontsize=None) | 184 fontsettings = self.chat.set_default_font(fontname=cmdargs, fontsize=None) |
229 except: | 185 except: |
230 self.chat.InfoPost("ERROR setting default font") | 186 self.chat.InfoPost("ERROR setting default font") |
231 | 187 |
232 | |
233 def on_fontsize(self, cmdargs): | 188 def on_fontsize(self, cmdargs): |
234 args = string.split(cmdargs,None,-1) | 189 args = string.split(cmdargs,None,-1) |
235 try: | 190 try: |
236 fontsettings = self.chat.set_default_font(fontname=None, fontsize=int(args[0])) | 191 fontsettings = self.chat.set_default_font(fontname=None, fontsize=int(args[0])) |
237 except Exception, e: | 192 except Exception, e: |
238 print e | 193 print e |
239 self.chat.InfoPost("ERROR setting default font size") | 194 self.chat.InfoPost("ERROR setting default font size") |
240 | 195 |
241 | |
242 def on_close(self, cmdargs): | 196 def on_close(self, cmdargs): |
243 try: | 197 try: |
244 chatpanel = self.chat | 198 chatpanel = self.chat |
245 if (chatpanel.sendtarget == "all"): | 199 if (chatpanel.sendtarget == "all"): |
246 chatpanel.InfoPost("Error: cannot close public chat tab.") | 200 chatpanel.InfoPost("Error: cannot close public chat tab.") |
248 chatpanel.chat_timer.Stop() | 202 chatpanel.chat_timer.Stop() |
249 chatpanel.parent.onCloseTab(0) | 203 chatpanel.parent.onCloseTab(0) |
250 except: | 204 except: |
251 self.chat.InfoPost("Error: cannot close private chat tab.") | 205 self.chat.InfoPost("Error: cannot close private chat tab.") |
252 | 206 |
253 | |
254 def on_time(self, cmdargs): | 207 def on_time(self, cmdargs): |
255 local_time = time.localtime() | 208 local_time = time.localtime() |
256 gmt_time = time.gmtime() | 209 gmt_time = time.gmtime() |
257 format_string = "%A %b %d, %Y %I:%M:%S%p" | 210 format_string = "%A %b %d, %Y %I:%M:%S%p" |
258 self.chat.InfoPost("<br />Local: " + time.strftime(format_string)+\ | 211 self.chat.InfoPost("<br />Local: " + time.strftime(format_string)+\ |
259 "<br />GMT: "+time.strftime(format_string,gmt_time)) | 212 "<br />GMT: "+time.strftime(format_string,gmt_time)) |
260 | 213 |
261 | |
262 def on_dieroller(self, cmdargs): | 214 def on_dieroller(self, cmdargs): |
263 args = string.split(cmdargs,None,-1) | 215 args = string.split(cmdargs,None,-1) |
264 rm = component.get('DiceManager') | 216 rm = component.get('DiceManager') |
217 cur_die = rm.getRoller() | |
265 try: | 218 try: |
266 rm.setRoller(args[0]) | 219 rm.setRoller(args[0]) |
267 self.chat.SystemPost("You have changed your die roller to the <b>\"" + args[0] + "\"</b> roller.") | 220 self.chat.SystemPost('You have changed your die roller to the <b>"' +rm.getRoller()+ '"</b> roller.') |
268 self.settings.set_setting('dieroller',args[0]) | 221 self.settings.change('dieroller', rm.getRoller()) |
269 except Exception, e: | 222 except Exception, e: |
270 print e | 223 rm.setRoller(cur_die) |
271 self.chat.InfoPost("Available die rollers: " + str(rm.listRollers())) | 224 self.settings.change('dieroller', str(cur_die)) |
272 self.chat.InfoPost("You are using the <b>\"" + rm.getRoller() + "\"</b> die roller.") | 225 if args[0] != '': self.chat.SystemPost(args[0]+ ' is an invalid roller.') |
273 | 226 self.chat.InfoPost('Available die rollers: ' +str(rm.listRollers()) ) |
274 | 227 self.chat.InfoPost('You are using the <b>"' +cur_die+ '"</b> die roller.') |
228 | |
275 def on_ping(self, cmdargs): | 229 def on_ping(self, cmdargs): |
276 ct = time.clock() | 230 ct = time.clock() |
277 msg = "<ping player='"+self.session.id+"' time='"+str(ct)+"' />" | 231 msg = "<ping player='"+self.session.id+"' time='"+str(ct)+"' />" |
278 self.session.outbox.put(msg) | 232 self.session.outbox.put(msg) |
279 | 233 |
280 | |
281 def on_log(self,cmdargs): | 234 def on_log(self,cmdargs): |
282 args = string.split(cmdargs,None,-1) | 235 args = string.split(cmdargs,None,-1) |
283 logfile = self.settings.get_setting( 'GameLogPrefix' ) | 236 logfile = self.settings.get_setting( 'GameLogPrefix' ) |
284 | |
285 if len( args ) == 0: | 237 if len( args ) == 0: |
286 self.postLoggingState() | 238 self.postLoggingState() |
287 elif args[0] == "on" and logfile != '': | 239 elif args[0] == "on" and logfile != '': |
288 try: | 240 try: |
289 while logfile[ 0 ] == ANTI_LOG_CHAR: | 241 while logfile[ 0 ] == ANTI_LOG_CHAR: |
307 self.chat.SystemPost('You must also specify a filename with the <em>/log to</em> command.' ) | 259 self.chat.SystemPost('You must also specify a filename with the <em>/log to</em> command.' ) |
308 self.postLoggingState() | 260 self.postLoggingState() |
309 else: | 261 else: |
310 self.chat.InfoPost("Unknown logging command, use 'on' or 'off'" ) | 262 self.chat.InfoPost("Unknown logging command, use 'on' or 'off'" ) |
311 | 263 |
312 | |
313 def postLoggingState( self ): | 264 def postLoggingState( self ): |
314 logfile = self.settings.get_setting( 'GameLogPrefix' ) | 265 logfile = self.settings.get_setting( 'GameLogPrefix' ) |
315 try: | 266 try: |
316 if logfile[0] != ANTI_LOG_CHAR: comment = 'is' | 267 if logfile[0] != ANTI_LOG_CHAR: comment = 'is' |
317 else: comment = 'is not' | 268 else: comment = 'is not' |
318 except: comment = 'is not' | 269 except: comment = 'is not' |
319 suffix = time.strftime( '-%d-%m-%y.html', time.localtime( time.time() ) ) | 270 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) ) | 271 self.chat.InfoPost('Log filename is "%s%s", system is %s logging.' % (logfile, suffix, comment) ) |
321 | 272 |
322 # This subroutine will set the players netork status. | |
323 # | |
324 #!self : instance of self | |
325 | |
326 | |
327 def on_name(self, cmdargs): | 273 def on_name(self, cmdargs): |
328 #only 20 chars no more! :) | |
329 if cmdargs == "": | 274 if cmdargs == "": |
330 self.chat.InfoPost("**Incorrect syntax for name.") | 275 self.chat.InfoPost("**Incorrect syntax for name.") |
331 else: | 276 else: |
332 #txt = txt[:50] | |
333 self.settings.set_setting('player', cmdargs) | 277 self.settings.set_setting('player', cmdargs) |
334 self.session.set_name(str(cmdargs)) | 278 self.session.set_name(str(cmdargs)) |
335 | 279 |
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): | 280 def on_status(self, cmdargs): |
342 if cmdargs == "": | 281 if cmdargs == "": |
343 self.chat.InfoPost("Incorrect synatx for status.") | 282 self.chat.InfoPost("Incorrect synatx for status.") |
344 else: | 283 else: |
345 #only 20 chars no more! :) | |
346 txt = cmdargs[:20] | 284 txt = cmdargs[:20] |
347 self.session.set_text_status(str(txt)) | 285 self.session.set_text_status(str(txt)) |
348 # def on_status - end | 286 |
349 | |
350 | |
351 def on_set(self, cmdargs): | 287 def on_set(self, cmdargs): |
352 args = string.split(cmdargs,None,-1) | 288 args = string.split(cmdargs,None,-1) |
353 keys = self.settings.get_setting_keys() | 289 keys = self.settings.get_setting_keys() |
354 #print keys | |
355 if len(args) == 0: | 290 if len(args) == 0: |
356 line = "<table border='2'>" | 291 line = "<table border='2'>" |
357 for m in keys: | 292 for m in keys: |
358 line += "<tr><td>" + str(m) + "</td><td> " + str(self.settings.get_setting(m)) + "</td></tr>" | 293 line += "<tr><td>" + str(m) + "</td><td> " + str(self.settings.get_setting(m)) + "</td></tr>" |
359 line += "</table>" | 294 line += "</table>" |
376 self.chat.InfoPost(return_string) | 311 self.chat.InfoPost(return_string) |
377 self.session.set_name(self.settings.get_setting("player")) | 312 self.session.set_name(self.settings.get_setting("player")) |
378 self.chat.set_colors() | 313 self.chat.set_colors() |
379 self.chat.set_buffersize() | 314 self.chat.set_buffersize() |
380 | 315 |
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=""): | 316 def on_help(self, cmdargs=""): |
387 cmds = self.cmdlist.keys() | 317 cmds = self.cmdlist.keys() |
388 cmds.sort() | 318 cmds.sort() |
389 shortcmds = self.shortcmdlist.keys() | 319 shortcmds = self.shortcmdlist.keys() |
390 shortcmds.sort() | 320 shortcmds.sort() |
398 if self.shortcmdlist[shortcmd] == cmd: | 328 if self.shortcmdlist[shortcmd] == cmd: |
399 msg += ', <b><font color="#0000CC">%s</font></b>' % (shortcmd) | 329 msg += ', <b><font color="#0000CC">%s</font></b>' % (shortcmd) |
400 msg += ' %s' % (self.cmdlist[cmd]['help']) | 330 msg += ' %s' % (self.cmdlist[cmd]['help']) |
401 self.chat.InfoPost(msg) | 331 self.chat.InfoPost(msg) |
402 | 332 |
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): | 333 def on_ignore(self, cmdargs): |
409 args = string.split(cmdargs,None,-1) | 334 args = string.split(cmdargs,None,-1) |
410 (ignore_list, ignore_name) = self.session.get_ignore_list() | 335 (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 />") | 336 ignore_output = self.colorize(self.chat.syscolor,"<br /><u>Player IDs Currently being Ignored:</u><br />") |
412 if cmdargs == "": | 337 if cmdargs == "": |
429 self.chat.InfoPost("Player " + name + " with ID:" + id + " now being ignored") | 354 self.chat.InfoPost("Player " + name + " with ID:" + id + " now being ignored") |
430 except: | 355 except: |
431 self.chat.InfoPost(m + " was ignored because it is an invalid player ID") | 356 self.chat.InfoPost(m + " was ignored because it is an invalid player ID") |
432 traceback.print_exc() | 357 traceback.print_exc() |
433 | 358 |
434 | |
435 def on_role(self, cmdargs): | 359 def on_role(self, cmdargs): |
436 if cmdargs == "": | 360 if cmdargs == "": |
437 self.session.display_roles() | 361 self.session.display_roles() |
438 return | 362 return |
439 delim = cmdargs.find("=") | 363 delim = cmdargs.find("=") |
451 role_pwd = self.session.orpgFrame_callback.password_manager.GetPassword("admin",int(self.session.group_id)) | 375 role_pwd = self.session.orpgFrame_callback.password_manager.GetPassword("admin",int(self.session.group_id)) |
452 if role_pwd != None: | 376 if role_pwd != None: |
453 for m in player_ids: | 377 for m in player_ids: |
454 self.session.set_role(m.strip(),role,role_pwd) | 378 self.session.set_role(m.strip(),role,role_pwd) |
455 except: traceback.print_exc() | 379 except: traceback.print_exc() |
456 # return | 380 |
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): | 381 def on_whisper(self, cmdargs): |
467 delim = cmdargs.find("=") | 382 delim = cmdargs.find("=") |
468 | 383 |
469 if delim < 0: | 384 if delim < 0: |
470 if self.previous_whisper: player_ids = self.previous_whisper | 385 if self.previous_whisper: player_ids = self.previous_whisper |
474 else: player_ids = string.split(cmdargs[:delim], ",") | 389 else: player_ids = string.split(cmdargs[:delim], ",") |
475 self.previous_whisper = player_ids | 390 self.previous_whisper = player_ids |
476 mesg = string.strip(cmdargs[delim+1:]) | 391 mesg = string.strip(cmdargs[delim+1:]) |
477 self.chat.whisper_to_players(mesg,player_ids) | 392 self.chat.whisper_to_players(mesg,player_ids) |
478 | 393 |
479 #--------------------------------------------------------- | |
480 # [START] Digitalxero Multi Whisper Group 1/1/05 | |
481 #--------------------------------------------------------- | |
482 | |
483 def on_groupwhisper(self, cmdargs): | 394 def on_groupwhisper(self, cmdargs): |
484 args = string.split(cmdargs,None,-1) | 395 args = string.split(cmdargs,None,-1) |
485 delim = cmdargs.find("=") | 396 delim = cmdargs.find("=") |
486 | 397 |
487 if delim > 0: group_ids = string.split(cmdargs[:delim], ",") | 398 if delim > 0: group_ids = string.split(cmdargs[:delim], ",") |
531 for n in orpg.player_list.WG_LIST[gid]: | 442 for n in orpg.player_list.WG_LIST[gid]: |
532 if idList == "": idList = str(n) | 443 if idList == "": idList = str(n) |
533 else: idList = str(n) + ", " + idList | 444 else: idList = str(n) + ", " + idList |
534 self.on_whisper(idList + "=" + self.settings.get_setting("gwtext") + msg) | 445 self.on_whisper(idList + "=" + self.settings.get_setting("gwtext") + msg) |
535 | 446 |
536 #--------------------------------------------------------- | |
537 # [END] Digitalxero Multi Whisper Group 1/1/05 | |
538 #--------------------------------------------------------- | |
539 | |
540 | |
541 def on_gmwhisper(self, cmdargs): | 447 def on_gmwhisper(self, cmdargs): |
542 if cmdargs == "": | 448 if cmdargs == "": |
543 self.chat.InfoPost("**Incorrect syntax for GM Whisper.") | 449 self.chat.InfoPost("**Incorrect syntax for GM Whisper.") |
544 else: | 450 else: |
545 the_gms = self.chat.get_gms() | 451 the_gms = self.chat.get_gms() |
549 if gmstring != "": gmstring += "," | 455 if gmstring != "": gmstring += "," |
550 gmstring += each_gm | 456 gmstring += each_gm |
551 self.on_whisper(gmstring + "=" + cmdargs) | 457 self.on_whisper(gmstring + "=" + cmdargs) |
552 else: self.chat.InfoPost("**No GMs to Whisper to.") | 458 else: self.chat.InfoPost("**No GMs to Whisper to.") |
553 | 459 |
554 | |
555 def on_moderate(self, cmdargs): | 460 def on_moderate(self, cmdargs): |
556 if cmdargs != "": | 461 if cmdargs != "": |
557 pos = cmdargs.find("=") | 462 pos = cmdargs.find("=") |
558 if (pos < 0): | 463 if (pos < 0): |
559 plist = "" | 464 plist = "" |
582 else: | 487 else: |
583 msg = "<moderate action='list' from='"+self.session.id+"' />" | 488 msg = "<moderate action='list' from='"+self.session.id+"' />" |
584 self.session.outbox.put(msg) | 489 self.session.outbox.put(msg) |
585 self.session.update() | 490 self.session.update() |
586 | 491 |
587 | |
588 def on_update(self, cmdargs): | 492 def on_update(self, cmdargs): |
589 self.chat.InfoPost("This command is no longer valid") | 493 self.chat.InfoPost("This command is no longer valid") |
590 | 494 |
591 | |
592 def on_description(self, cmdargs): | 495 def on_description(self, cmdargs): |
593 if len(cmdargs) <= 0: | 496 if len(cmdargs) <= 0: |
594 self.chat.InfoPost("**No description text to display." + str(delim)) | 497 self.chat.InfoPost("**No description text to display." + str(delim)) |
595 return | 498 return |
596 mesg = "<table bgcolor='#c0c0c0' border='3' cellpadding='5' cellspacing='0' width='100%'><tr><td><font color='#000000'>" | 499 mesg = "<table bgcolor='#c0c0c0' border='3' cellpadding='5' cellspacing='0' width='100%'><tr><td><font color='#000000'>" |
597 mesg += string.strip(cmdargs) | 500 mesg += string.strip(cmdargs) |
598 mesg += "</font></td></tr></table>" | 501 mesg += "</font></td></tr></table>" |
599 self.chat.Post(mesg) | 502 self.chat.Post(mesg) |
600 self.chat.send_chat_message(mesg) | 503 self.chat.send_chat_message(mesg) |
601 | 504 |
602 | |
603 def invoke_tab(self, cmdargs): | 505 def invoke_tab(self, cmdargs): |
604 ######START mDuo13's Tab Initiator######## | |
605 try: | 506 try: |
606 int(cmdargs) | 507 int(cmdargs) |
607 playerid = cmdargs.strip() | 508 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: | 509 for panel in self.chat.parent.whisper_tabs: |
610 if (panel.sendtarget == playerid): | 510 if (panel.sendtarget == playerid): |
611 self.chat.Post("Cannot invoke tab: Tab already exists.") | 511 self.chat.Post("Cannot invoke tab: Tab already exists.") |
612 return | 512 return |
613 try: displaypanel = self.chat.parent.create_whisper_tab(playerid) | 513 try: displaypanel = self.chat.parent.create_whisper_tab(playerid) |
620 except: | 520 except: |
621 displaypanel = self.chat.parent.create_null_tab(cmdargs) | 521 displaypanel = self.chat.parent.create_null_tab(cmdargs) |
622 nidx = self.chat.parent.get_tab_index(displaypanel) | 522 nidx = self.chat.parent.get_tab_index(displaypanel) |
623 self.chat.parent.newMsg(nidx) | 523 self.chat.parent.newMsg(nidx) |
624 return | 524 return |
625 #######END mDuo13's Tab Initiator######### | 525 |
626 | |
627 | |
628 | |
629 def on_remote_admin(self, cmdargs): | 526 def on_remote_admin(self, cmdargs): |
630 args = string.split(cmdargs,None,-1) | 527 args = string.split(cmdargs,None,-1) |
631 #handles remote administration commands | |
632 try: | 528 try: |
633 pass_state = 0 | 529 pass_state = 0 |
634 pwd = self.session.orpgFrame_callback.password_manager.GetSilentPassword("server") | 530 pwd = self.session.orpgFrame_callback.password_manager.GetSilentPassword("server") |
635 if pwd != None: | 531 if pwd != None: |
636 pass_state = 1 | 532 pass_state = 1 |
637 else: pwd = "<i>[NONE]</i>" | 533 else: pwd = "<i>[NONE]</i>" |
638 | |
639 if len( args ) == 0: | 534 if len( args ) == 0: |
640 #raw command return state info | |
641 msg = "<br /><b>Remote Administrator Config:</b>" | 535 msg = "<br /><b>Remote Administrator Config:</b>" |
642 if pass_state != 1 : msg += " Password not set. Remote admin functions disabled<br />" | 536 if pass_state != 1 : msg += " Password not set. Remote admin functions disabled<br />" |
643 else: msg += " Enabled. Using password '"+pwd+"'<br />" | 537 else: msg += " Enabled. Using password '"+pwd+"'<br />" |
644 self.chat.SystemPost(msg) | 538 self.chat.SystemPost(msg) |
645 return | 539 return |
646 | |
647 if pass_state != 1 and args[0] != "set": | 540 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!!") | 541 self.chat.SystemPost("Command ignored. No remote administrator password set!!") |
650 return | 542 return |
651 msgbase = "<admin id='"+self.session.id+"' group_id='"+self.session.group_id+"' pwd='"+pwd+"'" | 543 msgbase = "<admin id='"+self.session.id+"' group_id='"+self.session.group_id+"' pwd='"+pwd+"'" |
652 if args[0] == "set": | 544 if args[0] == "set": |
653 if len( args ) > 1: | 545 if len( args ) > 1: |
688 if admin_command.has_key(args[0]): | 580 if admin_command.has_key(args[0]): |
689 msg = msgbase + admin_command[args[0]] | 581 msg = msgbase + admin_command[args[0]] |
690 self.session.outbox.put(msg) | 582 self.session.outbox.put(msg) |
691 | 583 |
692 elif args[0] == "banip": | 584 elif args[0] == "banip": |
693 #Ban a player from the server | |
694 try: bname = str(args[2]) | 585 try: bname = str(args[2]) |
695 except: bname = 'Unknown' | 586 except: bname = 'Unknown' |
696 msg = msgbase + ' cmd="banip" bip="' + str(args[1]) + '" bname="' + bname + '"/>' | 587 msg = msgbase + ' cmd="banip" bip="' + str(args[1]) + '" bname="' + bname + '"/>' |
697 self.session.outbox.put(msg) | 588 self.session.outbox.put(msg) |
698 | 589 |
699 elif args[0] == "createroom": | 590 elif args[0] == "createroom": |
700 #request creation of a (temporary) persistant room | |
701 if len(args) < 2: | 591 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]" ) | 592 self.chat.SystemPost( "You must supply a name and boot password at least. <br />/admin createroom <name> <boot password> [password]" ) |
703 return | 593 return |
704 if len(args) < 3: | 594 if len(args) < 3: |
705 self.chat.SystemPost( "You must supply a boot password also.<br />/admin createroom <name> <boot password> [password]" ) | 595 self.chat.SystemPost( "You must supply a boot password also.<br />/admin createroom <name> <boot password> [password]" ) |
707 if len(args) < 4: args.append("") | 597 if len(args) < 4: args.append("") |
708 msg = msgbase + " cmd='createroom' name='"+str(args[1])+"' boot='"+ str(args[2])+"' pass='"+ str(args[3])+"' />" | 598 msg = msgbase + " cmd='createroom' name='"+str(args[1])+"' boot='"+ str(args[2])+"' pass='"+ str(args[3])+"' />" |
709 self.session.outbox.put(msg) | 599 self.session.outbox.put(msg) |
710 | 600 |
711 else: self.chat.InfoPost("Unknown administrator command" ) | 601 else: self.chat.InfoPost("Unknown administrator command" ) |
712 #command_function = {'banip': self.admin.r_admin_banip, 'createroom': self.r_admin_createroom,} | |
713 except: | 602 except: |
714 self.chat.InfoPost("An error has occured while processing a Remote Administrator command!") | 603 self.chat.InfoPost("An error has occured while processing a Remote Administrator command!") |
715 traceback.print_exc() | 604 traceback.print_exc() |