Changeset 3503
- Timestamp:
- 03/15/10 11:59:43 (5 months ago)
- Location:
- Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot
- Files:
-
- 3 added
- 3 modified
-
bot.lua (modified) (4 diffs)
-
irc.lua (modified) (5 diffs)
-
logging.lua (modified) (2 diffs)
-
services (added)
-
services.lua (added)
-
services/serverServ.lua (added)
Legend:
- Unmodified
- Added
- Removed
-
Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot/bot.lua
r3445 r3503 11 11 function initBot(hostname, port, nickname, channel) 12 12 local connection = irc.connect(hostname, port); 13 localnickname = nickname;14 13 bot.nickname = nickname; 14 15 15 bot.connection = connection; 16 16 bot.logDirectory = "logs/"; 17 17 18 18 function login() 19 connection.login( nickname)19 connection.login(bot.nickname) 20 20 return true 21 21 end … … 39 39 40 40 if first ~= nil then 41 if part1 == nickname then41 if part1 == bot.nickname then 42 42 first, last, nick = string.find(connection.getCmd(1), "(.-)!") 43 43 if nick == nil then … … 45 45 else 46 46 local channel = connection.getChannel(); 47 if channel == nickname then47 if channel == bot.nickname then 48 48 channel = nick; 49 49 end … … 61 61 62 62 -- If this is a private message, assume that it's directed at the bot 63 if channel == nickname then63 if channel == bot.nickname then 64 64 channel = nick; 65 65 handlePlayerCommand(connection, channel, nick, connection.getText()); -
Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot/irc.lua
r3494 r3503 1 1 local base = _G 2 2 require "socket" 3 require "mudbot.services" 3 4 require "save" 4 5 … … 16 17 17 18 local send = function(text) 19 print("SEND: " .. text); 18 20 c:send(text .. "\r\n") 19 21 end … … 24 26 if status == "closed" then 25 27 return 28 end 29 if (s ~= nil) then 30 print("RECV: " .. s); 26 31 end 27 32 coroutine.yield(s) … … 78 83 -- Parse the string we got from the server 79 84 if value ~= nil then 80 print(value)81 85 82 86 local first, last, part1, part2 = string.find(value, "^:(.-):(.-)$") … … 112 116 doLog(); 113 117 else 114 -- Parse PING118 -- Parse Server commands 115 119 local words = {} 116 120 for w in string.gfind(value, "%S+") do 117 121 table.insert(words, w) 118 122 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); 122 128 print("PONG") 123 129 else -
Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot/logging.lua
r3445 r3503 16 16 local function logHandler() 17 17 local text = bot.connection.getText(); 18 print("Got message " .. text)19 18 20 19 -- Parse the message … … 37 36 end 38 37 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 "")); 42 41 43 42 -- Skip non-channel messages
