Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup python 3.8
- name: Setup python 3.10.17
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.10.17
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
Expand All @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.x']
python-version: ['3.10.17']
steps:
- name: Checkout
uses: actions/checkout@v1
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup python 3.8
- name: Setup python 3.10.17
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.10.17
- name: Install virtualenv
run: pip install virtualenv
- name: Build docs
Expand All @@ -35,10 +35,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup python 3.8
- name: Setup python 3.10.17
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.10.17
- name: Add wheel dependency
run: pip install wheel
- name: Generate dist
Expand Down
14 changes: 9 additions & 5 deletions omnibot_receiver/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def handle_event(self, event):
]}
"""
omnibot_payload_type = event.get('omnibot_payload_type')
if self.message_router and omnibot_payload_type == 'message':
if (self.message_router and
omnibot_payload_type in {'message', 'reaction'}):
return self.message_router.handle_message(event)
elif (self.interactive_router and
omnibot_payload_type == 'interactive_component'):
Expand Down Expand Up @@ -258,7 +259,8 @@ def __init__(self, help='', help_as_default=True):
self.default_route = None
self.routes = {
'command': [],
'regex': []
'regex': [],
'reaction': [],
}

@staticmethod
Expand Down Expand Up @@ -321,9 +323,11 @@ def add_message_rule(self, rule, match_type, route_func, help=''):
match_type (str): The type of message this route should match
against::

command -- Match against messages directed at this bot.
regex -- Match against messages in a channel that have
been targetted at this bot by omnibot.
command -- Match against messages directed at this bot.
regex -- Match against messages in a channel that have
been targeted at this bot by omnibot.
reaction -- Match against reactions towards items
made by this bot.

route_func (function): The function to call when serving this route
**kwargs (dict): Keyword arguments (see below for more info)
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/omnibot_receiver/router_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ def a_to_b(message, a, b):
assert message_router.handle_message(message1) == 'a is 1, b is 2'
assert message_router.handle_message(message2) == 'a is 1, b is 2 to 3'

def test_reaction_route(self):
message = {'args': '+1', 'match_type': 'reaction'}
message_router = OmnibotMessageRouter()

@message_router.route(r'\+1', match_type='reaction')
def ping(message):
return 'pong'

assert message_router.handle_message(message) == 'pong'


class TestOmnibotInteractiveRouter(object):

Expand Down