From: <ch...@us...> - 2009-05-02 15:19:39
|
Revision: 297 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=297&view=rev Author: chozone Date: 2009-05-02 15:19:34 +0000 (Sat, 02 May 2009) Log Message: ----------- Made some basic commands for the input (like //exit). And now, the auto chat status thing works (like when you say 'brb', it will change your status to away). Modified Paths: -------------- trunk/VP/TODO trunk/VP/VP.py trunk/VP/lang/en.lang trunk/VP/lang/nl.lang trunk/VP/modules/input.py trunk/VP/modules/settings.py Modified: trunk/VP/TODO =================================================================== --- trunk/VP/TODO 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/TODO 2009-05-02 15:19:34 UTC (rev 297) @@ -17,10 +17,6 @@ Info(bar) * Creating the Info bar with information like: Current ground, user(?), money... - - Input -* Making special commands in chat -* Making that 'auto chat status' thingy (when you say something like 'brb', it will change your status to 'away') Menu * Creating checkitems (assigned to BlueWolf_) Modified: trunk/VP/VP.py =================================================================== --- trunk/VP/VP.py 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/VP.py 2009-05-02 15:19:34 UTC (rev 297) @@ -45,9 +45,9 @@ #chat auto-states if not 'chat' in conf: conf['chat'] = {} - conf['chat']['auto_states_enabled'] = conf['chat'].get('auto_states_enabled','False') #Later this True? + conf['chat']['auto_states_enabled'] = conf['chat'].get('auto_states_enabled','True') conf['chat']['auto_states_online'] = conf['chat'].get('auto_states_online','(b|back)\Z') - conf['chat']['auto_states_busy'] = conf['chat'].get('auto_states_busy','(phone|dnd)((\W.*)\Z|\Z)') + conf['chat']['auto_states_busy'] = conf['chat'].get('auto_states_busy','(dnd)((\W.*)\Z|\Z)') conf['chat']['auto_states_away'] = conf['chat'].get('auto_states_away','(brb|afk)((\W.*)\Z|\Z)') #animations @@ -72,7 +72,6 @@ #Without timeout, the Queue will not respond to KeyboardInterrupts. #This is a timeout of year. Think that will be enough :-) resp = share['response'].get(True, 31536000) - print resp if resp[0] == 'Exit': pygame.event.post(pygame.event.Event(QUIT)) Modified: trunk/VP/lang/en.lang =================================================================== --- trunk/VP/lang/en.lang 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/lang/en.lang 2009-05-02 15:19:34 UTC (rev 297) @@ -50,7 +50,7 @@ [[autostatechangedefault]] online = (b|back)\Z -busy = (phone|dnd)((\W.*)\Z|\Z) +busy = (dnd)((\W.*)\Z|\Z) away = (brb|afk)((\W.*)\Z|\Z) Modified: trunk/VP/lang/nl.lang =================================================================== --- trunk/VP/lang/nl.lang 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/lang/nl.lang 2009-05-02 15:19:34 UTC (rev 297) @@ -50,7 +50,7 @@ [[autostatechangedefault]] online = (b|back|biw)\Z -busy = (phone|dnd)((\W.*)\Z|\Z) +busy = (dnd)((\W.*)\Z|\Z) away = (brb|afk|bzt)((\W.*)\Z|\Z) Modified: trunk/VP/modules/input.py =================================================================== --- trunk/VP/modules/input.py 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/modules/input.py 2009-05-02 15:19:34 UTC (rev 297) @@ -1,5 +1,5 @@ from functions import * -import time +import time, re class Module(): def __init__(self, share, *arg): @@ -39,9 +39,8 @@ else: #Just an enter if self.inputText != '': - if self.inputText == '//exit': - self.sh['response'].put(('Exit',)) - else: + textToSend=self.checkChat() + if textToSend: text = self.inputText.encode('utf-8') text = text.strip() self.sh['Brains'].chatSend(text) @@ -141,3 +140,51 @@ interface.update([179,471,370,29]) + + + def checkChat(self): + """ + Handles all commands that are in the chat. + Is called when user presses the enter key in the Input. + The message that will be send to the server is what this function returns. + """ + t=self.inputText + c=t[2:] if len(t)>=2 and t.startswith('//') else '' + + if c == 'exit' or c == 'quit': + self.sh['response'].put(('Exit',)) + elif c == 'time' or c == 'date' or c == 'datetime': + return time.ctime() + elif c.startswith('stat ') or c.startswith('status '): + t=t.replace('//status ', '') + t=t.replace('//stat ', '') + if t == 'online' or t == 'busy' or t == 'away': + user=self.sh['conf']['account']['user'] + curStatus=self.sh['users'][user]['State'] + + if t != curStatus: + self.sh['Brains'].setStatus(t) + else: + return self.inputText + elif c == 'online' or c == 'busy' or c == 'away': + user=self.sh['conf']['account']['user'] + curStatus=self.sh['users'][user]['State'] + if c != curStatus: + self.sh['Brains'].setStatus(c) + else: + #Maybe... it is part of that stupid auto chat status thingy? + conf=self.sh['conf']['chat'] + print conf + if conf['auto_states_enabled']=='True': + user=self.sh['conf']['account']['user'] + curStatus=self.sh['users'][user]['State'] + + stat=None + if re.match(conf['auto_states_online'], t): stat='online' + if re.match(conf['auto_states_busy'], t): stat='busy' + if re.match(conf['auto_states_away'], t): stat='away' + + if stat and stat != curStatus: + self.sh['Brains'].setStatus(stat) + + return self.inputText Modified: trunk/VP/modules/settings.py =================================================================== --- trunk/VP/modules/settings.py 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/modules/settings.py 2009-05-02 15:19:34 UTC (rev 297) @@ -117,8 +117,7 @@ gui.Label(position = (15,80), parent = self.tab_misc, text = self.lang('misc','autochangestatus'))#section caption #DISABLED self.as_time=gui.CheckBox(position = self.tab_misc.nextPosition(5), parent = self.tab_misc, text = self.lang('misc','afterxmin'), value=conf['misc']['time_after_idle'],enabled=False) - #DISABLED - self.as_chat=gui.CheckBox(position = self.tab_misc.nextPosition(2), parent = self.tab_misc, text = self.lang('misc','chat'), value=conf['chat']['auto_states_enabled'],enabled=False) + self.as_chat=gui.CheckBox(position = self.tab_misc.nextPosition(2), parent = self.tab_misc, text = self.lang('misc','chat'), value=conf['chat']['auto_states_enabled']) #Create a special font style for our button labelStyleCopy = gui.defaultLabelStyle.copy() @@ -280,12 +279,6 @@ when the user click the 'reset chat states' button. Updates all images""" - #standard regexes - #now in lang files - #sonline="(b|back)\Z" - #sbusy="(phone|dnd)((\W.*)\Z|\Z)" - #saway="(brb|afk)((\W.*)\Z|\Z)" - #save in the local dict conf = self.sh['conf'] conf['chat']['auto_states_online'] = self.lang('autostatechangedefault','online') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |