this is pretty fun... log into the private chat bot with a
new nick.... and chat away anonymously in the private
chat. Based off of another chatbot that was modded a
bunch of times...
-----------------------------------------------------
--//Anonymous Chat Bot v1.0 by ?ottledHat?
--//Formerly know as Chat Bot v3.5 Coded by [aXs] Wellx 01/09-03
--//Formerly known as the Developer-Chat for TIC50
--//Based on the idea VIPChat from Piglja
--//Originaly modded on a request from Dj_OcTaGoN.. then changed a lil more to my own liking... :)
--//Users sign in and give a nick which they chat with in a private chat.
-----------------------------------------------------
saveFile = "Chatters.tbl"
ChatBot = "Hat?-Chat" -- Chat Bot Name
-----------------------------------------------------
ChatArray={}
dofile(saveFile)
function NewUserConnected(user)
OpConnected = NewUserConnected
user:SendData("$MyINFO $ALL "..ChatBot.." Anon-Private Chat... +chat to join +chathelp for cmds$ $PrivateChat9$$999$|")
end
------------------------------------------------------
function DataArrival(user, data)
if (strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
local Commands = (DeveloperCommands(user, data, cmd))
return Commands
elseif strsub(data, 1, 5) == "$To: " then
local s, e, to = strfind(data, "$To: (%S+)")
if to ~= ChatBot then
return 0
else
if to == ChatBot then
local data=strsub(data,1,strlen(data)-1)
local s,e,from,msg = strfind(data,"From:%s+(%S+)%s+$%b<>%s+(.+)")
if ChatArray[user.sName] ~= nil then
for i,v in ChatArray do
Developer=GetItemByName(i)
if (Developer~=nil) then
if i ~= user.sName then
Developer:SendData("$To: "..i.." From: "..ChatBot.." $<"..ChatArray[user.sName].."> "..msg.."|")
end
end
end
return 0
else
user:SendPM(ChatBot,"You do not have permission to chat in here. Type +chat in the main to join.")
end
local _,_,cmd = strfind(data,"$%b<>%s+(%S+)")
local Commands = (DeveloperCommands(user, data, cmd))
end
end
end
end
------------------------------------------------------
function DeveloperCommands(user, data, cmd)
if (cmd == "+chathelp") then
user:SendPM(ChatBot,
"\r\n\r\n"..
"~~ Scripted "..ChatBot.." Commands: ~~\r\n\r\n"..
" +chat - Join or Part from the anonymous sub chat room: "..ChatBot.."\r\n"..
" +showchatters - See witch users that can chat in the "..ChatBot.."\r\n"..
"\r\n")
return 1
elseif (cmd == "+chat") then
local s,e,cmd,ChatName = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
if (ChatName == nil) then
SendPmToNick(user.sName, ChatBot, "This chat is anonymous. Your message will be received by others as the nickname you enter after the !chat command... Please specify a nick.")
end
if ChatArray[user.sName] == nil then
ChatArray[user.sName] = ChatName
for index, value in ChatArray do
SendPmToNick(index, ChatBot, "**** "..ChatArray[user.sName].." Has joined the "..ChatBot.." ****")
end
SendPmToNick(user.sName, ChatBot, "\r\nThis chat is anonymous. Your message will be received by others as: <"..ChatArray[user.sName]..">")
else
for index, value in ChatArray do
SendPmToNick(index, ChatBot, " "..ChatArray[user.sName].." Has left the "..ChatBot)
end
ChatArray[user.sName] = nil
end
SerializeSave(ChatArray, "ChatArray", "")
return 1
elseif (cmd == "+showchatters") then
function DevList()
local DevList = ""
for k, v in ChatArray do
local line = v
if GetItemByName(k) then
if (strlen(k) <= 10) then
DevList = DevList.." ? "..line.."\t\t\t~ On-line ~\r\n"
else
DevList = DevList.." ? "..line.."\t\t~ On-line ~\r\n"
end
else
if (strlen(k) <= 10) then
DevList = DevList.." ? "..line.."\t\t\t? Off-Line ?\r\n"
else
DevList = DevList.." ? "..line.."\t\t? Off-Line ?\r\n"
end
end
end
return DevList
end
user:SendPM(ChatBot, "\r\n\r\n(? ?.??.-> "..ChatBot.." Chatters <-.??.???) \r\n\r\n"..DevList())
return 1
end
end
--------------------------------------------------------
function SaveToFile(file,string)
local f,e = openfile( file, "w+" )
if f then
write(f, string )
closefile(f)
end
end
function SerializeSave(tTable, sTableName, sTab)
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.."={"
local tStart = 0
for key, value in tTable do
if tStart == 1 then
sTmp = sTmp..",\r\n"
else
sTmp = sTmp.."\r\n"
tStart = 1
end
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
end
sTmp = sTmp.."\r\n"..sTab.."}"
SaveToFile(saveFile, sTmp)
end
enjoy...
-BH