| Total Complexity | 5 |
| Total Lines | 18 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | from st2actions.runners.pythonrunner import Action |
||
| 5 | class WechatNotifierAction(Action): |
||
| 6 | def run(self, corpID, corpSecret, agentid, message, touser=None, togroup=None, totag=None): |
||
| 7 | receivers = dict() |
||
| 8 | if touser: |
||
| 9 | receivers = {"touser": touser} |
||
| 10 | |||
| 11 | if togroup: |
||
| 12 | receivers.update({"toparty": togroup}) |
||
| 13 | |||
| 14 | if totag: |
||
| 15 | receivers.update({"totag": totag}) |
||
| 16 | |||
| 17 | if len(receivers) == 0: |
||
| 18 | raise KeyError('touser, togroup, totag can not be empty at the same time') |
||
| 19 | |||
| 20 | wechatClient = WechatClient(corpID, corpSecret) |
||
| 21 | wechatClient.sendTextMessage(agentid, message, **receivers) |
||
| 22 | return |
||
| 23 |