-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_base.py
More file actions
115 lines (90 loc) · 2.69 KB
/
Copy pathplugin_base.py
File metadata and controls
115 lines (90 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""
Plugin Base Class
All plugins must inherit from this class
"""
from abc import ABC, abstractmethod
from PySide6.QtWidgets import QWidget
class PluginBase(ABC):
"""
Abstract base class for all plugins
Plugins must implement all abstract methods to be loaded by the main application.
Each plugin receives access to the TelegramService and shared config.
"""
def __init__(self, telegram_service, config):
"""
Initialize the plugin
Args:
telegram_service: Shared TelegramService instance
config: Shared configuration dictionary
"""
self.telegram_service = telegram_service
self.config = config
@abstractmethod
def get_name(self) -> str:
"""
Return the plugin's display name
Returns:
str: Plugin name (e.g., "LED Controller")
"""
pass
@abstractmethod
def get_icon(self) -> str:
"""
Return an emoji or icon for the plugin
Returns:
str: Icon/emoji (e.g., "💡")
"""
pass
@abstractmethod
def get_widget(self) -> QWidget:
"""
Return the plugin's main widget for display in the UI
Returns:
QWidget: The widget to be displayed in the plugin tab
"""
pass
@abstractmethod
def on_telegram_message(self, message: str):
"""
Called when a new Telegram message is received
Args:
message: The message text received from Telegram
"""
pass
def get_description(self) -> str:
"""
Optional: Return a description of the plugin
Returns:
str: Plugin description
"""
return "No description provided"
def get_version(self) -> str:
"""
Optional: Return the plugin version
Returns:
str: Version string (e.g., "1.0.0")
"""
return "1.0.0"
def get_author(self) -> str:
"""
Optional: Return the plugin author
Returns:
str: Author name
"""
return "Unknown"
def get_homepage(self) -> str:
"""
Optional: Return the plugin homepage/repo URL
Returns:
str: URL or empty string
"""
return ""
def on_enable(self):
"""Optional: Called when the plugin is enabled"""
pass
def on_disable(self):
"""Optional: Called when the plugin is disabled"""
pass
def cleanup(self):
"""Optional: Called when the plugin is being unloaded"""
pass