I saw the script NightLitch wrote for Master chat, Op\Master chat (which i use now....well done! ), and was really needing a "Topic Chat" bot that would enable "all" members on the hub to come in and chat about the Hub topics. This would keep the Main chat cleaned up a bit. This is probably pretty simple for some of u guys. I'm still learning little by little, although I am smart enough to see that this is the board to hang out on for the PtokaX hub!!
I dont know if the channel bot has anything like this or not, was really needing just a standalone script for this. Basically a second chat that everyone has access to , to go in and discuss the topics and news in the hub.
Thnx alot for all you guys help.
QuoteOriginally posted by XPMAN
I dont know if the channel bot has anything like this or not, was really needing just a standalone script for this. Basically a second chat that everyone has access to , to go in and discuss the topics and news in the hub.
Thnx alot for all you guys help.
Hope this helps :) try the code see if its what u want
-- Taken from LUA boards
-- slightly modified by Stravides
bots = {}
function Main()
loadchat()
for name, users in bots do
frmHub:RegBot(name)
end
-- Unload Perm Rooms (ie the chat room you require)
frmHub:UnregBot("RPG_SCAN_REQUESTS")
-- ReLoad Perm Rooms (ie the chat room you require)
frmHub:RegBot("RPG_SCAN_REQUESTS")
end
function OnExit()
savechat()
end
function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)|$")
if cmd == "mkchat" and user.bOperator then mkchat(user, args) return 1 end
elseif strsub(data, 1, 4) == "$To:" then
local s, e, to, str = strfind(data, "^$To: (%S+) From: %S+ $%b<> (.*)|$")
if bots[to] then
local isowner = user.sName == bots[to][1]
local s, e, cmd, args = strfind(str, "^%!(%a+)%s*(.*)$")
if cmd == "members" then members(user, to)
elseif cmd == "delchat" and isowner then delchat(user, to)
else dochat(to, user.sName, str) end
end
end
end
function loadchat()
bots = dofile("chatrooms.dat") or {}
end
function savechat()
local f = openfile("chatrooms.dat", "w+")
assert(f, "chatrooms.dat")
write(f, "return {\n")
for name, users in bots do
write(f, "\t"..format("[%q]", name).." = { ")
for i = 1, getn(users) do write(f, format("%q", users
)..", ") end
write(f, "},\n")
end write(f, "}") closefile(f)
end
function dochat(to, from, str)
local users = bots[to]
for i = 1, getn(users) do
local nick = users
if nick ~= from then SendToNick(nick, "$To: "..nick.." From: "..to.." $<"..from.."> "..str) end
end
end
function mkchat(user, args)
local s, e, name, members = strfind(args, "(%S+)%s*(.*)")
if not s then user:SendData(">> syntax: !mkchat [userlist]") return end
if bots[name] then user:SendData(">> "..name.." belongs to "..bots[name][1]) return end
frmHub:RegBot(name) bots[name] = { user.sName }
invite(user, members, name) dochat(name, name, "hello")
end
function delchat(user, to)
dochat(to, to, "Thanks for Using Chatrooms")
frmHub:UnregBot(to)
bots[to] = nil
end
function members(user, to)
local users = bots[to]
for i = 1, getn(users) do user:SendPM(to, i..". "..users) end
end
function tfind(table, item)
for key, value in table do
if value == item then return key end
end
end
couldn't get it to work properly. had to substitute the Topic_Chat for the bot name. Still wouldn't work. Don't know whats wrong. Any more ideas?
To activate i just right clicked and sent pm to bot. This is correct right?
here this one is from tezlo
he is one terrific scripter that does not
put his name on this script so i added
credits to him, that is the only
change,
--created by tezlo
bots = {}
function Main()
loadchat()
for name, users in bots do
frmHub:RegBot(name)
end
end
function OnExit()
savechat()
end
function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)|$")
if cmd == "mkchat" and user.bOperator then mkchat(user, args) return 1 end
elseif strsub(data, 1, 4) == "$To:" then
local s, e, to, str = strfind(data, "^$To: (%S+) From: %S+ $%b<> (.*)|$")
if bots[to] then
if not tfind(bots[to], user.sName) then
user:SendPM(to, "youre not a member here") return
end
local isowner = user.sName == bots[to][1]
local s, e, cmd, args = strfind(str, "^%!(%a+)%s*(.*)$")
if cmd == "leave" then leave(user, to)
elseif cmd == "members" then members(user, to)
elseif cmd == "delchat" and isowner then delchat(user, to)
elseif cmd == "invite" and isowner then invite(user, args, to)
elseif cmd == "remove" and isowner then remove(user, args, to)
else dochat(to, user.sName, str) end
end
end
end
function loadchat()
bots = dofile("chatrooms.dat") or {}
end
function savechat()
local f = openfile("chatrooms.dat", "w+")
assert(f, "chatrooms.dat")
write(f, "return {\n")
for name, users in bots do
write(f, "\t"..format("[%q]", name).." = { ")
for i = 1, getn(users) do write(f, format("%q", users[i])..", ") end
write(f, "},\n")
end write(f, "}") closefile(f)
end
function dochat(to, from, str)
local users = bots[to]
for i = 1, getn(users) do
local nick = users[i]
if nick ~= from then SendToNick(nick, "$To: "..nick.." From: "..to.." $<"..from.."> "..str) end
end
end
function mkchat(user, args)
local s, e, name, members = strfind(args, "(%S+)%s*(.*)")
if not s then user:SendData(">> syntax: !mkchat [userlist]") return end
if bots[name] then user:SendData(">> "..name.." belongs to "..bots[name][1]) return end
frmHub:RegBot(name) bots[name] = { user.sName }
invite(user, members, name) dochat(name, name, "hello")
end
function delchat(user, to)
dochat(to, to, "bye bye")
frmHub:UnregBot(to)
bots[to] = nil
end
function leave(user, to)
local id = tfind(bots[to], user.sName)
if id == 1 then user:SendPM(to, "you cant")
else dochat(to, to, user.sName.." has left the room") tremove(bots[to], id) end
end
function members(user, to)
local users = bots[to]
for i = 1, getn(users) do user:SendPM(to, i..". "..users[i]) end
end
function invite(user, args, to)
local n = 0
gsub(args, "(%S+)", function(nick)
local tmp, bool = GetItemByName(nick), tfind(bots[%to], nick)
if tmp and not bool then
tinsert(bots[%to], nick)
dochat(%to, %to, nick.." has been invited to the room")
end
end)
end
function remove(user, args, to)
gsub(args, "(%S+)", function(nick)
local id = tfind(bots[%to], nick)
if id and id ~= 1 then
dochat(%to, %to, nick.." has been removed from the room")
tremove(bots[%to], id)
end
end)
end
function tfind(table, item)
for key, value in table do
if value == item then return key end
end
end--------------------------------------------------------------------------------
ah thanx :)
one more quick fix.. on TD4 chatrooms didnt get saved for the same reason as goodpoints
so now they do
bots = {}
function Main()
loadchat()
for name, users in bots do
frmHub:RegBot(name)
end
end
function OnExit()
savechat()
end
function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)|$")
if cmd == "mkchat" and user.bOperator then mkchat(user, args) return 1 end
elseif strsub(data, 1, 4) == "$To:" then
local s, e, to, str = strfind(data, "^$To: (%S+) From: %S+ $%b<> (.*)|$")
if bots[to] then
if not tfind(bots[to], user.sName) then
user:SendPM(to, "youre not a member here") return
end
local isowner = user.sName == bots[to][1]
local s, e, cmd, args = strfind(str, "^%!(%a+)%s*(.*)$")
if cmd == "leave" then leave(user, to)
elseif cmd == "members" then members(user, to)
elseif cmd == "delchat" and isowner then delchat(user, to)
elseif cmd == "invite" and isowner then invite(user, args, to)
elseif cmd == "remove" and isowner then remove(user, args, to)
else dochat(to, user.sName, str) end
end
end
end
function loadchat()
bots = dofile("chatrooms.dat") or {}
end
function savechat()
local f = openfile("chatrooms.dat", "w+")
assert(f, "chatrooms.dat")
write(f, "return {\n")
for name, users in bots do
write(f, "\t"..format("[%q]", name).." = { ")
for i = 1, getn(users) do write(f, format("%q", users[i])..", ") end
write(f, "},\n")
end write(f, "}") closefile(f)
end
function dochat(to, from, str)
local users = bots[to]
for i = 1, getn(users) do
local nick = users[i]
if nick ~= from then SendToNick(nick, "$To: "..nick.." From: "..to.." $<"..from.."> "..str) end
end
end
function mkchat(user, args)
local s, e, name, members = strfind(args, "(%S+)%s*(.*)")
if not s then user:SendData(">> syntax: !mkchat [userlist]") return end
if bots[name] then user:SendData(">> "..name.." belongs to "..bots[name][1]) return end
frmHub:RegBot(name) bots[name] = { user.sName }
invite(user, members, name) dochat(name, name, "hello")
savechat()
end
function delchat(user, to)
dochat(to, to, "bye bye")
frmHub:UnregBot(to)
bots[to] = nil
savechat()
end
function leave(user, to)
local id = tfind(bots[to], user.sName)
if id == 1 then user:SendPM(to, "you cant")
else dochat(to, to, user.sName.." has left the room") tremove(bots[to], id) savechat() end
end
function members(user, to)
local users = bots[to]
for i = 1, getn(users) do user:SendPM(to, i..". "..users[i]) end
end
function invite(user, args, to)
local n = 0
gsub(args, "(%S+)", function(nick)
local tmp, bool = GetItemByName(nick), tfind(bots[%to], nick)
if tmp and not bool then
tinsert(bots[%to], nick)
dochat(%to, %to, nick.." has been invited to the room")
end
end) savechat()
end
function remove(user, args, to)
gsub(args, "(%S+)", function(nick)
local id = tfind(bots[%to], nick)
if id and id ~= 1 then
dochat(%to, %to, nick.." has been removed from the room")
tremove(bots[%to], id)
end
end) savechat()
end
function tfind(table, item)
for key, value in table do
if value == item then return key end
end
end
heres a simple mod that could suit you XPMAN..
any user who goes chatting becomes a member and is removed on disconnect
that way people dont get bothered with PMs they dont want to receive :)
bots = {}
function Main()
loadchat()
for name, users in bots do
frmHub:RegBot(name)
end
end
function OnExit()
savechat()
end
function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)|$")
if cmd == "mkchat" and user.bOperator then mkchat(user, args) return 1 end
elseif strsub(data, 1, 4) == "$To:" then
local s, e, to, str = strfind(data, "^$To: (%S+) From: %S+ $%b<> (.*)|$")
local users = s and bots[to]
if users then
if not tfind(users, user.sName) then
tinsert(users, user.sName) savechat()
dochat(to, to, user.sName.." has entered the room")
end
local isowner = user.sName == users[1]
local s, e, cmd, args = strfind(str, "^%!(%a+)%s*(.*)$")
if cmd == "leave" then leave(user, to)
elseif cmd == "members" then members(user, to)
elseif cmd == "delchat" and isowner then delchat(user, to)
elseif cmd == "invite" and isowner then invite(user, args, to)
elseif cmd == "remove" and isowner then remove(user, args, to)
else dochat(to, user.sName, str) end
end
end
end
function UserDisconnected(user)
for name, users in bots do
local id = tfind(users, user.sName)
if id and id ~= 1 then tremove(users, id) end
end
end
function loadchat()
bots = dofile("chatrooms.dat") or {}
end
function savechat()
local f = openfile("chatrooms.dat", "w+")
assert(f, "chatrooms.dat")
write(f, "return {\n")
for name, users in bots do
write(f, "\t"..format("[%q]", name).." = { ")
for i = 1, getn(users) do write(f, format("%q", users[i])..", ") end
write(f, "},\n")
end write(f, "}") closefile(f)
end
function dochat(to, from, str)
local users = bots[to]
for i = 1, getn(users) do
local nick = users[i]
if nick ~= from then SendToNick(nick, "$To: "..nick.." From: "..to.." $<"..from.."> "..str) end
end
end
function mkchat(user, args)
local s, e, name, members = strfind(args, "(%S+)%s*(.*)")
if not s then user:SendData(">> syntax: !mkchat [userlist]") return end
if bots[name] then user:SendData(">> "..name.." belongs to "..bots[name][1]) return end
frmHub:RegBot(name) bots[name] = { user.sName }
invite(user, members, name) dochat(name, name, "hello")
savechat()
end
function delchat(user, to)
dochat(to, to, "bye bye")
frmHub:UnregBot(to)
bots[to] = nil
savechat()
end
function leave(user, to)
local id = tfind(bots[to], user.sName)
if id == 1 then user:SendPM(to, "you cant")
else dochat(to, to, user.sName.." has left the room") tremove(bots[to], id) savechat() end
end
function members(user, to)
local users = bots[to]
for i = 1, getn(users) do user:SendPM(to, i..". "..users[i]) end
end
function invite(user, args, to)
local n = 0
gsub(args, "(%S+)", function(nick)
local tmp, bool = GetItemByName(nick), tfind(bots[%to], nick)
if tmp and not bool then
tinsert(bots[%to], nick)
dochat(%to, %to, nick.." has been invited to the room")
end
end) savechat()
end
function remove(user, args, to)
gsub(args, "(%S+)", function(nick)
local id = tfind(bots[%to], nick)
if id and id ~= 1 then
dochat(%to, %to, nick.." has been removed from the room")
tremove(bots[%to], id)
end
end) savechat()
end
function tfind(table, item)
for key, value in table do
if value == item then return key end
end
end
the commands you need are described here (http://board.univ-angers.fr/thread.php?threadid=518&boardid=12&sid=619403621a28113479472dc2fcaa463b#1)
Thank u,thank u, thank u, thank u, thank u ,thank u............very nicely done!!! Exactly what i was looking for.
O, thank u !!