[Lyntin-cvs] CVS: lyntinng/modules action.py,1.27,1.28 substitute.py,1.22,1.23
Brought to you by:
glasssnake,
willhelm
From: will g. <wil...@us...> - 2003-03-28 21:26:12
|
Update of /cvsroot/lyntin/lyntinng/modules In directory sc8-pr-cvs1:/tmp/cvs-serv29282/modules Modified Files: action.py substitute.py Log Message: Fixed substitutes.py so that #write will write out antisubstitutes (before it would kick up an exception). Added action priority. Index: action.py =================================================================== RCS file: /cvsroot/lyntin/lyntinng/modules/action.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** action.py 19 Mar 2003 23:49:24 -0000 1.27 --- action.py 28 Mar 2003 21:26:07 -0000 1.28 *************** *** 19,23 **** 1. the trigger statement 2. the response statement ! 3. whether or not the action is a onetime action We also store a compiled regular expression of the trigger which --- 19,24 ---- 1. the trigger statement 2. the response statement ! 3. the priority of the action ! 4. whether or not the action is a onetime action We also store a compiled regular expression of the trigger which *************** *** 40,44 **** self._ses = ses ! def addAction(self, trigger, response, onetime=0): """ Compiles a trigger pattern and adds the entire action to the --- 41,45 ---- self._ses = ses ! def addAction(self, trigger, response, priority=5, onetime=0): """ Compiles a trigger pattern and adds the entire action to the *************** *** 51,54 **** --- 52,60 ---- @type response: string + @param priority: the priority to run this action at. actions + are sorted by priority then by the trigger statement when + we go to check for triggered actions. default is 5 + @type priority: int + @param onetime: if the trigger is found, should this action then get removed after the response is executed *************** *** 66,70 **** compiled = utils.compile_regexp(expansion, 1) ! self._actions[trigger] = (trigger, compiled, response, onetime) return 1 --- 72,76 ---- compiled = utils.compile_regexp(expansion, 1) ! self._actions[trigger] = (trigger, compiled, response, priority, onetime) return 1 *************** *** 75,79 **** """ for mem in self._actions.keys(): ! (trigger, compiled, response, onetime) = self._actions[mem] expansion = exported.expand_ses_vars(trigger, self._ses) if not expansion: --- 81,85 ---- """ for mem in self._actions.keys(): ! (trigger, compiled, response, priority, onetime) = self._actions[mem] expansion = exported.expand_ses_vars(trigger, self._ses) if not expansion: *************** *** 81,85 **** compiled = utils.compile_regexp(expansion, 1) ! self._actions[trigger] = (trigger, compiled, response, onetime) def clear(self): --- 87,91 ---- compiled = utils.compile_regexp(expansion, 1) ! self._actions[trigger] = (trigger, compiled, response, priority, onetime) def clear(self): *************** *** 136,142 **** matched = [] # go through all the lines in the data and see if we have # any matches ! for (action, actioncompiled, response, onetime) in self._actions.values(): line = utils.filter_cm(ansi.filter_ansi(text)) match = actioncompiled.search(line) --- 142,151 ---- matched = [] + actionlist = self._actions.values() + actionlist.sort(lambda x,y:cmp(x[3], y[3])) + # go through all the lines in the data and see if we have # any matches ! for (action, actioncompiled, response, priority, onetime) in actionlist: line = utils.filter_cm(ansi.filter_ansi(text)) match = actioncompiled.search(line) *************** *** 209,215 **** actup = self._actions[mem] ! data.append("%saction {%s} {%s} onetime={%s}" % (lyntin.commandchar, utils.escape(mem), ! utils.escape(actup[2]), actup[3])) return string.join(data, "\n") --- 218,224 ---- actup = self._actions[mem] ! data.append("%saction {%s} {%s} priority={%d} onetime={%s}" % (lyntin.commandchar, utils.escape(mem), ! utils.escape(actup[2]), actup[3], actup[4])) return string.join(data, "\n") *************** *** 229,236 **** self._actions = {} ! def addAction(self, ses, trigger, response, onetime=0): if not self._actions.has_key(ses): self._actions[ses] = ActionData(ses) ! return self._actions[ses].addAction(trigger, response, onetime) def clear(self, ses): --- 238,245 ---- self._actions = {} ! def addAction(self, ses, trigger, response, priority, onetime=0): if not self._actions.has_key(ses): self._actions[ses] = ActionData(ses) ! return self._actions[ses].addAction(trigger, response, priority, onetime) def clear(self, ses): *************** *** 262,266 **** acdata = self._actions[basesession]._actions for mem in acdata.keys(): ! self.addAction(newsession, mem, acdata[mem][2], acdata[mem][3]) def removeSession(self, ses): --- 271,275 ---- acdata = self._actions[basesession]._actions for mem in acdata.keys(): ! self.addAction(newsession, mem, acdata[mem][2], acdata[mem][3], acdata[mem][4]) def removeSession(self, ses): *************** *** 398,401 **** --- 407,411 ---- trigger = args["trigger"] action = args["action"] + priority = args["priority"] onetime = args["onetime"] quiet = args["quiet"] *************** *** 422,432 **** try: ! am.addAction(ses, trigger, action, onetime) if not quiet: ! exported.write_message("action: {%s} {%s} added." % (trigger, action), ses) except: exported.write_traceback("action: exception thrown.", ses) ! commands_dict["action"] = (action_cmd, "trigger= action= onetime:boolean=false quiet:boolean=false") def unaction_cmd(ses, args, input): --- 432,442 ---- try: ! am.addAction(ses, trigger, action, priority, onetime) if not quiet: ! exported.write_message("action: {%s} {%s} {%d} added." % (trigger, action, priority), ses) except: exported.write_traceback("action: exception thrown.", ses) ! commands_dict["action"] = (action_cmd, "trigger= action= priority:int=5 onetime:boolean=false quiet:boolean=false") def unaction_cmd(ses, args, input): Index: substitute.py =================================================================== RCS file: /cvsroot/lyntin/lyntinng/modules/substitute.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** substitute.py 28 Mar 2003 00:06:47 -0000 1.22 --- substitute.py 28 Mar 2003 21:26:08 -0000 1.23 *************** *** 251,254 **** --- 251,259 ---- return "" + def getAntiSubstitutesInfo(self, ses, text=''): + if self._subs.has_key(ses): + return self._subs[ses].getAntiSubstitutesInfo(text) + return "" + def getStatus(self, ses): if self._subs.has_key(ses): |