Lala utils¶
Helpers to be used with plugins
-
class
lala.util.
command
(command=None, admin_only=False, aliases=None)[source]¶ Bases:
object
Decorator to register a command. The name of the command is the __name__ attribute of the decorated function. Example:
@command def heyiamacommand(user, channel, text): pass
You can also pass a
command
parameter to overwrite the name of the command:@command(command="yetanothercommand") def command_with_a_really_stupid_or_insanely_long_name(user, channel, text): pass
aliases
can be a list of names under which the function will be available in addition to its primary name.An additional argument,
admin_only
can be used to make a function available to admins only:@command(admin_only=True) def give_me_the_one_ring(user, channel, text): pass
New in version 0.5.
If the function returns a
twisted.internet.defer.Deferred
or a generator function that’s generating them, an Errback will automatically be added to the Deferred(s).Changed in version 0.5.
The third argument received by a command function used to include the name of the command itself. Since version 0.5 this is no longer the case.
-
lala.util.
on_join
(f)[source]¶ Decorator for functions reacting to joins
Parameters: f – The function which should be called on joins.
-
class
lala.util.
regex
(regex)[source]¶ Bases:
object
Decorator to register a regex. Example:
@regex("(https?://.+)\s?") def somefunc(user, channel, text, match_obj): pass
match_obj
is are.MatchObject
.Parameters: regex – A re.RegexObject
or a string representing a regular expression.
-
lala.pluginmanager.
disable
(trigger)[source]¶ Disables trigger.
Parameters: trigger (str) – The trigger to disable. Can be a key for a callback or a regular expression
-
lala.pluginmanager.
enable
(trigger)[source]¶ Enables trigger.
Parameters: trigger (str) – The trigger to enable. Can be a key for a callback or a regular expression
-
lala.pluginmanager.
is_admin
(user)[source]¶ Check whether
user
is an admin.If a nickserv password is set, this will work by checking an internal list of identified admins.
If no nickserv password is set, this simply checks if
user
is in the “admins” option of the “base” section.