Fix conditions to validate a hook
This commit is contained in:
parent
01e12970fb
commit
3aa705dfb6
6
hooks.py
6
hooks.py
@ -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):
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user