MCPcopy
hub / github.com/nonebot/nonebot2 / __call__

Method __call__

nonebot/rule.py:165–177  ·  view source on GitHub ↗
(self, event: Event, state: T_State)

Source from the content-addressed store, hash-verified

163 return hash((frozenset(self.msg), self.ignorecase))
164
165 async def __call__(self, event: Event, state: T_State) -> bool:
166 try:
167 text = event.get_plaintext()
168 except Exception:
169 return False
170 if match := re.match(
171 f"^(?:{'|'.join(re.escape(prefix) for prefix in self.msg)})",
172 text,
173 re.IGNORECASE if self.ignorecase else 0,
174 ):
175 state[STARTSWITH_KEY] = match.group()
176 return True
177 return False
178
179
180def startswith(msg: str | tuple[str, ...], ignorecase: bool = False) -> Rule:

Callers

nothing calls this directly

Calls 2

get_plaintextMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected