summaryrefslogtreecommitdiff
path: root/poezio
diff options
context:
space:
mode:
Diffstat (limited to 'poezio')
-rw-r--r--poezio/core/commands.py14
-rw-r--r--poezio/core/core.py1
-rw-r--r--poezio/core/handlers.py6
-rw-r--r--poezio/mam.py3
-rw-r--r--poezio/plugin_manager.py15
5 files changed, 37 insertions, 2 deletions
diff --git a/poezio/core/commands.py b/poezio/core/commands.py
index 50bbca68..fca9a705 100644
--- a/poezio/core/commands.py
+++ b/poezio/core/commands.py
@@ -1115,11 +1115,17 @@ class CommandCore:
exc_info=True)
@command_args_parser.quoted(1, 256)
- def load(self, args):
+ def load(self, args: List[str]) -> None:
"""
/load <plugin> [<otherplugin> …]
# TODO: being able to load more than 256 plugins at once, hihi.
"""
+
+ usage = '/load <plugin> [<otherplugin> …]'
+ if not args:
+ self.core.information(usage, 'Error')
+ return
+
for plugin in args:
self.core.plugin_manager.load(plugin)
@@ -1128,6 +1134,12 @@ class CommandCore:
"""
/unload <plugin> [<otherplugin> …]
"""
+
+ usage = '/unload <plugin> [<otherplugin> …]'
+ if not args:
+ self.core.information(usage, 'Error')
+ return
+
for plugin in args:
self.core.plugin_manager.unload(plugin)
diff --git a/poezio/core/core.py b/poezio/core/core.py
index fe6a9d78..6065f215 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -227,6 +227,7 @@ class Core:
('connected', self.handler.on_connected),
('connection_failed', self.handler.on_failed_connection),
('disconnected', self.handler.on_disconnected),
+ ('reconnect_delay', self.handler.on_reconnect_delay),
('failed_all_auth', self.handler.on_failed_all_auth),
('got_offline', self.handler.on_got_offline),
('got_online', self.handler.on_got_online),
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index cfdeb271..c8d08441 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -1250,6 +1250,12 @@ class HandlerCore:
self.core.information("Auto-reconnecting.", 'Info')
self.core.xmpp.start()
+ async def on_reconnect_delay(self, event):
+ """
+ When the reconnection is delayed
+ """
+ self.core.information("Reconnecting in %d seconds..." % (event), 'Info')
+
def on_stream_error(self, event):
"""
When we receive a stream error
diff --git a/poezio/mam.py b/poezio/mam.py
index ad1c07e2..0f745f30 100644
--- a/poezio/mam.py
+++ b/poezio/mam.py
@@ -89,7 +89,8 @@ async def query(
callback: Optional[Callable] = None,
) -> None:
try:
- iq = await core.xmpp.plugin['xep_0030'].get_info(jid=remote_jid)
+ query_jid = remote_jid if groupchat else JID(core.xmpp.boundjid.bare)
+ iq = await core.xmpp.plugin['xep_0030'].get_info(jid=query_jid)
except (IqError, IqTimeout):
raise DiscoInfoException
if 'urn:xmpp:mam:2' not in iq['disco_info'].get_features():
diff --git a/poezio/plugin_manager.py b/poezio/plugin_manager.py
index 2b7b7374..e603b6fa 100644
--- a/poezio/plugin_manager.py
+++ b/poezio/plugin_manager.py
@@ -10,6 +10,7 @@ import os
from importlib import import_module, machinery
from pathlib import Path
from os import path
+import pkg_resources
from poezio import tabs, xdg
from poezio.core.structs import Command, Completion
@@ -68,16 +69,30 @@ class PluginManager:
module = None
loader = self.finder.find_module(name, self.load_path)
if loader:
+ log.debug('Found candidate loader for plugin %s: %r', name, loader)
module = loader.load_module()
+ if module is None:
+ log.debug('Failed to load plugin %s from loader', name)
else:
try:
module = import_module('poezio_plugins.%s' % name)
except ModuleNotFoundError:
pass
+ for entry in pkg_resources.iter_entry_points('poezio_plugins'):
+ if entry.name == name:
+ log.debug('Found candidate entry for plugin %s: %r', name, entry)
+ try:
+ module = entry.load()
+ except ImportError as exn:
+ log.debug('Failed to import plugin: %s\n%r', name,
+ exn, exc_info=True)
+ finally:
+ break
if not module:
self.core.information('Could not find plugin: %s' % name,
'Error')
return
+ log.debug('Plugin %s loaded from "%s"', name, module.__file__)
except Exception as e:
log.debug("Could not load plugin %s", name, exc_info=True)
self.core.information("Could not load plugin %s: %s" % (name, e),