-- --------------------------------------------------------------------------- -- Custom variables -- --------------------------------------------------------------------------- local hello_words = { "ahoy!", "EHLO", "hai", "hello!", "henlo", "hey!", "hi!", "ACK (TCP)", "aloha! (Hawaiian)", "ciao! (Italian)", "hallo (Dutch)", "hej (Swedish)", "hola (Spanish)", "salut! (French)", "saluton (Esperanto)", "tag! (German)", "toki! (Toki Pona)", "هلا (pron: hala)", "مااس (Arabic, pron: salaam)", "สวัสดี (Thai, pron: sawatdee)", "你好 (Chinese, pron: ni hao)", "こんにちわ (Japanese, pron: konnichiwa)", "안녕 (Korean, pron: annyeong)", "नमस्ते (Hindi, pron: namaste)", "ᐊᐃ (Ai)", "Привет (Russian, pron: preevyet)", "שָׁלוֹם (Hebrew, pron: shalom)", "kia ora (Māori)" } -- --------------------------------------------------------------------------- -- Config -- --------------------------------------------------------------------------- -- [[ -- `itte_config` -- Add custom settings and override the default config settings here (see -- `itte.lua` for the full list). Settings need to be appended to this variable -- to be collected by the reload function. -- ]] itte_config = { debug = true, } -- --------------------------------------------------------------------------- -- Handlers -- --------------------------------------------------------------------------- -- Load the main module. local irc = require("itte") -- Load the util module to use some helper functions. local util = require("itteutil") --[[ -- `itte_handlers` -- Define any custom handlers in a new table, then assign the table to it. -- Handlers can also be added to it directly e.g. `itte_handlers.hello()`. -- Handler names should correspond to the service code name, e.g. a function -- `itte_handlers.hello()` will be called within chat as -- `[command_prefix]hello`, as in `!hello`. -- -- Here an object called `h` is created for convenience, and functions will be -- added to it. --]] local h = {} -- Reply with a random greeting. -- The handler takes two parameters, `cxt` and `msg`. -- -- The first is a context table that includes server details and a reference to -- the socket connection. The other is a message table, which is the IRC user -- message broken down into parts such as the sender, recipient, reply_to, and -- the code trigger used. -- -- The context and message tables are required for the `message()` function to -- know which server and user to direct a response. -- -- The `message()` function takes the server connection from the context table, -- a table of users or channels to reply to, and the text string, then formats -- the string into an IRC command and sends it to the server. -- -- `util.pick()` is a helper function that takes a table of items and picks one -- randomly by default if the number of items is unspecified. It will return -- the items in a table, so `[1]` will get the one (and in this case, only) -- value in the table. function h.hello(cxt, msg) irc.message(cxt, { msg.reply_to }, util.pick(hello_words)[1]) end -- This is a task handler for a task named "hello" in the sample config, and is -- an alias to the hello() function above. function h.th_hello(cxt, msg) h.hello(cxt, msg) end -- Hook up the handlers. itte_handlers = h