Changeset 3503

Show
Ignore:
Timestamp:
03/15/10 11:59:43 (5 months ago)
Author:
trichards
Message:

Adding IRC services compatible with Hybrid IRC to mudbot.

Location:
Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot
Files:
3 added
3 modified

Legend:

Unmodified
Added
Removed
  • Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot/bot.lua

    r3445 r3503  
    1111function initBot(hostname, port, nickname, channel) 
    1212    local connection = irc.connect(hostname, port); 
    13     local nickname = nickname; 
    14      
     13    bot.nickname = nickname; 
     14 
    1515    bot.connection = connection; 
    1616    bot.logDirectory = "logs/"; 
    1717 
    1818    function login() 
    19         connection.login(nickname) 
     19        connection.login(bot.nickname) 
    2020        return true 
    2121    end 
     
    3939             
    4040            if first ~= nil then 
    41                 if part1 == nickname then 
     41                if part1 == bot.nickname then 
    4242                    first, last, nick = string.find(connection.getCmd(1), "(.-)!") 
    4343                    if nick == nil then  
     
    4545                    else 
    4646                        local channel = connection.getChannel(); 
    47                         if channel == nickname then 
     47                        if channel == bot.nickname then 
    4848                            channel = nick; 
    4949                        end 
     
    6161                 
    6262                -- If this is a private message, assume that it's directed at the bot 
    63                 if channel == nickname then 
     63                if channel == bot.nickname then 
    6464                    channel = nick; 
    6565                    handlePlayerCommand(connection, channel, nick, connection.getText()); 
  • Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot/irc.lua

    r3494 r3503  
    11local base = _G 
    22require "socket" 
     3require "mudbot.services" 
    34require "save" 
    45 
     
    1617 
    1718    local send = function(text) 
     19        print("SEND: " .. text); 
    1820        c:send(text .. "\r\n") 
    1921    end 
     
    2426            if status == "closed" then  
    2527                return  
     28            end 
     29            if (s ~= nil) then 
     30                print("RECV: " .. s); 
    2631            end 
    2732            coroutine.yield(s) 
     
    7883            -- Parse the string we got from the server 
    7984            if value ~= nil then 
    80                 print(value) 
    8185 
    8286                local first, last, part1, part2 = string.find(value, "^:(.-):(.-)$") 
     
    112116                    doLog(); 
    113117                else 
    114                     -- Parse PING 
     118                    -- Parse Server commands 
    115119                    local words = {} 
    116120                    for w in string.gfind(value, "%S+") do 
    117121                        table.insert(words, w) 
    118122                    end 
    119  
    120                     if words[1] == "PING" then 
    121                         c:send("PONG :indiezen") 
     123                     
     124                    command = ircServices["ServerServ"].commands[words[1]]; 
     125                     
     126                    if (command ~= nil) then 
     127                        command.handler(c, words); 
    122128                        print("PONG") 
    123129                                        else 
  • Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot/logging.lua

    r3445 r3503  
    1616local function logHandler() 
    1717    local text = bot.connection.getText(); 
    18     print("Got message " .. text) 
    1918 
    2019    -- Parse the message  
     
    3736    end 
    3837     
    39     print("first: " .. (first or "")); 
    40     print("last: " .. (last or "")); 
    41     print("nick: " .. (nick or "")); 
     38    --print("first: " .. (first or "")); 
     39    --print("last: " .. (last or "")); 
     40    --print("nick: " .. (nick or "")); 
    4241     
    4342    -- Skip non-channel messages