Total Complexity | 2 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | import os |
||
9 | class ExecuteActionAliasAction(Action): |
||
10 | def __init__(self, config=None): |
||
11 | super(ExecuteActionAliasAction, self).__init__(config=config) |
||
12 | api_url = os.environ.get('ST2_ACTION_API_URL', None) |
||
13 | token = os.environ.get('ST2_ACTION_AUTH_TOKEN', None) |
||
14 | self.client = Client(api_url=api_url, token=token) |
||
15 | |||
16 | def run(self, text, source_channel=None, user=None): |
||
17 | alias_match = ActionAliasMatch() |
||
18 | alias_match.command = text |
||
19 | alias, representation = self.client.managers['ActionAlias'].match( |
||
20 | alias_match) |
||
21 | |||
22 | execution = ActionAliasExecution() |
||
23 | execution.name = alias.name |
||
24 | execution.format = representation |
||
25 | execution.command = text |
||
26 | execution.source_channel = source_channel # ? |
||
27 | execution.notification_channel = None |
||
28 | execution.notification_route = None |
||
29 | execution.user = user |
||
30 | |||
31 | action_exec_mgr = self.app.client.managers['ActionAliasExecution'] |
||
32 | |||
33 | execution = action_exec_mgr.create(execution) |
||
34 | return execution.execution['id'] |
||
35 |