MCPcopy Create free account
hub / github.com/wechaty/python-wechaty / instance

Method instance

src/wechaty/wechaty.py:262–279  ·  view source on GitHub ↗

get or create global wechaty instance. Args: options: WechatyOptions Returns: Wechaty: global wechaty instance

(cls: Type[Wechaty], options: Optional[WechatyOptions] = None
                 )

Source from the content-addressed store, hash-verified

260
261 @classmethod
262 def instance(cls: Type[Wechaty], options: Optional[WechatyOptions] = None
263 ) -> Wechaty:
264 """
265 get or create global wechaty instance.
266 Args:
267 options: WechatyOptions
268 Returns:
269 Wechaty: global wechaty instance
270 """
271 log.info('instance()')
272
273 if cls._global_instance is None:
274 cls._global_instance = cls(options)
275
276 # Huan(202003): how to remove cast?
277 return cls._global_instance
278 # return cast(Wechaty, cls._global_instance)
279 # return cls._global_instance
280
281 def use(self, plugin: Union[WechatyPlugin, List[WechatyPlugin]]) -> Wechaty:
282 """register the plugin

Callers 2

message_listenerMethod · 0.45
test_single_id_containerFunction · 0.45

Calls

no outgoing calls

Tested by 1

test_single_id_containerFunction · 0.36