opcomextra
 

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

opcomextra

Started by plop, 28 February, 2005, 17:47:23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

plop

-- PtokaX Lua 5 version by PPK

-- vim:ts=4:sw=4:noet
-- PtokaX OpComExtra.lua 1.1 (Sedulus/20030314) tested on PtokaX 0.3.2.4 IceCube-III-fix3
-- based on OpComExtra.lua for DCH++ by Sedulus
-- created for Cop][Killer of the [TropiCo.se] network
-- no rights reserved (although it would be nice if you kept my name in here)

bot_name = frmHub:GetHubSecAliasName()
max_table_siz = 8	-- the maximum number of nick/times per IP and ip/times per nick stored
max_history_siz = 100	-- the maximum number of last logins recorded

--
-- start
--

IPTable = {}		-- store info about IP's here
NickTable = {}		-- store info about Nicks here
HistoryTable = {}	-- store last logins

-- Gets called upon arrival of a chat or pm message
function clientMessage(client, msg, loc)
	if string.sub(msg, 1, 7) == "ipinfo " then
		if client.bOperator then
			local ip = string.sub(msg, 8)
			if IPTable[ip] then
				local str = "ipinfo on: "..ip.."\r\n"
				for key, elem in IPTable[ip] do
					if key ~= "n" then str = str..elem.."\r\n" end
				end
				messageClient(client, loc, bot_name, str)
			else
				messageClient(client, loc, bot_name, "no ipinfo on: "..ip)
			end
		end
		return 1
	elseif string.sub(msg, 1, 9) == "userinfo " then
		if client.bOperator then
			local nick = string.sub(msg, 10 )
			if NickTable[nick] then
				local str = "userinfo on: "..nick.."\r\n"
				for key, elem in NickTable[nick] do
					if key ~= "n" then str = str..elem.."\r\n" end
				end
				messageClient(client, loc, bot_name, str)
			else
				messageClient(client, loc, bot_name, "no userinfo on: "..nick)
			end
		end
		return 1
	elseif msg == "history" or string.sub( msg, 1, 8 ) == "history " then
		if client.bOperator then
			local num = tonumber(string.sub(msg, 10))
			local start
			local last = table.getn(HistoryTable)
			if not num or num <= 0 or num > last then
				start = 1
			else
				start = last - num + 1
			end

			local str = "last login history:\r\n"
			for i = start, last do
				str = str..i.."\t"..HistoryTable[i].."\r\n"
			end
			messageClient(client, loc, bot_name, str)
		end
		return 1
	end
end

-- Gets called when a new user connects
function userConnected(client)
	local nick = client.sName
	local ip = client.sIP
	local level = client.bOperator
	if not level then level = 0 else level = 1 end
	-- create tables
	if not IPTable[ip] then IPTable[ip] = {} end
	if not NickTable[nick] then NickTable[nick] = {} end
	-- remove first so we scroll (max_table_siz/max_history_siz)
	if table.getn(IPTable[ip]) == max_table_siz then table.remove(IPTable[ip], 1) end
	if table.getn(NickTable[ nick ] ) == max_table_siz then table.remove(NickTable[nick], 1) end
	if table.getn(HistoryTable) == max_history_siz then table.remove(HistoryTable, 1) end
	-- add newest entry
	table.insert(IPTable[ip], os.date()..": ["..level.."] "..nick )
	table.insert(NickTable[nick], os.date()..": "..ip )
	table.insert(HistoryTable, os.date()..": ["..level.."] "..nick.." - "..ip )
end

-- Checks if this is a message for us
function isMessageForMe(data)
	local ret,c,msg = string.find( data, "^%b<> !(.*)|$" )
	if ret then
		return msg,0
	end
	return nil
end

-- Send client a message
function messageClient(client, where, from, msg)
	if where == 0 then
		client:SendData("<"..from.."> "..msg.."|")
	end
end

-- Event: arrival of data
function ChatArrival(curUser, sData)
	local msg,loc = isMessageForMe(sData)
	if msg then
		return clientMessage(curUser, msg, loc)
	end
end

-- Event: new user
function NewUserConnected(curUser)
	return userConnected(curUser)
end

-- Event: new op
function OpConnected(curUser)
	return userConnected(curUser)
end

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 <----<<

UwV

#1
-- PtokaX Lua 5 version by PPK
-- vim:ts=4:sw=4:noet
-- PtokaX OpComExtra.lua 1.1 (Sedulus/20030314) tested on PtokaX 0.3.2.4 IceCube-III-fix3
-- based on OpComExtra.lua for DCH++ by Sedulus
-- created for Cop][Killer of the [TropiCo.se] network
-- no rights reserved (although it would be nice if you kept my name in here)

-- now saves to files, does some otherstuff and is DSN ready ...uwv 
-- usercommands glued in & 5.0.x version by UwV

-- you need the three following files in your script folder : " ntable.tbl "  "  htable.tbl "  and " itable.tbl "

bot_name = frmHub:GetHubSecAliasName() -- botname 1 to react to commands in PM 
bot_name2 = "-=Holly=-" -- botname 2 to react to commands in PM
max_table_siz = 7	-- the maximum number of nick/times per IP and ip/times per nick stored
max_history_siz = 604	-- the maximum number of last logins recorded

the next thingy keeps getting messed up when i post it,,
    " &#124;  "    it changes to : " | "
(and this color trick won't work inside code tags)
so please dl the attachement ..
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

Alexinno

 It works now, no errors :-*

thx UwV

SMF spam blocked by CleanTalk