Skip to content
This repository was archived by the owner on May 28, 2022. It is now read-only.

Commit 3a11b95

Browse files
committed
Merge branch 'release/v3.2.1'
2 parents 44bc66a + 8ff9725 commit 3a11b95

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
## [v3.2.1] 2022-01-24
11+
12+
### Fixed
13+
14+
- `mention_command` が複数登録できない不具合を修正しました
15+
1016
## [v3.2.0] 2022-01-24
1117

1218
### Added

mi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__copyright__ = "Copyright 2021-present yupix"
55
__author_email__ = "[email protected]"
66
__url__ = "https://github.com/yupix/Mi.py"
7-
__version__ = "3.2.0"
7+
__version__ = "3.2.1"
88

99
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1010

mi/client.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,16 @@ async def __on_error(event_method: str) -> None:
158158
traceback.print_exc()
159159

160160
async def progress_command(self, message):
161-
for key, command in self.all_commands.items():
162-
if key == 'regex':
163-
if re.search(command[0], message.content):
164-
hit_list = re.findall(command[0], message.content)
161+
for cmd in self.all_commands:
162+
print(cmd)
163+
if cmd.cmd_type == 'regex':
164+
if re.search(cmd.key, message.content):
165+
hit_list = re.findall(cmd.key, message.content)
165166
if isinstance(hit_list, tuple):
166167
hit_list = hit_list[0]
167-
await command[1].invoke(message, *hit_list)
168-
elif message.content.find(command[0]) != -1:
169-
await command[1].invoke(message)
168+
await cmd.func.invoke(message, *hit_list)
169+
elif message.content.find(cmd.key) != -1:
170+
await cmd.func.invoke(message)
170171
else:
171172
continue
172173

mi/ext/commands/core.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
import asyncio
2-
from typing import Dict, List, Optional
2+
from typing import List, Optional
33

44
from mi.ext.commands._types import _BaseCommand
55

66

7+
class CMD:
8+
def __init__(self, cmd_type: str, key: str, func: 'Command'):
9+
self.cmd_type = cmd_type
10+
self.key = key
11+
self.func = func
12+
13+
714
class CommandManager:
815
def __init__(self, *args, **kwargs):
9-
self.all_commands: Dict[str, List[str, Command]] = {}
16+
self.all_commands: List[CMD] = []
1017
super().__init__(*args, **kwargs) # Clientクラスを初期化する
1118

1219
def add_command(self, command: 'Command'):
1320
if not isinstance(command, Command):
1421
raise TypeError(f'{command}はCommandクラスである必要があります')
1522
command_type = 'regex' if command.regex else 'text'
1623
command_key = command.regex or command.text
17-
self.all_commands[command_type] = [command_key, command]
24+
self.all_commands.append(CMD(command_type, command_key, command))
1825

1926

2027
class Command(_BaseCommand):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
setup(
4040
name="mi.py",
41-
version="3.2.0",
41+
version="3.2.1",
4242
install_requires=["emoji", 'aiocache', 'aiohttp'],
4343
url="https://github.com/yupix/mi.py",
4444
author="yupix",

0 commit comments

Comments
 (0)