diff options
author | mathieui <mathieui@mathieui.net> | 2020-05-09 23:12:57 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-05-09 23:12:57 +0200 |
commit | 2eb362ffe86dda15e75e3be227acdfce695bfeab (patch) | |
tree | 078efe9c1172f6b8cb052803be5d3411b0670d42 /poezio/decorators.py | |
parent | f68fa1da5e2cccd396ee03eec12359ff905b7bc6 (diff) | |
download | poezio-2eb362ffe86dda15e75e3be227acdfce695bfeab.tar.gz poezio-2eb362ffe86dda15e75e3be227acdfce695bfeab.tar.bz2 poezio-2eb362ffe86dda15e75e3be227acdfce695bfeab.tar.xz poezio-2eb362ffe86dda15e75e3be227acdfce695bfeab.zip |
Move the deny_anonymous decorator to the poezio.decorators module
Diffstat (limited to 'poezio/decorators.py')
-rw-r--r-- | poezio/decorators.py | 12 |
1 files changed, 12 insertions, 0 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 |