Attachment 'Registration.v2.0.lua'

Download

   1 --//----------------------------------------//--
   2 --//-- Ðåãèñòðàöèÿ v 2.0 (PtokaX > 0.3.6.0d)
   3 --//-- Àâòîð: DestroyNet © 09.10.2007
   4 --//-- Áàçèðóåòñÿ íà ñêðèïòå îò NRJ (22.09.06)
   5 --//----------------------------------------//--
   6 --[[
   7 Âîçìîæíîñòü áëîêèðîâàòü íåçàðåãàíûì ïîèñê/ñêà÷êó/×àò (ïî âûáîðó)
   8 --
   9 Âûáîð ìåòîäà ðåãèñòðàöèè: ñàìîëè÷íàÿ/òðåáóåòñÿ ïîäòâåðæäåíèå Îïåðàòîðà
  10 --
  11 Ïðè îòêàçå â ðåãèñòðàöèè íèêà îïåðàòîð ìîæåò óêàçàòü ïðè÷èíó,
  12 åñëè þçåð óñïåë óéòè ñ õàáà, ïðè÷èíó îòêàçà åìó ïîêàæåò ïðè ñëåäóþùåì çàõîäå
  13 ]]
  14 
  15 
  16 --[[		Êîíôèãóðàöèÿ					]]--
  17 sBot		= ""	-- îñòàâèòü "" ÷òîáû âçÿòü íèê áîòà õàáà
  18 --//----------------------------------------//--
  19 BlockSearch = 1 -- Áëîêèðîâàòü ïîèñê íåçàðåãåñðèðîâàííûì
  20 BlockDL		= 1 -- Áëîêèðîâàòü ñêà÷êó íåçàðåãåñðèðîâàííûì
  21 BlockChat	= 1 -- Áëîêèðîâàòü ÷àò íåçàðåãåñðèðîâàííûì
  22 --//----------------------------------------//--
  23 ShowInfo	= 1	-- ïîçàçûâàòü äîïîëíèòåëüíóþ èíôîðìàöèþ î òîì, êàê ìîæíî èçáåæàòü ïîâòîðíûõ ââîäîâ ïàðîëÿ ïðè âõîäå íà õàá
  24 ShowToAll	= 0	-- ïîêàçûâàòü âñåì ïîëüçîâàòåëÿì, ÷òî íà õàáå íîâûé çàðåãèñòðèðîâàííûé ó÷àñòíèê
  25 --//----------------------------------------//--
  26 RegMode		= 0 -- 1 - Ïîëüçîâàòåëü ìîæåò ñàì çàðåãåñòðèðîâàòüñÿ / 0 - Òðåáóåòüñÿ ïîäòâåðæäåíèå îïåðàòîðà
  27 --//----------------------------------------//--
  28 NeedRegFile	= "Registration.dat"
  29 --//----------------------------------------//--
  30 -- Ñîîáùåíèå ïîêàçûâàåìîå íåçàðåãåñòðèðîâàííûì ïîëüçîâàòåëÿì
  31 rMsg = "\r\n"..
  32 		"\t"..string.rep("«»", 30).."\r\n"..
  33 		"\t\tÂÛ ÍÅ ÇÀÐÅÃÈÑÒÐÈÐÎÂÀÍÛ ÍÀ ÕÀÁÅ ! ! !\r\n"..
  34 		"\t"..string.rep("«»", 30).."\r\n"..
  35 		"\tÍå çàðåãåñòðèðîâàííûì ïîëüçîâàòåëÿì çàïðåùåíû ïîèñê, ñêà÷êà ôàéëîâ è îáùåíèå â ÷àòå\r\n"..
  36 		"\tÄëÿ ðåãèñòðàöèè íà õàáå îòïðàâüòå çàïðîñ îïåðàòîðàì\r\n"..
  37 		"\t\r\n"..
  38 		"\tÏîìîùü ïî ðåãèñòðàöèè: !reghelp\r\n\r\n"..
  39 		"\t"..string.rep("«»", 30)
  40 --//----------------------------------------//--
  41 
  42 --[[	Îñíîâíîé Êîä ñêðèïòà				]]--
  43 --[[	Íå ðåäàêòèðóéòå åñëè íå óâåðåíû		]]--
  44 NeedReg = {}
  45 
  46 na = "n/a"
  47 tShareUnits = {"Á", "ÊÁ", "ÌÁ", "ÃÁ", "ÒÁ", "ÏÁ"}
  48 
  49 tOpPrifiles = {
  50 	[0] = true,
  51 	[1] = true,
  52 }
  53 
  54 function OnStartup()
  55 	sPtokaXsPath = Core.GetPtokaXPath():g("/", "\\")
  56 	sScriptsPath = sPtokaXsPath.."scripts\\"
  57 	if sBot == "" then
  58 		sBot = SetMan.GetString(21)
  59 	end
  60 	if loadfile(sScriptsPath..NeedRegFile) then
  61 		dofile(sScriptsPath..NeedRegFile)
  62 	end
  63 	TmrMan.AddTimer(1000, "ClearMemory")
  64 end
  65 
  66 function DoShareUnits(iSize)
  67 	local iTableSize = #tShareUnits
  68 	iSize = tonumber(iSize)
  69 	local sUnits = ""
  70 	for iTablePos = 1, iTableSize do
  71 		if iSize < 1024 or iTablePos == iTableSize then
  72 			sUnits = tShareUnits[iTablePos]
  73 			break
  74 		else
  75 			iSize = iSize / 1024
  76 		end
  77 	end
  78 	local sSize = string.format("%0.2f %s", iSize, sUnits)
  79 	sSize = string.gsub(sSize, "%.", ",")
  80 	local _,_, s1stChar, s2ndChar = string.find(sSize, "%d+,(%d)(%d)")
  81 	s1stChar, s2ndChar = tonumber(s1stChar), tonumber(s2ndChar)
  82 	if s2ndChar == 0 then
  83 		sSize = string.gsub(sSize, ","..s1stChar..s2ndChar, ","..s1stChar)
  84 		if s1stChar == 0 then
  85 			sSize = string.gsub(sSize, ","..s1stChar, "")
  86 		end
  87 	end
  88 	return sSize
  89 end
  90 
  91 function ClearMemory()
  92 	collectgarbage("collect")
  93 end
  94 
  95 function Return(sData)
  96 	if type(sData) == "function" then
  97 		return sData
  98 	end
  99 	return function()
 100 		return sData
 101 	end
 102 end
 103 
 104 string.g = function(sData, s1, s2)
 105 	return sData:gsub(s1, Return(s2))
 106 end
 107 
 108 function OnExit()
 109 	local hFile = io.open(sScriptsPath..NeedRegFile, "w+")
 110 	Serialize(NeedReg, "NeedReg", hFile)
 111 	hFile:close()
 112 end
 113 
 114 function UserConnected(curUser)
 115 	if curUser.iProfile == -1 then
 116 		if NeedReg[curUser.sNick] then
 117 			if NeedReg[curUser.sNick].Reason ~= "" then
 118 				local tReason = NeedReg[curUser.sNick].Reason
 119 				Core.SendPmToNick(curUser.sNick, sBot, "Âàø çàïðîñ íà ðåãèñòðàöèþ íèêà '"..curUser.sNick.."' áûë îòêëîíåí. Ïðè÷èíà: "..tReason)
 120 				NeedReg[curUser.sNick] = nil
 121 			else
 122 				Core.SendToOpChat("Ïîëüçîâàòåëü "..curUser.sNick.." ("..curUser.sIP..") îæèäàåò ïîäòâåðæäåíèÿ ðåãèñòðàöèè íèêà.\r\n"..
 123 					"Äëÿ ïîäòâåðæäåíèÿ íàïèøèòå: !reguser "..curUser.sNick.."\r\n"..
 124 					"Äëÿ îòêàçà â ðåãèñòðàöèè: !noreg "..curUser.sNick.." <ïðè÷èíà>")
 125 			end
 126 		end			
 127 		Core.SendPmToNick(curUser.sNick, sBot, rMsg)
 128 		Core.SendToUser(curUser, "$UserCommand 1 1 Ðåãèñòðàöèÿ\\Çàðåãèñòðèðîâàòüñÿ$<%[mynick]> !regme %[line:Ââåäèòå ïàðîëü èëè îñòàâüòå ïîëå ïóñòûì]&#124;")
 129 	else
 130 		Core.SendToUser(curUser, "$UserCommand 1 1 Ðåãèñòðàöèÿ\\Ñìåíèòü ïàðîëü$<%[mynick]> !passwd %[line:Ââåäèòå íîâûé ïàðîëü]&#124;")
 131 		Core.SendToUser(curUser, "$UserCommand 1 1 Ðåãèñòðàöèÿ\\Óäàëèòü ðåãèñòðàöèþ$<%[mynick]> !unreg&#124;")
 132 		if tOpPrifiles[curUser.iProfile] then
 133 			for i,v in pairs(NeedReg) do
 134 				if v.Reason == "" then
 135 					Core.SendPmToNick(curUser.sNick, sBot, "Ïîëüçîâàòåëü "..i.." ("..v.IP..") ïîäàë çàïðîñ íà ðåãèñòðàöèþ íèêà.\r\n"..
 136 							(v.AddInfo or "")..
 137 							"Äëÿ ïîäòâåðæäåíèÿ íàïèøèòå: !reguser "..i.."\r\n"..
 138 							"Äëÿ îòêàçà â ðåãèñòðàöèè: !noreg "..i.." <ïðè÷èíà>")
 139 				end
 140 			end
 141 		end
 142 	end
 143 end
 144 RegConnected = UserConnected
 145 OpConnected = UserConnected
 146 
 147 function ChatArrival(curUser, sData)
 148 	Core.GetUserAllData(curUser)
 149 	local sData = string.sub(sData, 1, -2)
 150 	local s,e,cmd =string.find(sData, "%b<>%s+(%S+)")
 151 	if RegMode == 1 then
 152 		if cmd == "!regme" then
 153 			if curUser.iProfile == -1 then
 154 				local s,e,pass = string.find(sData, "%b<>%s+%S+%s+(%S+)")
 155 				if pass == nil then	
 156 					local pass = math.random(os.date("%H%M%S"))
 157 				end
 158 				RegMan.AddReg(curUser.sNick, pass.."", 3)
 159 				Core.SendToUser(curUser, "<"..sBot.."> Âû áûëè çàðåãèñòðèðîâàíû íà õàáå. Âàø íèê:"..curUser.sNick.." Ïàðîëü: "..pass..". Íå çàáóäüòå ïåðåçàéòè íà õàá!")
 160 				if ShowInfo == 1 then
 161 					Core.SendToUser(curUser, "<"..sBot.."> Òåïåðü äëÿ âõîäà íà õàá ïîä âàøèì íèêîì íåîáõîäèìî çíàòü ïàðîëü. Âû ìîæåòå ââîäèòü åãî êàæäûé ðàç âðó÷íóþ, ëèáî ïðîïèñàòü ïàðîëü â íàñòðîéêàõ êëèåíòà. Äëÿ ýòîãî íàéäèòå â ñïèñêå èçáðàííûõ õàáîâ ýòîò õàá, çàéäèòå â åãî ñâîéñòâà è ïðîïèøèòå â ñòðîêàõ Nick è Password âàøè íèê è ïàðîëü.")
 162 				end
 163 				if ShowToAll == 1 then
 164 					Core.SendToAll("<"..sBot.."> Ïðèâåòñòâóåì íîâîãî çàðåãèñòðèðîâàíîãî ó÷àñòíèêà - "..curUser.sNick.." !!!")
 165 				end
 166 			else
 167 				Core.SendToUser(curUser, "<"..sBot.."> Âû óæå çàðåãèñòðèðîâàíû!")
 168 			end
 169 			return true
 170 		end
 171 	else
 172 		if cmd == "!regme" then
 173 			if curUser.iProfile == -1 then
 174 				if NeedReg[curUser.sNick] then
 175 					Core.SendToUser(curUser, "<"..sBot.."> Çàÿâêà íà ðåãèñòðàöèþ íèêà '"..curUser.sNick.."' óæå ðàññìàòðèâàåòñÿ!")
 176 				else
 177 					local s,e,pass = string.find(sData, "%b<>%s+%S+%s+(%S+)")
 178 					if pass == nil then	
 179 						pass = math.random(os.date("%H%M%S"))
 180 					end
 181 					local sAddInfo = "\tØàðà: "..DoShareUnits(Core.GetUserValue(curUser, 16) or 0).."\r\n"..
 182 						"\tÎïèñàíèå: "..(Core.GetUserValue(curUser, 2) or na).."\r\n"..
 183 						"\tEmail: "..(Core.GetUserValue(curUser, 5) or na).."\r\n"..
 184 						"\tÒåã: "..(Core.GetUserValue(curUser, 3) or na).."\r\n"
 185 					NeedReg[curUser.sNick] = {
 186 						Nick = curUser.sNick,
 187 						IP = curUser.sIP,
 188 						Password = pass,
 189 						Reason = "",
 190 						AddInfo = sAddInfo,
 191 					}
 192 					Core.SendToUser(curUser, "<"..sBot.."> Âàøà çàÿâêà íà ðåãèñòðàöèþ íèêà óñïåøíî îòïðàâëåíà.\r\n"..
 193 						"Ïàðàìåòðû çàÿâêè:\r\n"..
 194 						"Íèê: "..curUser.sNick.."\r\n"..
 195 						"Ïàðîëü: "..pass.."\r\n"..
 196 						"Íå çàáóäüòå ýòè äàííûå, ïîñëå ïîäòâåðæäåíèÿ ðåãèñòðàöèè, âû íå ñìîæåòå çàéòè íà õàá ïîä ýòèì íèêîì íåçíàÿ ïàðîëÿ!")
 197 					Core.SendToOpChat("Ïîëüçîâàòåëü "..curUser.sNick.." ("..curUser.sIP..") ïîäàë çàïðîñ íà ðåãèñòðàöèþ íèêà.\r\n"..
 198 						(sAddInfo or "")..
 199 						"Äëÿ ïîäòâåðæäåíèÿ íàïèøèòå: !reguser "..curUser.sNick.."\r\n"..
 200 						"Äëÿ îòêàçà â ðåãèñòðàöèè: !noreg "..curUser.sNick.." <ïðè÷èíà>")
 201 				end
 202 			else
 203 				Core.SendToUser(curUser, "<"..sBot.."> Âû óæå çàðåãèñòðèðîâàíû!")
 204 			end
 205 			return true
 206 		end
 207 	end
 208 	if cmd == "!unreg" then
 209 		if curUser.iProfile ~= -1 then
 210 			RegMan.DelReg(curUser.sNick)
 211 			Core.SendToUser(curUser, "<"..sBot.."> Âàø àêêàóíò áûë áûë óäàëåí")
 212 		else
 213 			Core.SendToUser(curUser, "<"..sBot.."> Êîìàíäà äîñòóïíà òîëüêî äëÿ çàðåãèñòðèðîâàííûõ ïîëüçîâàòåëåé!")
 214 		end
 215 		return true
 216 	elseif cmd == "!reghelp" then
 217 		local hMsg = "\r\n\r\n"..
 218 		"\t"..string.rep("«»", 30).."\r\n"..
 219 		"\t\tÏîìîùü ïî ðåãèñòðàöèè\r\n"..
 220 		"\t"..string.rep("«»", 30).."\r\n\r\n"..
 221 		"\t!reghelp\t\t - Ýòîò ôàéë ïîìîùè\r\n"..
 222 		"\t!regme <ïàññ>\t - Çàðåãèñòðèðîâàòüñÿ (ìîæíî íå óêàçûâàòü ïàññ)\r\n"..
 223 		"\t!passwd <ïàññ>\t - Ñìåíèòü ïàðîëü\r\n"..
 224 		"\t!unreg\t\t - Óäàëèòü àêêàóíò\r\n\r\n"..
 225 		"\tÒàêæå âñå êîìàíäû äîñòóïíû â ìåíþ õàáà:\r\n"..
 226 		"\tÍàæìèòå ïðàâîé êíîïêîé íà çàêëàäêå õàáà\r\n"..
 227 		"\tè âûáèðåòå ïîäìåíþ 'Ðåãèñòðàöèÿ'\r\n"..
 228 		"\t"..string.rep("«»", 30)
 229 		Core.SendPmToNick(curUser.sNick, sBot, hMsg)
 230 		return true
 231 	elseif cmd == "!reguser" then
 232 		if tOpPrifiles[curUser.iProfile] then
 233 			local s,e,rNick = string.find(sData, "%b<>%s+%S+%s+(%S+)")
 234 			if NeedReg[rNick] then
 235 				local pass = NeedReg[rNick].Password
 236 				RegMan.AddReg(rNick, pass.."", 3)
 237 				NeedReg[rNick] = nil
 238 				if Core.GetUser(rNick) then
 239 					Core.SendPmToNick(rNick, sBot, "Âàø çàïðîñ íà ðåãèñòðàöèþ íèêà áûë îäîáðåí.\r\n"..
 240 						"Ïàðàìåòðû çàÿâêè:\r\n"..
 241 						"Íèê:"..rNick.."\r\n"..
 242 						"Ïàðîëü: "..pass..". Íå çàáóäüòå ïåðåçàéòè íà õàá!")
 243 					if ShowInfo == 1 then
 244 						Core.SendToNick(rNick, "<"..sBot.."> Òåïåðü äëÿ âõîäà íà õàá ïîä âàøèì íèêîì íåîáõîäèìî çíàòü ïàðîëü. Âû ìîæåòå ââîäèòü åãî êàæäûé ðàç âðó÷íóþ, ëèáî ïðîïèñàòü ïàðîëü â íàñòðîéêàõ êëèåíòà.\r\n"..
 245 							"Äëÿ ýòîãî íàéäèòå â ñïèñêå èçáðàííûõ õàáîâ ýòîò õàá, çàéäèòå â åãî ñâîéñòâà è ïðîïèøèòå â ñòðîêàõ Nick è Password âàøè íèê è ïàðîëü.")
 246 					end
 247 					if ShowToAll == 1 then
 248 						Core.SendToAll("<"..sBot.."> Ïðèâåòñòâóåì íîâîãî çàðåãèñòðèðîâàíîãî ó÷àñòíèêà - "..rNick.."!")
 249 					end
 250 				end
 251 				Core.SendToOpChat("Çàÿâêà íà ðåãèñòðàöèþ íèêà '"..rNick.."' ïîäòâåðæäåíà. ("..curUser.sNick..")")
 252 			else
 253 				Core.SendToUser(curUser, "<"..sBot.."> Çàÿâêà íà ðåãèñòðàöèþ íèêà '"..rNick.."' íå íàéäåíà.")
 254 			end			
 255 		else
 256 			
 257 		end
 258 		return true
 259 	elseif cmd == "!noreg" then
 260 		if tOpPrifiles[curUser.iProfile] then
 261 			local s,e,rNick,tReason = string.find(sData, "%b<>%s+%S+%s+(%S+)%s+(.*)")
 262 			if NeedReg[rNick] then
 263 				local nrIP = NeedReg[rNick].IP
 264 				local nrPASS = NeedReg[rNick].Password
 265 				NeedReg[rNick].Reason = tReason
 266 				if Core.GetUser(rNick) then
 267 					Core.SendPmToNick(rNick, sBot, "Âàø çàïðîñ íà ðåãèñòðàöèþ íèêà áûë îòêëîíåí. Ïðè÷èíà: "..tReason)
 268 					NeedReg[rNick] = nil
 269 				end
 270 				Core.SendToOpChat("Çàÿâêà íà ðåãèñòðàöèþ íèêà '"..rNick.."' îòâåðãíóòà. Ïðè÷èíà: "..tReason.." ("..curUser.sNick..")")
 271 			else
 272 				Core.SendToUser(curUser, "<"..sBot.."> Çàÿâêà íà ðåãèñòðàöèþ íèêà '"..rNick.."' íå íàéäåíà.")
 273 			end			
 274 		end
 275 		return true
 276 	end
 277 	if BlockChat == 1 and curUser.iProfile == -1 then
 278 		Core.SendToUser(curUser, "<"..sBot.."> Çàðåãåñòðèðóéòåñü äëÿ ïîëó÷åíèÿ âîçìîæíîñòè îáùàòüñÿ â ÷àòå. Ïîìîùü ïî ðåãèñòðàöèè: !reghelp")
 279 		return true
 280 	end
 281 end
 282 
 283 function ConnectToMeArrival(curUser, sData)
 284 	if BlockDL == 1 and curUser.iProfile == -1 then
 285 		Core.SendToUser(curUser, "<"..sBot.."> Çàðåãåñòðèðóéòåñü äëÿ ïîëó÷åíèÿ âîçìîæíîñòè ñêà÷èâàòü ôàéëû")
 286 		return true
 287 	end
 288 end
 289 MultiConnectToMeArrival = ConnectToMeArrival
 290 RevConnectToMeArrival = ConnectToMeArrival
 291 
 292 function SearchArrival(curUser, sData)
 293 	if BlockSearch== 1 and curUser.iProfile == -1 then
 294 		Core.SendToUser(curUser, "<"..sBot.."> Çàðåãåñòðèðóéòåñü äëÿ ïîëó÷åíèÿ âîçìîæíîñòè ïîëüçîâàòüñÿ ïîèñêîì")
 295 		return true
 296 	end
 297 end
 298 SRArrival = SearchArrival
 299 
 300 function Serialize(tTable, sTableName, hFile, sTab)
 301 	sTab = sTab or "";
 302 	hFile:write(sTab..sTableName.." = {\n");
 303 	for key, value in pairs(tTable) do
 304 		if (type(value) ~= "function") then
 305 			local sKey = (type(key) == "string") and string.format("[%q]", key) or string.format("[%d]", key);
 306 			if(type(value) == "table") then
 307 				Serialize(value, sKey, hFile, sTab.."\t");
 308 			else
 309 				local sValue = (type(value) == "string") and string.format("%q", value) or tostring(value);
 310 				hFile:write(sTab.."\t"..sKey.." = "..sValue);
 311 			end
 312 			hFile:write(",\n");
 313 		end
 314 	end
 315 	hFile:write(sTab.."}");
 316 end

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-12-23 18:07:56, 10.4 KB) [[attachment:CleanReg_API2.lua]]
  • [get | view] (2009-12-23 18:59:52, 7.0 KB) [[attachment:RegBot.by.NRJv.1.2_api2.lua]]
  • [get | view] (2009-12-23 18:38:41, 66.5 KB) [[attachment:RegMe_v1.5.lua]]
  • [get | view] (2009-12-23 18:42:58, 12.0 KB) [[attachment:Registration.v2.0.lua]]
  • [get | view] (2009-12-23 17:59:58, 7.9 KB) [[attachment:Registrator_1.00_beta.rar]]
  • [get | view] (2009-12-23 19:19:13, 8.3 KB) [[attachment:_NewAPI_RegBot.zip]]
  • [get | view] (2009-12-23 19:09:47, 4.2 KB) [[attachment:reguser.zip]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.