user alert
 

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

user alert

Started by kEwL, 14 July, 2005, 14:34:51

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kEwL

i want a script which alerts a user when a user he wants to talk with comes online
eg
+addalert kewl
u will be alerted when the user comes online

and when the user kewl comes online it ll send a pm to testing that kewl has joined the hub

Madman

#1
something like this?
command is !online

-- OnlineChecker
-- Striped from MadSecurity
-- Made by Madman
-- Make a folder called Online in the Script folder
-- Added Op = NewUser, thanks Dessamator =)
-- Added so the command can be changed easy
-- Fixed Nick nil error

Bot = "OnlineChecker"
Cmd = "online"

function Main()
	frmHub:RegBot(Bot)
end

function ChatArrival(curUser, data)
	local data = string.sub(data,1, -2)
	local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#](%S+)") -- Find commands
	if cmd then -- Found command
		cmd = string.lower(cmd)
		local tCmds = {
		[Cmd] =  function(curUser, data)
			local s,e,Nick = string.find(data, "%b<>%s+%S+%s+(%S+)") -- Find nick
			if not Nick then
				curUser:SendData(Bot, "I need a nick to check") return 1
			end
			OnNick = GetItemByName(Nick) -- Is nick online?
			if OnNick then -- Yup
				curUser:SendData(Bot, OnNick.sName.. " is online!") return 1 -- Tell us and stop
			end
			local file = io.open("Online/" ..Nick..".txt", "a+") -- Open file
			if file then -- There was a file
				file:write(curUser.sName.."\n") -- Add this
				file:close() -- Close it
			else -- There was no file
				local file = io.open("Online/" ..Nick..".txt", "w+") -- Open in write mode
				file:write(curUser.sName.. "\n") -- Write/create
				file:close() -- Close
			end
			curUser:SendData(Bot, "Online check added 2 " ..Nick) return 1 -- tell us it's done
		end,
		}
		if tCmds[cmd] then -- If the command was in table
			return tCmds[cmd](curUser, data) -- Then execute it...
		end
	end
end

function NewUserConnected(curUser)
	local file = io.open("Online/" ..curUser.sName.. ".txt")
	if file then
		file:close()
		local file = io.input("Online/" ..curUser.sName.. ".txt")
		while 1 do
			local line = io.read()
			if line == nil then
				break
			else
				local s,e,Nick = string.find(line, "(%S+)")
				OnNick = GetItemByName(Nick)
				if OnNick then
					OnNick:SendPM(Bot, curUser.sName.. " just went online @ " ..os.date("%X"))
				end
			end
		end
		file:close()
		os.remove("Online/" ..curUser.sName.. ".txt")
	end
end

OpConnected = NewUserConnected
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

kEwL

[21:29] Syntax C:\ptokax\scripts\alert.lua:26: attempt to index local `file' (a nil value)

this is the error i get

Madman

#3
i'm not at home atm.. but will check on it when i come home.. did u create the Online folder?

*edit*
made a small change... copy it again... and if u still get the error and have the Online folder... show me what you wrote to get the error....
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

kEwL

i am not getting a pm instead i get in the main chat
Private message from OnlineChecker: testing just went online @ 10:31:38
and i havent touched the script :)

Madman

my bad...
Add this under
Bot = "OnlineChecker"
function Main()
	frmHub:RegBot(Bot)
end
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

kEwL

#6
i want all users to use the cmd now only the ops can

Dessamator

hmm, u must be doing something wrong,there's nothing in that script stating that only ops can use the command,  although the script is missing the "NewUserConnected = OpConnected"
Ignorance is Bliss.

kEwL

no m8 didnt touch the script
have a look i tried to use the cmd as a reg user and it says you cant use this command

Dessamator

that error is probably from another script, there's nothing like that in this one !
Ignorance is Bliss.

kEwL

hey i checked that script again
the problem appears when i run the script with the user hider script when i remove the user hider script it works fine

Madman

#11
Then that script probarly has the command online 2... i updated the script.. copy it again and change the line
Cmd = "online"
to anyting you want...maybe
Cmd = "addalert"

And thanks Dessamator 4 reminding of the OpConnected = NewUserConnected =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

kunal

[21:23] Syntax C:\ptokax0.3.3.21\scripts\addalert.lua:37: attempt to index local `file' (a nil value)

kunal

#13
ok got it t work.
can online check be added only to reg users
if user kkkk is not regged in the hub other users cant add online check to him.


Madman

#15
QuoteOriginally posted by kunal
madman pls find time for my request.

Sry dude... must have missed this thread...

-- OnlineChecker
-- Striped from MadSecurity
-- Made by Madman
-- Make a folder called Online in the Script folder
-- Added Op = NewUser, thanks Dessamator =)
-- Added so the command can be changed easy
-- Fixed Nick nil error
-- Added only reg user can be checked

Bot = "OnlineChecker"
Cmd = "online"

function Main()
	frmHub:RegBot(Bot)
end

function ChatArrival(curUser, data)
	local data = string.sub(data,1, -2)
	local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#](%S+)") -- Find commands
	if cmd then -- Found command
		cmd = string.lower(cmd)
		local tCmds = {
		[Cmd] =  function(curUser, data)
			local s,e,Nick = string.find(data, "%b<>%s+%S+%s+(%S+)") -- Find nick
			if not Nick then
				curUser:SendData(Bot, "I need a nick to check") return 1
			end
			if frmHub:isNickRegged(Nick) then -- Is nick regged
				OnNick = GetItemByName(Nick) -- Is nick online?
				if OnNick then -- Yup
					curUser:SendData(Bot, OnNick.sName.. " is online!") return 1 -- Tell us and stop
				end
				local file = io.open("Online/" ..Nick..".txt", "a+") -- Open file
				if file then -- There was a file
					file:write(curUser.sName.."\n") -- Add this
					file:close() -- Close it
				else -- There was no file
					local file = io.open("Online/" ..Nick..".txt", "w+") -- Open in write mode
					file:write(curUser.sName.. "\n") -- Write/create
					file:close() -- Close
				end
				curUser:SendData(Bot, "Online check added 2 " ..Nick) -- tell us it's done
			else
				curUser:SendData(Bot, Nick.. " is not regged and cant be added to online check")
			end
			return 1
		end,
		}
		if tCmds[cmd] then -- If the command was in table
			return tCmds[cmd](curUser, data) -- Then execute it...
		end
	end
end

function NewUserConnected(curUser)
	local file = io.open("Online/" ..curUser.sName.. ".txt")
	if file then
		file:close()
		local file = io.input("Online/" ..curUser.sName.. ".txt")
		while 1 do
			local line = io.read()
			if line == nil then
				break
			else
				local s,e,Nick = string.find(line, "(%S+)")
				OnNick = GetItemByName(Nick)
				if OnNick then
					OnNick:SendPM(Bot, curUser.sName.. " just went online @ " ..os.date("%X"))
				end
			end
		end
		file:close()
		os.remove("Online/" ..curUser.sName.. ".txt")
	end
end

OpConnected = NewUserConnected

*Edit*

Fixed an small error..
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p


SMF spam blocked by CleanTalk