Skip to content

Commit 9e8845c

Browse files
committed
fix: Improve plugin loading error handling and fix analytics plugin
- Update plugin manager to gracefully handle abstract method errors - Fix analytics plugin metadata property implementation - Ensure application continues running even if plugins fail to load - Add better error logging for plugin loading failures
1 parent 36afe98 commit 9e8845c

3 files changed

Lines changed: 25 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to the Telegram Multi-Account Message Sender project will be
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [1.2.8] - 2025-01-XX
8+
## [1.2.8] - 2025-12-07
99

1010
### Added
1111
- **Proxy Test Functionality**: Added "Test Proxy" button in account proxy settings to verify proxy connection before saving

app/plugins/example_analytics_plugin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ def __init__(self, api):
1717
"""Initialize plugin."""
1818
super().__init__(api)
1919
self.events = []
20-
21-
@property
22-
def metadata(self) -> PluginMetadata:
23-
"""Get plugin metadata."""
24-
return PluginMetadata(
20+
self._metadata = PluginMetadata(
2521
name="Example Analytics Plugin",
2622
version="1.0.0",
2723
description="Example plugin that demonstrates analytics tracking",
@@ -31,6 +27,11 @@ def metadata(self) -> PluginMetadata:
3127
tags=["example", "analytics", "tracking"]
3228
)
3329

30+
@property
31+
def metadata(self) -> PluginMetadata:
32+
"""Get plugin metadata."""
33+
return self._metadata
34+
3435
def get_default_config(self) -> Dict[str, Any]:
3536
"""Get default configuration."""
3637
return {

app/services/plugin_manager.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,30 @@ def load_plugin(self, plugin_path: Path) -> Optional[PluginInfo]:
140140
for name, obj in inspect.getmembers(module):
141141
if (inspect.isclass(obj) and
142142
issubclass(obj, Plugin) and
143-
obj is not Plugin):
143+
obj is not Plugin and
144+
obj is not MessageFilterPlugin and
145+
obj is not AnalyticsPlugin and
146+
obj is not NotificationPlugin and
147+
obj is not IntegrationPlugin):
144148
plugin_class = obj
145149
break
146150

147151
if plugin_class is None:
148152
raise ValueError(f"No Plugin subclass found in {plugin_path}")
149153

150-
# Instantiate plugin
151-
plugin_instance = plugin_class(self.api)
154+
# Try to instantiate plugin - Python's ABC will raise TypeError if abstract methods aren't implemented
155+
# We catch it and provide better error context
156+
try:
157+
plugin_instance = plugin_class(self.api)
158+
except TypeError as e:
159+
error_msg = str(e)
160+
if "abstract" in error_msg.lower() or "abstractmethod" in error_msg.lower():
161+
# This is an abstract method error - log it and skip this plugin
162+
self.logger.error(f"Error loading plugin {plugin_path.name}: {error_msg}")
163+
return None
164+
else:
165+
# Some other TypeError during instantiation
166+
raise
152167

153168
# Get metadata
154169
metadata = plugin_instance.metadata

0 commit comments

Comments
 (0)