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

Class WechatyPlugin

src/wechaty/plugin.py:392–575  ·  view source on GitHub ↗

abstract wechaty plugin base class listen events from

Source from the content-addressed store, hash-verified

390
391
392class WechatyPlugin(ABC, WechatySchedulerMixin, WechatyEventMixin):
393 """
394 abstract wechaty plugin base class
395
396 listen events from
397 """
398 AUTHOR = "wechaty"
399 AVATAR = 'https://avatars.githubusercontent.com/u/10242208?v=4'
400 AUTHOR_LINK = "https://github.com/wj-Mcat"
401 ICON = "https://wechaty.js.org/img/wechaty-icon.svg"
402 VISIABLE = True
403 VIEW_URL = None
404 UI_DIR = None
405
406 def __init__(self, options: Optional[WechatyPluginOptions] = None):
407 self.output: Dict[str, Any] = {}
408 self.bot: Optional[Wechaty] = None
409 if options is None:
410 options = WechatyPluginOptions()
411 self.options = options
412 self._default_logger: Optional[Logger] = None
413 self._cache_dir: Optional[str] = None
414
415 self.setting_file: str = os.path.join(self.cache_dir, 'setting.json')
416 self._setting_wechaty_setting: WechatySetting = WechatySetting(self.setting_file)
417
418 def metadata(self) -> NavMetadata:
419 """get the default nav metadata
420
421 Returns:
422 NavMetadata: the instance of metadata
423 """
424 return NavMetadata(
425 author=self.AUTHOR,
426 author_link=self.AUTHOR_LINK,
427 icon=self.ICON,
428 avatar=self.AVATAR,
429 view_url=self.VIEW_URL
430 )
431
432 @property
433 def setting(self) -> WechatySetting:
434 """get the setting of a plugin"""
435 return self._setting_wechaty_setting
436
437 @setting.setter
438 def setting(self, value: dict) -> None:
439 """update setting with value
440
441 Args:
442 value (dict): the value of setting dict
443 """
444 self._setting_wechaty_setting.save_setting(value)
445
446 def get_ui_dir(self) -> Optional[str]:
447 """get the ui asset dir
448 """
449 # 1. get the customized ui dir according to the static UI_DIR attribute

Callers 1

test_settingFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_settingFunction · 0.72