1
0
Fork 0

Fix conditions to validate a hook

This commit is contained in:
Némunaire 2013-01-01 16:13:58 +01:00
parent 01e12970fb
commit 3aa705dfb6
2 changed files with 5 additions and 3 deletions

View File

@ -16,6 +16,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
from response import Response
class MessagesHook:
@ -181,8 +183,8 @@ class Hook:
return (channel is None or len(self.channels) <= 0 or
channel in self.channels) and (server is None or
self.server is None or self.server == server) and (
(self.name is None or strcmp == self.name) or (
self.end is None or strcmp == self.end) or (
(self.name is None or strcmp == self.name) and (
self.end is None or strcmp == self.end) and (
self.regexp is None or re.match(self.regexp, strcmp)))
def run(self, msg, data2=None, strcmp=None):

View File

@ -13,7 +13,7 @@ def load(context):
add_event(ModuleEvent(intervalle=0, offset=d.total_seconds(), call=bonneannee))
from hooks import Hook
add_hook("cmd_rgxp", Hook(cmd_timetoyear, data=yrn, regexp="[0-9]{4}"))
add_hook("cmd_rgxp", Hook(cmd_timetoyear, data=yrn, regexp="^[0-9]{4}$"))
add_hook("cmd_hook", Hook(cmd_newyear, str(yrn), yrn))
add_hook("cmd_hook", Hook(cmd_newyear, "ny", yrn))
add_hook("cmd_hook", Hook(cmd_newyear, "newyear", yrn))