userlist by bastya_elvtars
 

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

userlist by bastya_elvtars

Started by bastya_elvtars, 04 January, 2005, 02:07:40

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bastya_elvtars

just completing a little request on ukknnet board, but its better than i thought

enjoy

-- userlist by bastya_elvtars
-- shows a sorted userlist in PM divided into categories
-- ascii should be updated by somebody who has ascii design skills
-- will be deprecated in lua5 px ;)

-- sure u should edit these if needed

bot="userlist-bot"

command="userlist" -- no leading ! or other prefix plz - supports ! + #

level=2 -- levels are always the following, determining who CAN use the command:
        -- 5:only superops
        -- 4 ops & above
        -- 3 vips & above
        -- 2 registered users & above
        -- 1 anyone
        -- 0 disabled

-- not sure u should edit below without minimal lua knowledge.

users={}

users["reg"]={}
users["su"]={}
users["op"]={}
users["vip"]={}
users["guest"]={}


toins={
[1]=users["op"],
[2]=users["vip"],
[3]=users["reg"],
[0]=users["su"],
[-1]=users["guest"],
}

userlevels={[-1]=1,[0]=5,[1]=4,[2]=3,[3]=2}


function NewUserConnected(user)
	if toins[user.iProfile] then
		toins[user.iProfile][user.sName]=1
	end
end

function Main()
	frmHub:RegBot(bot)
end

function UserDisconnected(user)
	if toins[user.iProfile] then
		toins[user.iProfile][user.sName]=nil
	end
end

function userlist()
	return ("This Is The Current UserList:\r\n\r\n=======================\r\n=======================\r\nSuperops:\r\n--------------------------------------\r\n"..
	makelistofaddedprofileintable(toins[0]).."--------------------------------------\r\n\r\nOps:\r\n--------------------------------------\r\n"..
	makelistofaddedprofileintable(toins[1]).."--------------------------------------\r\n\r\nVIPs:\r\n--------------------------------------\r\n"..
	makelistofaddedprofileintable(toins[2]).."--------------------------------------\r\n\r\nREGs:\r\n--------------------------------------\r\n"..	
	makelistofaddedprofileintable(toins[3]).."--------------------------------------\r\n\r\nGuests:\r\n--------------------------------------\r\n"..
	makelistofaddedprofileintable(toins[-1]).."\r\n\r\n=======================\r\n=======================")
end

function makelistofaddedprofileintable(table)
	local txt=""
	local arr={}
	for a,b in table do
		tinsert(arr,a)
	end
	sort(arr)
	for u=1,getn(arr) do
		txt=txt..arr[u].."\r\n"
	end
	return txt
end

function DataArrival(user,data)
	if userlevels[user.iProfile]>=level then
		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==command  then
					user:SendPM(bot,userlist())
				end
			elseif strsub(data, 1, 1) == "<" then 
				data=strsub(data,1,strlen(data)-1)
				local _,_,cmd = strfind(data,"%b<>%s+[%!%+%#](%S+)")
					if cmd==command  then
					user:SendPM(bot,userlist())
				end
			end
		end
	end
end

OpConnected=NewUserConnected
OpDisconnected=UserDisconnected
Everything could have been anything else and it would have just as much meaning.

Ubikk

this is the error I got today when I tried the script:

Syntax Error: unfinished string;
  last token read: `"This Is The Current  UserList' at line 117 in string "-- userlist by bastya_elvtars
..."

Herodes

replace the userlist() function with this one ..


function userlist()
	local msg ="This Is The Current  UserList:\r\n\r\n"
	msg = msg..srtrep(strrep("=", 20).."\r\n", 2).."Superops:>\r\n"
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg..makelistofaddedprofileintable(toins[0])
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg.."\r\nOps:\r\n"
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg..makelistofaddedprofileintable(toins[1])
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg.."\r\nVIPs:\r\n
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg..makelistofaddedprofileintable(toins[2])
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg.."\r\nREGs:\r\n"
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg..makelistofaddedprofileintable(toins[3])
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg.."\r\nGuests:\r\n"
	msg = msg..srtrep("-", 37).."\r\n"
	msg = msg..makelistofaddedprofileintable(toins[-1]).."\r\n"
	msg = msg..srtrep(strrep("=", 20).."\r\n", 2).."\r\n"
	return msg
end

//completely untested//

SMF spam blocked by CleanTalk