Skip to content

Lua Modules

Marco Silipo edited this page Sep 29, 2016 · 7 revisions

Alfred allows for extending him via lua to add a new lua module, simply add a new .lua file in the modules directory.


Default table

All functions are located in the alfred table.

registerRaw

Arguments

  1. FUNCTION Function to call when a message is received. function will receive following argument set: content:string, receiver:string, sender:string, kind:string

Result

NIL

Examples

  • alfred.registerraw(function(c, recv, send, kind) print(c) end);

registerCmd

Arguments

  1. FUNCTION Function to call when a command is used. function will receive following argument set: content:string, receiver:string, sender:string, kind:string additionally, the function will receive all parameters you requested in formatprovider
  2. STRING Name of the command
  3. STRING Arg-Format of this command. Each argument has to be terminated with a ;.
  • Required Argument: ARGNAME;
  • Optional Argument: ARGNAME=DEFUALT;
  1. BOOLEAN Determines wether this command requires you to be an authorized user.
  2. BOOLEAN Determines wether this command is only available via direct messages.

Result

NIL

Examples

  • alfred.registerCmd(function(c, recv, send, kind, arg1) print(arg1) end, "roll", "text=foo;", false, false);

registerMsg

Arguments

  1. FUNCTION Function to call when a message is received. function will receive following argument set: content:string, receiver:string, sender:string

Result

NIL

Examples

  • alfred.registerMsg(function(c, recv, send) print(c) end);

sendPrivMsg

Arguments

  1. STRING Message to send.
  2. STRING Receiver of this message. Receiver can be a channel, a fuly qualified nick or a nick.

Result

NIL

Examples

  • alfred.sendPrivMsg("hello there", "X39");
  • alfred.sendPrivMsg("hello there", "jenny!~foo.vaderphone.ip-pool.doop");
  • alfred.sendPrivMsg("hello there", "#foobar");

respond

Arguments

  1. STRING Message to send.
  2. STRING Receiver of this message. Should be registermsg or registerraw receiver arg.
  3. STRING Sender of this message. Should be registermsg or registerraw sender arg.

Result

NIL

Examples

  • alfred.respond("hello there", recv, sender);
  • alfred.respond("hello there", "#foobar", "jenny!~foo.vaderphone.ip-pool.doop");

getRandomResponse

Arguments

  1. STRING response available in config.xml file.

Result

STRING either invalid arg string or a random response as entered in config.xml

Examples

  • alfred.getRandomResponse("error");
  • alfred.getRandomResponse("unknown");

setChannelVar

Arguments

  1. STRING Fully qualified channel name (always starts with #).
  2. STRING Namespace. Users are automatically managed by using their fully qualified username (discarded when user PARTs).
  3. STRING Variable name to use.
  4. STRING Value to put.

Result

NIL

Examples

  • alfred.setChannelVar("#foo", "bar", "varname", "something");
  • alfred.setChannelVar("#foo", "jenny!~foo.vaderphone.ip-pool.doop", "varname", "something");

getChannelVar

Arguments

  1. STRING Fully qualified channel name (always starts with #).
  2. STRING Namespace. Users are automatically managed by using their fully qualified username (discarded when user PARTs).
  3. STRING Variable name to use.

Result

STRING Value in given slot or NIL if there was no value at given slot.

Examples

  • alfred.getChannelVar("#foo", "bar", "varname", "something");
  • alfred.getChannelVar("#foo", "jenny!~foo.vaderphone.ip-pool.doop", "varname", "something");

getChannelVar

Arguments

Result

TABLE Table containing all channels the bot currently is joined to

Examples

  • alfred.getChannelList();