error regbot - Page 2
 

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

error regbot

Started by gizmo, 08 February, 2004, 21:31:38

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nErBoS

Hi,

The function seems alright to me. The error must be from another think, can you post here the script ??

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

#26
Umm... its about 1200 lines of code so im gonna cut it down to only the part that im working on.

--Sk-BoT Created for the Snooze's Keep Hub by Snooze [URL]http://www.snooze.no-ip.com/sk/[/URL]
--Credit goes to all the friendly people at The LUA Script Board [URL]http://board.univ-angers.fr[/URL]
--Special thanks to:
--(uk-kingdom)pH?tt? for his 9step lua manual and the Mail code
--plop for helping me figure out the mail code 
--nErBoS for help on read/write/delete .txt files
--And to DamionNH for ever getting me started ;-)

Bot = "?SK-BoT?"
descr = "...::: Snooze's Keep Internal Network :::..."   -- Set Description
mb = 1 * 1024              -- Bot Share ( 0 share )
speed = "SnoozeSpeed"                       -- set speed here 
size = 1 * 1024 * mb
email = "bot@bot.com"            -- Set Email addy
info = "$MyINFO $ALL "..Bot.." "..descr.."$ $"..speed..strchar( 1 ).."$"..email.."$"..size.."$" 


sOplog = "skbot/sktxtfiles/oplog.txt" -- In script/txtfiles/ folder
sBigshare = "skbot/sktxtfiles/invite.txt" -- Msg to bigshare users ..


prefix = "!"
trigger = "skbot"
BigShare = 50 -- In GB
SendC = SendToAll
SendP = SendPmToAll


function Main() 
	frmHub:RegBot(Bot)
end 

function GetTime()
	s = date("%S")
	h = date("%H")
	m = date("%M")
	d = date("%d")
	mm = date("%m")
	y = date("%y")
	Date = "Day: "..d.."/"..mm.."/20"..y.." Hour: "..h..":"..m..":"..s
	return Date
end

function NewUserConnected(user)
    if not(GetProfileName(user.iProfile) == "Reg" or GetProfileName(user.iProfile) == "Vip") then
	s,e,share = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)")
	share = share / (1024*1024*1024)
	if (share >= BigShare) then
	Readtextfile(user, sBigshare)
	end
    end
  SendToAll( info ) 
end 

function OpConnected(user)
  SendC( info ) 
end

function DataArrival(user,data)
	if strsub(data, 1, 1) == "<" or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
		local data=strsub(data,1,strlen(data)-1) 
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")
	  if cmd == (trigger) then 
	    user:SendPM(Bot, "Welcome to SK-BoT. Type !skhelp too see commands available to you.") 
	  elseif cmd == prefix.."changeuserpass" then
	    ChangePass(user, data)
	  elseif cmd == prefix.."reg" then
	    RegUser(user, data)
	  elseif cmd == prefix.."deleteuser" then
	    DelUser(user, data)
	  elseif cmd == prefix.."showlogs" then
	    ShowLogs(user, data)
	  elseif cmd == prefix.."clearlogs" then
	    ClearLogs(user, data)
	  elseif cmd == prefix.."changeuserpass" then
	    ChangePass(user, data)
	  end
    end
end

---------------Reg Del Users------------

function Get1Arg(data) 
   s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" ) 
   return arg 
end 

function Get2Arg(data) 
   s,e,cmd,arg,arg2 = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" ) 
   return arg, arg2 
end 


function Get3Arg(data) 
   s,e,cmd,arg,arg2,arg3 = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(%S+)%s+(.+)" ) 
   return arg, arg2,arg3
end  

function GetProfileOffline(nick)
   ret = nil
   for a,b in GetProfiles() do
      for c,d in GetUsersByProfile(b) do
         if d == nick then
            ret = GetProfileIdx(b)
            break
         end
      end
   end
   return ret
end

function RegUser(user,data)
   local arg, arg2, arg3 = Get3Arg(data)  
   if (arg==nil or arg2 == nil or arg3 == nil) then 
      user:SendPM(Bot, "Syntax error, !register   , must have a nick and a new pass and level.") 
   else
      local tmp = GetProfileOffline(arg)
      if tmp ~= nil then
         user:SendPM(Bot, "The user "..arg.." is already registerd in the Hub.")
      elseif "tonumber(arg3) <= user.iProfile" then
         user:SendPM(Bot, "The user '"..arg.."' has the same or higher level then you. You can only register a user with lower level than yourself.")
			appendto(sOplog)
			write("\r\n", "*"..user.sName.." tryed register '"..arg.."' with level a higher level than themself. (Level: "..GetProfileName(arg3)..") on "..GetTime())
			writeto()
      else
         AddRegUser(arg, arg2, arg3)
         user:SendPM(Bot, "The new user '"..arg.."' has been register with pass: '"..arg2.."' and profile: "..GetProfileName(arg3))
			appendto(sOplog)
			write("\r\n", "*"..user.sName.." registered '"..arg.."' with password:'"..arg2.."' and level: "..GetProfileName(arg3).." on "..GetTime())
			writeto()
      		end 
   	end 
end

function ChangePass(user, data)
   local arg, arg2 = Get2Arg(data)  
   if (arg == nil or arg2 == nil) then 
      user:SendPM(Bot, "Syntax error, !changeuserpass  , must have a nick and a new pass.")
   else
      local tmp = GetProfileOffline(arg)
      if tmp == nil then
         user:SendPM(Bot, "The user '"..arg.."' is not registerd in the Hub.")
      elseif tmp <= user.iProfile then
         user:SendPM(Bot, "The user '"..arg.."' has the same or higher level then you. You can only change password on a user with lower level than yourself.")
	appendto(sOplog)
	write("\r\n", "*"..user.sName.." tryed to change a higher ranking users ("..arg..") password to:'"..arg2.."' and level: "..GetProfileName(arg3).." on "..GetTime())
	writeto()
      else
         DelRegUser(arg)
         AddRegUser(arg, arg2, tmp)
         user:SendPM(Bot, "The user "..arg.."'s password has been changed to: "..arg2)
	appendto(sOplog)
	write("\r\n", "*"..user.sName.." changed "..arg.."'s password to:'"..arg2.."' on "..GetTime())
	writeto()
      end
   end
end


function DelUser(user, data)
	Get1Arg(data)
	if (arg == nil) then
		user:SendPM(Bot, "Syntax error, !deleteuser .")
	else
		if (DelRegUser(arg) == -1) then
			user:SendPM(botname, "The User '"..arg.."' is not registerd in the Hub.")
				appendto(sOplog)
				write("\r\n", "The non existing user "..arg.." was attempted deleted by: "..user.sName.." on "..GetTime())
				writeto()
		else
			DelRegUser(arg)
			user:SendPM(Bot, "The User '"..arg.."' has been deleted. This action was added to log. ")
			appendto(sOplog)
			write("\r\n", "*"..user.sName.." deleted the User '"..arg.."' on "..GetTime())
			writeto()
		end
	end
end
-------------Start Logs---------------
function ShowLogs(user, data)
		if not user.bOperator then
			SendC(Bot, "Only Ops can use this function.")
			return 1
end
		readfrom(sOplog)
		local sLine = read() 
		local sFileContent = ""
		if sLine then 
			sFileContent = sLine
			while 1 do 
				sLine = read() 
				if not sLine then 
					break
				else
				sFileContent = sFileContent..sLine.."\r\n"
				end
			end
			appendto(sOplog)
			write("\r\n", "*"..user.sName.." viewed the OpsLogs on "..GetTime())
			writeto()
			readfrom()	-- close filehandle
			user:SendPM(Bot,sFileContent) 
			return 1
		else
			SendC(Bot,"Nothing in \"oplog.txt\" or no \"oplog.txt\"")
			return 1
		end 
		readfrom()
end

function ClearLogs(user, data)
	if (GetProfileName(user.iProfile) == "Master") then
			writeto(sOplog) -- goes to the file wanted 
			write("") --- will write nothing in the file and everthing that was on him will disappeare 
			writeto() -- to write on the file
			appendto(sOplog)
			write("\r\n", "The Operator '"..user.sName.."' deleted the OpsLogs on "..GetTime())
			writeto()
			user:SendPM(Bot, "Done.. The OpsLogs has been deleted!")
			return 1
		else
			SendC(Bot, "Only Ops with the profile Master can use this function.")
			return 1
		end
end


I hope this helps clear it up :-)

**Snooze
- still trying ...

nErBoS

Hi,

Well your reg is not working because you have diferent names the function name..

"function RegUser(user,data)"

The function called in the command !reg..

"RegOps(user, data)"

Try to correct that and you will see that will work.

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

Opps :(

Pasted the wrong command in here .. It's corrected in the script above..

Sorry nErBoS !



**Snooze

nErBoS

Hi,

Have i tried your script and worked ok, if you know when happens the error it would helps to see whats wrong.

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

Hmm... thats odd..

When i try to register a user i get the error:

The user has the same or higher level then you. You can only register a user with lower level than yourself.

I get that no matter what level i enter.. ?


**Snooze

nErBoS

Hi,

Modified this...
      elseif "tonumber(arg3) <= user.iProfile" then
to this..
      elseif (tonumber(arg3) <= user.iProfile) then

I have tried and got no error he lets me register the one i can and don?t let the own that i can?t

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

Thanks nErBoS :))

That worked just like we entended !!


**Snooze
- 4ever greatfull

Snooze

After working a "few" days on this script to my Ops, i feel like i need to thank you both again for all the help you have given me !!

A _H U G E_ 'Thank You' goes to nErBoS & plop !!!!



**Snooze
- the greatfull

plop

QuoteOriginally posted by Snooze
After working a "few" days on this script to my Ops, i feel like i need to thank you both again for all the help you have given me !!

A _H U G E_ 'Thank You' goes to nErBoS & plop !!!!



**Snooze
- the greatfull
yw.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

nErBoS

Hi,

Your welcome, we are here to help on at we can :)

Best regards, nErBoS
--## nErBoS Spot ##--

SMF spam blocked by CleanTalk