get or create global wechaty instance. Args: options: WechatyOptions Returns: Wechaty: global wechaty instance
(cls: Type[Wechaty], options: Optional[WechatyOptions] = None
)
| 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 |
no outgoing calls