PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: D-J Valhala on 25 July, 2004, 23:19:29

Title: one more Multi-Function Bot needed
Post by: D-J Valhala on 25 July, 2004, 23:19:29
here we go  :D
========================================
+onopchat                    -       Show Op-Chat

+onvipchat                   -       Show ViP-Chat

+offopchat                    -       Dont Show Op-Chat

+offvipchat                   -       Dont Show ViP-Chat

+protectuser     -        Protect a user from
+kick/+kill

+unprotect        -        Remove user from
protection

+vipprotecton               -       Protect ViP's From +kick/+kill

+vipprotectoff               -       OP Can +kick/+kill ViP

+svipprotecton              -      Protect SuperViP's From
+kick/+kill

+svipprotectoff              -      OP Can kick/+kill SuperViP
========================================
thanks :P
Title:
Post by: NightLitch on 26 July, 2004, 02:23:35
not tested at all just a quick set in pieces bot, but plz try it:

-----------------------------------------------------------
-- D-J Valhala Request on Multi Purpose Bot
-- By: NightLitch
-----------------------------------------------------------
-- Multi Prefixes
-- onopchat - Show Op-Chat
-- onvipchat - Show ViP-Chat
-- offopchat - Dont Show Op-Chat
-- offvipchat - Dont Show ViP-Chat
-- protect - Protects user from kick/kill commands ( user, vip, supervip )
-- unprotect - Remove user from protection ( user, vip, supervip )
-----------------------------------------------------------
OpChatName = "-OpChat-"
VipChatName = "-VipChat-"

ProtectFile = "ProtectedUsers.log"

Protect = {
User = {},
VIP = {},
SuperVIP = {},
}

function Main()
LoadFile(ProtectFile)
end

function DataArrival(sUser,sData)
if strsub(sData, 1,1) == "<" then
sData=strsub(sData,1,strlen(sData)-1)
local _,_,prefix,cmd,arg=strfind(sData, "%b<>%s+(%S)(%S+)%s*(.*)")
if prefix then
if cmd == "opchat" then
_,_,set = strfind(arg, "(%w+)")
if set==nil then SendToNick(sUser.sName, "Syntax: !"..cmd.." ") return 1
elseif strlower(set)=="on" then
frmHub:RegBot(OpChatName) SendToNick(sUser.sName, "OP-Chat has been Set ON.") return 1
elseif strlower(set)=="off" then
frmHub:UnregBot(OpChatName) SendToNick(sUser.sName, "OP-Chat has been Set OFF.") return 1
end
elseif cmd == "vipchat" then
_,_,set = strfind(arg, "(%w+)")
if set==nil then SendToNick(sUser.sName, "Syntax: !"..cmd.." ") return 1
elseif strlower(set)=="on" then
frmHub:RegBot(VipChatName) SendToNick(sUser.sName, "VIP-Chat has been Set ON.") return 1
elseif strlower(set)=="off" then
frmHub:UnregBot(VipChatName) SendToNick(sUser.sName, "VIP-Chat has been Set OFF.") return 1
end
elseif cmd == "protect" then
_,_,lvl,user = strfind(arg, "(%w+)%s+(%S+)")
if user==nil or lvl==nil then SendToNick(sUser.sName, "Syntax: !"..cmd.." ") return 1 end
local Level = nil
if strfind(lvl)=="user" then Level = User
elseif strfind(lvl)=="vip" then Level = VIP
elseif strfind(lvl)=="supervip" then Level = SuperVIP
else SendToNick(sUser.Name, lvl.." is not a valid profile level") return 1 end
if Protect.Level[user]==nil then
Protect.Level[user] = 1
SaveFile(Protect , "Protect", ProtectFile)
SendToNick(sUser.sName, tostring(Level)..": "..user.." have been added to Protect List") return 1
else
SendToNick(sUser.sName, tostring(Level)..": "..user.." is all ready in Protect List") return 1
end
elseif cmd == "unprotect" then
_,_,lvl,user = strfind(arg, "(%w+)%s+(%S+)")
if user==nil or lvl==nil then SendToNick(sUser.sName, "Syntax: !"..cmd.." ") return 1 end
local Level = nil
if strfind(lvl)=="user" then Level = User
elseif strfind(lvl)=="vip" then Level = VIP
elseif strfind(lvl)=="supervip" then Level = SuperVIP
else SendToNick(sUser.Name, lvl.." is not a valid profile level") return 1 end
if Protect.Level[user]==1 then
Protect.Level[user] = nil
SaveFile(Protect , "Protect", ProtectFile)
SendToNick(sUser.sName, tostring(Level)..": "..user.." have been removed from Protect List") return 1
else
SendToNick(sUser.sName, tostring(Level)..": "..user.." is not in Protect List") return 1
end
elseif cmd=="kick" or cmd=="kill" then
local _,_,user = strfind(arg, "(%S+)%s+.*")
if user then
if Protect.User[user]==1 or Protect.VIP[user]==1 or Protect.SuperVIP[user]==1 then
SendToNick(sUser.sName, user.." is protected from kicks and kills!!") return 1
end
end
end
end
end
end

function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
write(hFile, sTab..sTableName.." = {\n" );
for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
write(hFile, sTab.."\t"..sKey.." = "..sValue);
end
write(hFile, ",\n");
end
write(hFile, sTab.."}");
end

function SaveFile(table , tablename, file)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end

function LoadFile(file)
assert(readfrom(file),file.." is not found.")
dostring(read("*all"))
readfrom()
end

hope it works with the kick/kill

/NL
Title:
Post by: kepp on 26 July, 2004, 09:34:50
What happens when you hide any of the bots and reconnect?
Title:
Post by: NightLitch on 26 July, 2004, 11:53:53
QuoteOriginally posted by kepp
What happens when you hide any of the bots and reconnect?

eh, nothing ? or what happens... ?
Title:
Post by: D-J Valhala on 26 July, 2004, 12:11:24
i would like it so if i type +offvipchat ONLY me will not see the chat everybode else can see it but if someone else type +offvipchat he wont see it and with op-chat to  :D
Title:
Post by: NightLitch on 26 July, 2004, 12:13:43
QuoteOriginally posted by D-J Valhala
i would like it so if i type +offvipchat ONLY me will not see the chat everybode else can see it but if someone else type +offvipchat he wont see it and with op-chat to  :D

that I think, can't be done m8.. BUt gonna fix so only Operators can handle the commands... forgot that...

Does the script work btw ??

/NL
Title:
Post by: D-J Valhala on 26 July, 2004, 12:19:11
have't test it yet  :)
Title:
Post by: NightLitch on 26 July, 2004, 12:20:39
QuoteOriginally posted by D-J Valhala
have't test it yet  :)

lol, then plz do so I now if I should continue this little piece of just leave it  :P
Title:
Post by: D-J Valhala on 26 July, 2004, 13:38:48
nope not working and i like the profix will bw "+"  :D
Title:
Post by: kepp on 26 July, 2004, 17:11:21
Ah nevermind, Too fast on reply button, Missread
Title:
Post by: NightLitch on 26 July, 2004, 21:08:10
QuoteOriginally posted by D-J Valhala
nope not working and i like the profix will bw "+"  :D

k gonna take a look at it myself then when I get the time...

/NL