summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/decorators.py12
-rw-r--r--poezio/tabs/rostertab.py13
2 files changed, 13 insertions, 12 deletions
diff --git a/poezio/decorators.py b/poezio/decorators.py
index 4b5d0320..51abf32c 100644
--- a/poezio/decorators.py
+++ b/poezio/decorators.py
@@ -162,3 +162,15 @@ class CommandArgParser:
command_args_parser = CommandArgParser()
+
+
+def deny_anonymous(func: Callable) -> Callable:
+ """Decorator to disable commands when using an anonymous account."""
+ def wrap(self: 'RosterInfoTab', *args, **kwargs):
+ if self.core.xmpp.anon:
+ return self.core.information(
+ 'This command is not available for anonymous accounts.',
+ 'Info'
+ )
+ return func(self, *args, **kwargs)
+ return wrap
diff --git a/poezio/tabs/rostertab.py b/poezio/tabs/rostertab.py
index 50b8c0d5..2cd6e010 100644
--- a/poezio/tabs/rostertab.py
+++ b/poezio/tabs/rostertab.py
@@ -24,7 +24,7 @@ from poezio.contact import Contact, Resource
from poezio.decorators import refresh_wrapper
from poezio.roster import RosterGroup, roster
from poezio.theming import get_theme, dump_tuple
-from poezio.decorators import command_args_parser
+from poezio.decorators import command_args_parser, deny_anonymous
from poezio.core.structs import Command, Completion
from poezio.tabs import Tab
from poezio.ui.types import InfoMessage
@@ -32,17 +32,6 @@ from poezio.ui.types import InfoMessage
log = logging.getLogger(__name__)
-def deny_anonymous(func: Callable) -> Callable:
- def wrap(self: 'RosterInfoTab', *args, **kwargs):
- if self.core.xmpp.anon:
- return self.core.information(
- 'This command is not available for anonymous accounts.',
- 'Info'
- )
- return func(self, *args, **kwargs)
- return wrap
-
-
class RosterInfoTab(Tab):
"""
A tab, split in two, containing the roster and infos