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

Method __call__

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

Source from the content-addressed store, hash-verified

218 return hash((frozenset(self.msg), self.ignorecase))
219
220 async def __call__(self, event: Event, state: T_State) -> bool:
221 try:
222 text = event.get_plaintext()
223 except Exception:
224 return False
225 if match := re.search(
226 f"(?:{'|'.join(re.escape(suffix) for suffix in self.msg)})$",
227 text,
228 re.IGNORECASE if self.ignorecase else 0,
229 ):
230 state[ENDSWITH_KEY] = match.group()
231 return True
232 return False
233
234
235def endswith(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