Changeset 3494
- Timestamp:
- 03/12/10 11:06:53 (5 months ago)
- Location:
- Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot
- Files:
-
- 2 modified
-
irc.lua (modified) (4 diffs)
-
playerCommands.lua (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot/irc.lua
r3445 r3494 1 1 local base = _G 2 2 require "socket" 3 require "save" 3 4 4 5 module(..., package.seeall) … … 119 120 if words[1] == "PING" then 120 121 c:send("PONG :indiezen") 121 else 122 print("PONG") 123 else 122 124 print(words[1]) 123 125 print("ERR: Couldn't parse " .. value) … … 161 163 162 164 local channels = {} 163 165 166 local setChannels = function(newChannels) 167 168 bot.reload("savedChannels.lua"); 169 170 -- Set the channels to be the new channels (possibly temporarily save the current channels table 171 local oldChannels = channels; 172 channels = newChannels; 173 174 -- Iterate through the new channels and join them if not already joined. 175 for channelName, channel in channels do 176 -- Check to see if the channel has already been joined 177 -- We've already joined if the channel exists in the original channels table. 178 if oldChannels[channelName] == nil then 179 -- Join the channel because it wasn't in the old list. 180 connection.join(channelName); 181 else 182 -- We're already in the channel, so remove it from the old list. 183 -- This will make it so that when we're done, everything still 184 -- in the old list we need to leave. 185 oldChannels[channelName] = nil; 186 end 187 end 188 189 190 -- Once you're done, any channels that remain in the old channels table you need to "leave". 191 for channelName, channel in oldChannels do 192 connection.part(channelName); 193 end 194 end 195 196 local saveChannels = function() 197 local file = io.open("savedChannels.lua", "w"); 198 199 file:write("channels = {}\n"); 200 201 for channelIndex, channel in pairs(channels) do 202 file:write("channels[\"" .. channelIndex .. "\"] = channel(\"" .. channel .. "\");\n"); 203 end 204 205 file:close(); 206 end 207 164 208 local login = function(_nickname) 165 209 nickname = _nickname … … 214 258 getCmd = getCmd, getText = getText, quit = quit, login = login, join = join, 215 259 sendMessage = sendMessage, errHandler = errHandler, say = say, broadcast = broadcast, 216 setLogHandler = setLogHandler 260 setLogHandler = setLogHandler, saveChannels = saveChannels, setChannels = setChannels 217 261 } 218 262 -
Scripts/branches/0180_TM_ENHANCE_MUDBOT_QUESTING/Lua/experiments/mudbot/playerCommands.lua
r3225 r3494 25 25 end 26 26 27 playerCommands[" leave"] = function (connection, channel, nick, command, words)27 playerCommands["part"] = function (connection, channel, nick, command, words) 28 28 if operators[nick] ~= nil then 29 29 --connection.leave(words[2]..words[3]) 30 connection.say("This needs fixed! :(") 30 connection.part(words[2]..words[3]) 31 --connection.say("This needs fixed! :(") 32 connection.say("words[2]"..words[2].."words[3]"..words[3]) 33 connection.say("I'm leavin'") 31 34 else 32 35 connection.say("You can't do that!")
