Conditions | 3 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 21 |
Ratio | 100 % |
Tests | 12 |
CRAP Score | 3.004 |
Changes | 0 |
1 | """ |
||
19 | 1 | View Code Duplication | def send_message(channel: str, text: str) -> None: |
1 ignored issue
–
show
|
|||
20 | """Write the text to the channel by sending it to the bot via HTTP.""" |
||
21 | 1 | scope = 'any' |
|
22 | 1 | scope_id = None |
|
23 | 1 | format = 'weitersager' |
|
24 | |||
25 | 1 | webhook = webhook_service.find_enabled_outgoing_webhook(scope, scope_id, format) |
|
26 | |||
27 | 1 | if webhook is None: |
|
28 | 1 | current_app.logger.warning( |
|
29 | f'No enabled IRC webhook found. Not sending message to IRC.' |
||
30 | ) |
||
31 | 1 | return |
|
32 | |||
33 | 1 | text_prefix = webhook.text_prefix |
|
34 | 1 | if text_prefix: |
|
35 | text = text_prefix + text |
||
36 | |||
37 | 1 | data = {'channel': channel, 'text': text} |
|
38 | |||
39 | requests.post(webhook.url, json=data) # Ignore response code for now. |
||
40 |