BoT for PtokaX --- Need Help !!!
 

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

BoT for PtokaX --- Need Help !!!

Started by juda, 29 December, 2004, 17:55:42

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

juda

Hay to all scripters...!!!
 I need a little help,actuly I need script with 2 important commands for me: KICK  &  WARN......
In PtokaX is already command  !drop ..... but whan you use this command,user dont get any message in chat or in PM for what reason is been kicked or warned.....
I also try other bots that have this commands.(Too big bots & a lot of commands that usrs dont use in my hub).I now running hub with just 4 scripts and I like to have bot that have just   !warn  &  !kick  !!!
Please for option to give bot name ---[WARN BOT]--- and display in hub like other bots ??? Thanks for any help.....

           Have a nice day & happy new year to all...
juda

bolamix

#1
Hi,
Hope this is what you want. I'm sure you would have found it if you had searched for it...
--Requested by Hades
--Made by nErBoS

Bot = "Your-bot-name"

warn = {}
kicked = {}

function Main()
	frmHub:RegBot(Bot)
end

function NewUserConnected(user, data)
	if (warn[user.sName] == 3) then
		user:SendData(Bot, "You're going to be kicked because you had 3 warns.")
		user:TempBan()
		warn[user.sName] = nil
	else
	end
	if (kicked[user.sName] == 3) then
		user:SendData(Bot, "You've had your 3 kicks, now you're banned. Happy?")
		user:Ban()
		user:NickBan()
		kicked[user.sName] = nil
	else
	end
end

OpConnected = NewUserConnected

function DataArrival(user, data)
	if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if (cmd=="!kick") then
			if (user.bOperator) then
				local s,e,usr,reason = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
				if (usr == nil or reason == nil) then
					user:SendData(Bot, "Syntax error: the command must be !kick  , both arguments are mandatory.")
				else
					if (GetItemByName(usr) == nil) then
						user:SendData(Bot, usr.." is not online.")
					else
						local userToBeKicked = GetItemByName(usr)
						SendToAll(Bot, userToBeKicked.sName.." has been kicked by "..user.sName.." because: "..reason)
						userToBeKicked:SendPM(Bot, "You've been kicked by "..user.sName.." because: "..reason)
						if (kicked[userToBeKicked.sName] == nil) then
							kicked[userToBeKicked.sName] = 1
						else
							kicked[userToBeKicked.sName] = kicked[userToBeKicked.sName] + 1
						end
						userToBeKicked:TempBan()
					end
				end
			else
				user:SendData(Bot, "You don?t have permission to use this command.")
			end
			return 1
		elseif (cmd=="!warn") then
			if (user.bOperator) then
				local s,e,usr,reason = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
				if (usr == nil or reason == nil) then
					user:SendData(Bot, "Syntax error, !warn  , must have a nick and reason.")
				else
					if (GetItemByName(usr) == nil) then
						user:SendData(Bot, "The user "..usr.." is not online.")
					else
						local userToBeWarned = GetItemByName(usr)
						userToBeWarned:SendPM(Bot, "You have been warned because: "..reason)
						user:SendData(Bot, "Your warning has been sent.")
						SendToAll(Bot, "User "..userToBeWarned.sName.." was warned by "..user.sName.." because: "..reason)
						if (warn[userToBeWarned.sName] == nil) then
							warn[userToBeWarned.sName] = 1
						else
							warn[userToBeWarned.sName] = warn[userToBeWarned.sName] + 1
						end
						userToBeWarned:Disconnect()
					end
				end
			else
				user:SendData(Bot, "You don?t have permission to use this command.")
			end
			return 1
		end
	end
end

Edit: SyntaxError
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

juda

Thanks...I search,but can get bot in my way...
One question: Is this bot send kick or warn message in chat and PM....look but dont know for shore. ?
If not,please if you can do,that send MSSG in CHAT and PM......thanks

This is the script that I want,but get this error:
Syntax error: expected;
  last token read: `)' at line 46 in file `...Settings\juda\My
Documents\Hubs\PtokaX_0.330_15.25\scripts\warn.lua'

Please for more help.....thanks
juda

bolamix

Hi,

1st question: chat & pm

   SendToAll(Bot, userToBeKicked.sName.." has been kicked by "..user.sName.." because: "..reason) << "SendToAll" sends the message to MainChat
   userToBeKicked:SendPM(Bot, "You've been kicked by "..user.sName.." because: "..reason) << "SendPM" sends the message in PM

2nd question: error at line 46 << typing mistake, fixed in the post above (removed ".." after "reason")
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

juda

Good,now script work,but whan I warn user 1 time is warned in chat and PM that is OK....
but user is also  "disconected" after first warn...
any idea how to repair this?
juda

bastya_elvtars

the whole bot must be rewritten because if it does not disconnect users, the whole thing fails 2 work - quite weird algorythm though... sorry nerbos  :P

use this bot, i just love it and integrated 2 lawmaker:

http://www.plop.nl/ptokaxbots/klownietklowniet/Warning.lua
Everything could have been anything else and it would have just as much meaning.

bolamix

Oops well, sorry about that, I only use the !kick command and have commented out the "warn" parts, and it works as it should for me.
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

juda

I already try this bot...!!! Whan you warn user 3 tim,  user get permanent ban...!!!
Dont want to ban user,just kick by time !!!
I need bot :
On command.....   !warn  - send warning to chat and users PM (You are warn 1 time becouse share.....)
than 2 time...(You are warn 2 time becouse share.....)
When is user warned the 3 time.... - send message to chat and PM (You been warn 3 time,you are now kicked for 30 minutes,becouse.....)
In PtokaX I have set to 30 minutes....Is possible to use this time in script???
In ptokaX is command  !drop , but dont send any reason or text....
                               Thanks
juda

bastya_elvtars

#8
Did a rewrite to this bot when integrated into LawMaker... Hope this fulfills your needs.

-- Date: 13-02-2004 
-- code from klownietklowniet 
-- some small shit by Freed 
-- optimized some by pur 
-- Added regbot, by zinden // made optional by bastya_elvtars
-- fixed security bug introdused by me :-( 
-- gg3k added save function (that was ripped from triviabot :))
-- several tiny fixes and other add-ons by bastya_elvtars

-----<>------ config start

Bot="WarnerBrother" -- lol

maxwarns=3

botinlist=0 -- 0 to disable bot in userlist, 1 to enable

warntime=30 -- bantime in mins

-----<>------ config end

warnings={}

function Main()
LoadWarn()
	if botinlist==1 then
		frmHub:RegBot(Bot)
	end
end

function DataArrival(user,data)
	local returndata
	if strsub(data, 1, 4) == "$To:" then
		data=strsub(data,1,strlen(data)-1)
		-- is this meant for our bot?
		local _,_,whoTo = strfind(data,"$To:%s+(%S+)")
		if (whoTo == Bot) then
			local _,_,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+[%!%+%#](%S+)")
			if cmd  then
				returndata=parsecmds(user,data,strlower(cmd),"PM")
			end
		end
	elseif strsub(data, 1, 1) == "<" then 
		data=strsub(data,1,strlen(data)-1)
		local _,_,cmd = strfind(data,"%b<>%s+[%!%+%#](%S+)")
		if cmd then
			returndata=parsecmds(user,data,strlower(cmd),"MAIN")
		end
	end
	return returndata
end

function dowarn(user,data,env)
		if user.bOperator then
			local _,_,arg,arg2= strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
			if arg then 
				local victim=GetItemByName(arg) 
				if victim and not victim.bOperator then
					if warnings[arg]==nil then 
						warnings[arg]=0 
					end
					if warnings[arg]==(maxwarns - 1) then 
						SendPmToNick(Bot, "This was your last warning. Now have a rest for "..warntime.." mins. ;) // "..user.sName)
						SendToAll(Bot, arg.." could not change his mind ---> we have to go on with 1 user less for "..warntime.." minutes. :P // "..user.sName) 
						victim:TimeBan(warntime)
						--victim:Disconnect() 
						SaveWarn()
						  
					else 
						warnings[arg]=warnings[arg]+1 
						if arg2~=nil then 
							victim:SendPM(Bot,"You have been warned because: "..arg2) 
							SendToAll(Bot, arg.." got his warning #"..warnings[arg]..". Reason: "..arg2.." // "..user.sName) 
							victim:SendPM(Bot, "This is warning #"..warnings[arg]..". Get "..maxwarns.." and you will be banned for "..warntime.." mins...")
						else
							user:SendData(parseenv(user,env,Bot).."No reason specified...")
						end 
						SaveWarn()
					end
				elseif victim and victim.bOperator then
					user:SendData(parseenv(user,env,Bot)..user.sName..", do not warn an operator please.This was your warning #"..maxwarns)
					user:Disconnect()
				elseif arg==Bot then
					user:SendData(parseenv(user,env,Bot).."You cannot warn me! Everything I do is right, agree? This was your warning #"..maxwarns)
					user:Disconnect()
				else
					user:SendData(parseenv(user,env,Bot)..arg.." not online.") 
				end
			else
				user:SendData(parseenv(user,env,Bot).."Hmm, who to warn and why? I'm so busy that I missed. ;)") 
			end
		else
			user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
		end
end

function resetwarn(user,data,env)
		if user.bOperator then
			local _,_,arg = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if arg then 
				if warnings[arg] then
					warnings[arg]=nil 
					user:SendData(parseenv(user,env,Bot)..arg.." - warning(s) deleted.") 
					SaveWarn()
				else
					user:SendData(parseenv(user,env,Bot)..arg.." - not found in the list.") 
				end
			else 
				user:SendData(parseenv(user,env,Bot).."Please specify a nick!") 
			end 
		else 
			user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
		end
end

function SaveWarn()
	local handle = openfile("warned.dat", "w")
		for index, value in warnings do
			write(handle,index.."|"..value.."\r\n")
		end
	closefile(handle)
end

function LoadWarn()
	local handle = openfile("warned.dat", "r")
	if (handle) then
		local line = read(handle)
		while line do
			local arrTmp = tokenize(line, "|")
			if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then
				warnings[arrTmp[1]] = tonumber(arrTmp[2])
			end
			line = read(handle)
		end
		closefile(handle)
	end
end

function tokenize (inString,token)
	_WORDS = {}
	local matcher = "([^"..token.."]+)"
	gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
	return _WORDS
end

function parsecmds(user,data,cmd,env)
	local commandtable={
							["warn"]={dowarn,{user,data,env}},
							["resetwarn"]={resetwarn,{user,data,env}}	}
	if commandtable[cmd] then
		call (commandtable[cmd][1],commandtable[cmd][2])
		return 1
	end
end

function parseenv(user,env,bot)
	if env=="PM" then
		return "$To: "..user.sName.." From: "..bot.." $<"..bot.."> "
	elseif env=="MAIN" then
		return "<"..bot.."> "
	end
end
Everything could have been anything else and it would have just as much meaning.

juda

Finaly.....thanks to this script !!!
I already tested bot and work good...
I just want to warn you for a little mistake in your script....
Before I repair this,script didnt work.....Watch out in the start of the script:
-----<>------ config start

Bot="WarnerBrother" -- lol

mawarns=3

botinlist=0 -- 0 to disable bot in userlist, 1 to enable

warntime=30 -- bantime in mins

-----<>------ config end

The mistake is in 2 row....(mawarns=3)  --- it must be (maxwarns=3).....whan I repair this,script work....

    Thanks again......
juda

juda

Discover another row to repair.....
The path to the file,whare warns will be saved !!!
---------------------------------------------------------------
function SaveWarn()
   local handle = openfile("lawmaker/dats/warned.dat", "w")
      for index, value in warnings do
         write(handle,index.."|"..value.."\r\n")
      end
   closefile(handle)
end
----------------------------------------------------------------
You must change the path.....lawmaker/dats/warned.dat    to your own  dats/warned.dat    or  data/warned.dat    or .....

 NOW WORK !!! I hope....  By from SLOVENIJA
juda

bastya_elvtars

lol sorry for those 2 errors i am sick for 2 weeks now and really wasted

but atleast you practised lua ;)

im glad i could help
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk