annotate orpg/chat/commands.py @ 183:0d9b746b5751 beta

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