one more Multi-Function Bot needed
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

one more Multi-Function Bot needed

Started by D-J Valhala, 25 July, 2004, 23:19:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

D-J Valhala

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
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

NightLitch

#1
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
//NL

kepp

#2
What happens when you hide any of the bots and reconnect?
Guarding    

NightLitch

QuoteOriginally posted by kepp
What happens when you hide any of the bots and reconnect?

eh, nothing ? or what happens... ?
//NL

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
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

NightLitch

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
//NL

D-J Valhala

have't test it yet  :)
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

NightLitch

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
//NL

D-J Valhala

nope not working and i like the profix will bw "+"  :D
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

kepp

Ah nevermind, Too fast on reply button, Missread
Guarding    

NightLitch

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
//NL

SMF spam blocked by CleanTalk