MCPcopy
hub / github.com/wechaty/python-wechaty / on

Method on

src/wechaty/wechaty.py:303–318  ·  view source on GitHub ↗

listen wechaty event Args: event: the event name, see at `WechatyEventName`. listener: the function bind to event name, see at `WechatyEventFunction`. Examples: Event:scan >>> bot.on('scan', lambda qrcode, status: print(qrcode,

(self, event: str, f: Callable[..., Any] = None)

Source from the content-addressed store, hash-verified

301 return self._name
302
303 def on(self, event: str, f: Callable[..., Any] = None) -> Wechaty: # type: ignore
304 """
305 listen wechaty event
306 Args:
307 event: the event name, see at `WechatyEventName`.
308 listener: the function bind to event name, see at `WechatyEventFunction`.
309 Examples:
310 Event:scan
311 >>> bot.on('scan', lambda qrcode, status: print(qrcode, status))
312 >>> bot.start()
313 Returns:
314 Wechaty: self
315 """
316 log.info('on() listen event <%s> with <%s>', event, f)
317 super().on(event, f)
318 return self
319
320 def emit(self, event: str, *args: Any, **kwargs: Any) -> bool:
321 """

Callers 3

add_listener_functionMethod · 0.95
ready_listenerMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected