|
3 | 3 | """ |
4 | 4 |
|
5 | 5 | from typing import Callable |
| 6 | +from functools import partial |
6 | 7 | from library.clientclass import BaseClient |
7 | 8 | from plugins import hato |
8 | 9 |
|
9 | 10 |
|
10 | 11 | def analyze_message(message: str) -> Callable[[BaseClient], None]: |
11 | 12 | """コマンド解析""" |
12 | 13 |
|
13 | | - conditions = {'help': lambda m: hato.help_message, |
14 | | - 'eq': lambda m: hato.earth_quake, |
15 | | - '地震': lambda m: hato.earth_quake, |
16 | | - 'text list': lambda m: hato.get_text_list, |
17 | | - 'text add ': lambda m: hato.add_text(m[len('text add '):]), |
18 | | - 'text show ': lambda m: hato.show_text(m[len('text show '):]), |
19 | | - 'text delete ': lambda m: hato.delete_text(m[len('text delete '):]), |
20 | | - 'text random': lambda m: hato.show_random_text, |
21 | | - 'text': lambda m: hato.show_random_text, |
22 | | - '>< ': lambda m: hato.totuzensi(m[len('>< '):]), |
23 | | - 'amesh': lambda m: hato.amesh((m[len('amesh'):]).strip()), |
24 | | - '電力': lambda m: hato.electricity_demand, |
25 | | - '標高': lambda m: hato.altitude((m[len('標高'):]).strip()), |
26 | | - 'version': lambda m: hato.version, |
27 | | - 'にゃーん': lambda m: hato.yoshiyoshi, |
28 | | - 'おみくじ': lambda m: hato.omikuji, |
29 | | - } |
| 14 | + conditions = { |
| 15 | + 'help': lambda m: hato.help_message, |
| 16 | + 'eq': lambda m: hato.earth_quake, |
| 17 | + '地震': lambda m: hato.earth_quake, |
| 18 | + 'text list': lambda m: hato.get_text_list, |
| 19 | + 'text add ': lambda m: partial( |
| 20 | + hato.add_text, |
| 21 | + word=m[len('text add '):] |
| 22 | + ), |
| 23 | + 'text show ': lambda m: partial( |
| 24 | + hato.show_text, |
| 25 | + power_word_id=m[len('text show '):] |
| 26 | + ), |
| 27 | + 'text delete ': lambda m: partial( |
| 28 | + hato.delete_text, |
| 29 | + power_word_id=m[len('text delete '):] |
| 30 | + ), |
| 31 | + 'text random': lambda m: hato.show_random_text, |
| 32 | + 'text': lambda m: hato.show_random_text, |
| 33 | + '>< ': lambda m: partial(hato.totuzensi, message=m[len('>< '):]), |
| 34 | + 'amesh': lambda m: partial(hato.amesh, place=m[len('amesh'):].strip()), |
| 35 | + '電力': lambda m: hato.electricity_demand, |
| 36 | + '標高': lambda m: partial(hato.altitude, place=m[len('標高'):].strip()), |
| 37 | + 'version': lambda m: hato.version, |
| 38 | + 'にゃーん': lambda m: hato.yoshiyoshi, |
| 39 | + 'おみくじ': lambda m: hato.omikuji, |
| 40 | + } |
30 | 41 |
|
31 | 42 | for key, method in conditions.items(): |
32 | 43 | if message.startswith(key): |
|
0 commit comments