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
lala.util.msg(target, message, log=True)[source]

Send a message to a target.

Parameters:
  • target (str) – Target to send the message to. Can be a channel or user
  • message (str or [str]) – One or more messages to send
  • log (bool) – Whether or not to log the message
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 a re.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.

class lala.pluginmanager.PluginFunc(func, enabled=True, admin_only=False, aliases=None)[source]

Bases: object

lala.pluginmanager.load_plugin(name)[source]