Screwed with RegBot
 

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

Screwed with RegBot

Started by Znupi, 11 June, 2006, 21:56:07

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Znupi

I tryed to make a regbot ... and it works just fine except for one thing ... here's the code:
--[[

				...ooO::: ReG BoT bY ZnuPi :::Ooo...

]]--

---------------------------- [ Here-The-ScriPt-StartS ] ----------------------------

Bot = frmHub:GetHubBotName()		--Don't mess with this
OpChat = frmHub:GetOpChatName()		--Neither with this
prefix = "!"				--Prefix you want users to use, example: if prefix = "!", they will use !regme <pass>, if prefix is "@", they will use @regme <pass>
regpref = "[Znup.Member]"		--Prefix of nick required for a user to register, change to "" for any prefix
regnr = 3				--Auto-detects, better not mess with this


function NewUserConnected(user)
	if (user.bRegistered == nil) then
		if (string.sub(user.sName,1,string.len(regpref)) ~= regpref) then
			user:SendData(Bot,"If you want to reg yourself, set your nick prefix to "..regpref)
			user:SendData("$UserCommand 1 1 Reg Help $<%[mynick]> "..prefix.."rhelp&#124;|")
		else
			user:SendData(Bot,"\r\nYou have the prefix required to get regged! Don't miss this oportunity!\r\n"..
					"You may use right-click commands to get regged, or use "..prefix.."regme <pass>")
			user:SendData("$UserCommand 1 1 Get ReggeD $<%[mynick]> "..prefix.."regme %[line:Password]&#124;|")
		end
	else
		user:SendData(Bot,"\r\nWelcome regged user "..user.sName.." !\r\n"..
				"To get unregged use right-click commands or type "..prefix.."unregme")
		user:SendData("$UserCommand 1 1 Get UnReggeD $<%[mynick]> "..prefix.."unregme&#124;|")
	end
end


function ChatArrival(user,data)
	data = string.sub(data,1,string.len(data)-1)
	s,e,cmd = string.find(data,"%s+(%S+)")
	if (cmd == prefix.."regme") then
		if (user.bRegistered and user.bOperator == nil) then
			user:SendData(Bot,"Dude, ur already regged!")
			return 1
		end
		if (user.bOperator) then
			user:SendData(Bot,"Dude, ur an OP !")
			return 1
		end
	if (string.sub(user.sName,1,string.len(regpref)) ~= regpref) then
		user:SendData(Bot,"First, you have to set your nick prefix to "..regpref)
		return 1
	end
	local i = 0
	CheckReg()
	s,e,cmd,pass = string.find(data,"%s+(%S+)%s+(.*)")
	user:SendData(Bot,"Pass: "..pass)
	AddRegUser(user.sName,pass,regnr)
	SendPmToOps(OpChat,"\r\n\r\n\t"..string.rep("=",7).."R-E-G"..string.rep("=",7).."\r\n\r\n"..
				"\tUser: "..user.sName.."\r\n\r\n"..
				"\tIP: "..user.sIP.."\r\n\r\n"..
				"\tPassword: "..pass.."\r\n\r\n"..
				"\t"..string.rep("=",7).."R-E-G"..string.rep("=",7).."\r\n\r\n")
	user:SendPM(Bot,"\r\n\r\n\t"..string.rep("=",5).."? [ You haVe been reGGeD ]? "..string.rep("=",5).."\r\n\r\n"..
				"\t[ Profile Information ]\r\n\r\n"..
				"\tNick: "..user.sName.."\r\n\r\n"..
				"\tPassword: "..pass.."\r\n\r\n"..
				"\t[ BeTTer WriTe ThiS DoWn ;) ]\r\n\r\n"..
				"\t"..string.rep("=",5).."? [ You haVe been reGGeD ]? "..string.rep("=",5))
	return 1
	end
	if (cmd == prefix.."unregme") then
		DelRegUser(user.sName)
		user:SendPM(Bot,"\r\n\r\n\t\t\t"..string.rep("[=]",5).."? ?[ Your accounT haS beeN DeleteD ]? ?"..string.rep("[=]",5))
		SendPmToOps(OpChat,"\r\n\r\n\t"..string.rep("=",7).."U-N-R-E-G"..string.rep("=",7).."\r\n\r\n"..
					"\tUser: "..user.sName.."\r\n\r\n"..
					"\tIP: "..user.sIP.."\r\n\r\n"..
					"\t"..string.rep("=",7).."U-N-R-E-G"..string.rep("=",7).."\r\n\r\n")
		return 1
	end
	if (cmd == prefix.."rhelp") then
		user:SendData(Bot,"\r\n\r\nHow to get regged to this hub:\r\n"..
				"\t1)Add this hub to your favorites by typing /fav\r\n"..
				"\t2)Go to your favorite hubs list, right-click this one, choose Properties and change your nick to one with the prefix "..regpref.."\r\n"..
				"\t3)Reconnect to the hub\r\n"..
				"\t4)Use Right-click commands to register or type !regme <pass> to get regged with your desired password\r\n")
		return 1
	end
end

function CheckReg()
	if (GetProfileName(regnr) ~= "Reg") then
		while (GetProfileName(i)) do
			if (GetProfileName(i)=="Reg") then
				regnr = i
				i = i + 1
				return 1
			end
		end
	end
end

---------------------------- [ Here-The-ScriPt-EndS ] ----------------------------

The CheckReg() function doesn't work ... if I set regnr to 2 by default ... the users get regged as VIP ...
Two questions : Is it necessary to make this checking, is the default number going to be 3 all the time ?
Where have I gone wrong? ;D

Oh, and ... another thing ... I do know my string.find is bad ... but it works ...

Rincewind

In PtokaX a registered user always has a profile number of 3.

The full listing of profiles is;
      -1 = unreg
       3 = reg
       2 = VIP
       1 = operator
       0 = master

Some scripts like Robocop and Grimoire also use;
       4 = moderator
       5 = net founder

Znupi

So I can lose the CheckReg() function, thanks.

bastya_elvtars

Quote from: Znupi on 11 June, 2006, 22:28:52
So I can lose the CheckReg() function, thanks.

The less function calls, the better. Separate functions should only be declared if used frequently.
Everything could have been anything else and it would have just as much meaning.

Markitos

BTW u need to register the bot in the userlist to send Pm msgs...

Psycho_Chihuahua

Quote from: Markitos on 12 June, 2006, 09:34:08
BTW u need to register the bot in the userlist to send Pm msgs...

If he is using
Bot = frmHub:GetHubBotName()
not necessarily (well if HubBot is already registered he doesn't have to - otherwise your right)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Znupi

The Hub Bot is registered, otherwise I would have registered it. ;D

Markitos

Quote from: Psycho_Chihuahua on 12 June, 2006, 12:42:53
Quote from: Markitos on 12 June, 2006, 09:34:08
BTW u need to register the bot in the userlist to send Pm msgs...

If he is using
Bot = frmHub:GetHubBotName()
not necessarily (well if HubBot is already registered he doesn't have to - otherwise your right)
Silly me  ;D

SMF spam blocked by CleanTalk