Module blitwizard.net.irc

This is the IRC module which allows you to connect to the popular Internet Relay Chat.

You can add ingame chat rooms to your game quite easily using this module.

Class connection

connection:new (server, callback, username, optional) Create a new IRC instance.
connection:close () Close an IRC connection.
connection:getUsername () Get the user name currently used on the chat server.
connection:enterRoom (room) Join a specific chat room
connection:talkToPerson (username, msg) Talk to a specific person (in private chat).
connection:talkToRoom (room, msg) Talk to a specific chat room.
connection:doRoomAction (room, action) Roleplay a specific action in a room, e.g.


Class connection

This is the IRC connection class type which embodies an IRC server connection.

You can create as many as you like if you want to connect to multiple servers at once.

connection:new (server, callback, username, optional)
Create a new IRC instance. (see usage example below!)

Parameters:

  • server string the address of the server, e.g. irc.eloxoph.de
  • callback function the event callback. It will be called with first parameter being this IRC instance, the second one the event name and all additional parameters depending on the event.

    The following events are known:

    "connect": the connection was successfully established. Use connection:enterRoom to enter a chat room now!

    "enter": parameters: room, user name. The user with the given name entered the specified chat room. If the user name is yours (connection:getUsername), this means you are inside the chat room now and you may participate in conversations using connection:talkToRoom or connection:doRoomAction.

  • username number the desired user name to be used on the chat server
  • optional port ) specify the server port. Defaults to 6667, the most commonly used IRC server port

Usage:

      -- connect to the #blitwizard chat room:
      myIRC = blitwizard.net.irc.connection:new("irc.eloxoph.de",
      function(self, event, param1, param2, param3)
          if event == "connect" then
              print("Connected! Will now enter chat room...")
              self:enterRoom("#blitwizard")
          elseif event == "enter" then
              if string.lower(param1) == "#blitwizard" and
              param2 == self:getUsername() then
                  print("Now inside #blitwizard! Say \"Hello World!\"...")
                  self:talkToRoom("#blitwizard", "Hello World!")
              end
           elseif event == "roomTalk" and
            string.lower(param1) == "#blitwizard" then
               -- a person talked in #blitwizard! display it!
               print("<" .. param2 .. "> " .. param3)
           elseif event == "roomAction" and
            string.lower(param1) == "#blitwizard" then
               -- a person did an 'action' in #blitwizard. display it:
               print("<" .. param2 .. " " .. param3 .. ">")
           end
      end, "testUser")
connection:close ()
Close an IRC connection.
connection:getUsername ()
Get the user name currently used on the chat server.

Returns:

    string the user name currently used
connection:enterRoom (room)
Join a specific chat room

Parameters:

  • room string the name of the chat room. Please note that on most servers, the name is required to start with #. Space chars are not allowed.
connection:talkToPerson (username, msg)
Talk to a specific person (in private chat).

Please note offline chat is not supported (message will not arrive if user is offline!)

Parameters:

  • username string the user name of the person to talk to
  • msg string the message you want to send to the person
connection:talkToRoom (room, msg)
Talk to a specific chat room. Please note this is not possible before the "enter" event!

Parameters:

  • room string the chat room to talk to
  • msg string the message you want to send
connection:doRoomAction (room, action)
Roleplay a specific action in a room, e.g. "looks outside of window" as an action will show up as " looks outside the window".

Similar to connection.talkToRoom, this is not possible before entering a room and getting the "enter" event.

Parameters:

  • room string the chat room you want to do the action in
  • action string the description of your action
generated by LDoc 1.3.11