mirror of
https://github.com/Nick80835/microbot
synced 2025-09-04 16:35:35 +00:00
add support for pattern_extra in inline commands
This commit is contained in:
@@ -36,6 +36,7 @@ class InlinePhotoCommand:
|
|||||||
self.function = func
|
self.function = func
|
||||||
|
|
||||||
self.pattern = args.get("pattern")
|
self.pattern = args.get("pattern")
|
||||||
|
self.pattern_extra = args.get("pattern_extra", "")
|
||||||
self.default = args.get("default", None)
|
self.default = args.get("default", None)
|
||||||
|
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ class InlineArticleCommand:
|
|||||||
self.function = func
|
self.function = func
|
||||||
|
|
||||||
self.pattern = args.get("pattern")
|
self.pattern = args.get("pattern")
|
||||||
|
self.pattern_extra = args.get("pattern_extra", "")
|
||||||
self.default = args.get("default", None)
|
self.default = args.get("default", None)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ class CommandHandler():
|
|||||||
|
|
||||||
async def handle_inline(self, event):
|
async def handle_inline(self, event):
|
||||||
for command in self.inline_photo_commands:
|
for command in self.inline_photo_commands:
|
||||||
pattern_match = search(self.inline_pattern_template.format(command.pattern), event.text)
|
pattern_match = search(self.inline_pattern_template.format(command.pattern + command.pattern_extra), event.text)
|
||||||
|
|
||||||
if pattern_match:
|
if pattern_match:
|
||||||
if self.is_blacklisted(event, True):
|
if self.is_blacklisted(event, True):
|
||||||
@@ -72,7 +72,7 @@ class CommandHandler():
|
|||||||
return
|
return
|
||||||
|
|
||||||
for command in self.inline_article_commands:
|
for command in self.inline_article_commands:
|
||||||
pattern_match = search(self.inline_pattern_template.format(command.pattern), event.text)
|
pattern_match = search(self.inline_pattern_template.format(command.pattern + command.pattern_extra), event.text)
|
||||||
|
|
||||||
if pattern_match:
|
if pattern_match:
|
||||||
if self.is_blacklisted(event, True):
|
if self.is_blacklisted(event, True):
|
||||||
@@ -122,7 +122,8 @@ class CommandHandler():
|
|||||||
builder = event.builder
|
builder = event.builder
|
||||||
event.pattern_match = pattern_match
|
event.pattern_match = pattern_match
|
||||||
event.args = pattern_match.groups()[-1]
|
event.args = pattern_match.groups()[-1]
|
||||||
event.other_args = pattern_match.groups()[:-1]
|
event.other_args = pattern_match.groups()[1:-1]
|
||||||
|
event.command = pattern_match.groups()[0]
|
||||||
event.object = command
|
event.object = command
|
||||||
|
|
||||||
result_list = await command.function(event)
|
result_list = await command.function(event)
|
||||||
|
Reference in New Issue
Block a user