Away name change script
 

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

Away name change script

Started by QuikThinker, 14 August, 2004, 19:32:16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

QuikThinker

Hey guys,
I am after a script that the OPs & Masters can use by runnin a command 4 instance the !away command so that it will change their name 2 av the prefix [AWAY] on their nick. The reason i'm asking is because new users get frustrated when they think OPs r jus ignoring them.
So 4 jus 2 clear it up when they come in the hub they can type !away (or wateva) then the prefix will change their name to say [AWAY]QuikThinker 4 example so this will be a clear enuff indication 2 the users who r away & who r at their PCs.
Dunno if its possible but good luck.

Quik.

Herodes

I dont think this represents in full the funcitonaity that one would want from an away bot but ... It does what you asked for ... I havent tested it thoroughly so pls grab n test ... report bugs and misses and maybe we can fix it ...
[*To All*] pls lets make this one a nice script ;)

---  Awayer v1 --- idea by QuitckThinker
--- by Herodes
--- This bot has been writen offline and based on no other script
--- Although the initial idea for the AwayBot is from tezlo's RetroBot...
--- This diplays a prefix for those operators and above that are away
--- !away
--- !back
--- feel free to develop this further ...  

tAways = {}
awpref = "[AWAY]"

function Main()
	frmHub:EnableFullData(1)
end

function DataArrival(user, data)
	if ( (user.bOperator) and (tAways[user.sName]) and (strsub(data, 1, 7) == "$MyINFO") ) then 
		local s,e,name = strfind(data, "%$MyINFO %$ALL (%S+)")
		SendToAll("$Quit "..user.sName)
		frmHub:UnregBot(awpref..user.sName)
		frmHub:RegBot(awpref..user.sName)
		newinfo = gsub(data, user.sName, awpref..user.sName)
		SendToAll(newinfo)
		return 1
	end

	if strsub(data, 1, 8) == "$GetINFO" then
		local s,e,from, to = strfind(data, "$GetINFO%s(%S+)%s(%S+)")
		if tAways[from] == 1 then
			data = gsub(data, from, awpref..from)
			SendToAll("$Quit "..from)
		end
		if tAways[to] == 1 then
			data = gsub(data, to, awpref..to)
			SendToAll("$Quit "..to)
		end
		SendToNick(to, data)
		return 1
	end

	if strsub(data, 1,1) == "<" then
		data =strsub(data, 1, strlen(data)-1)
		local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if cmd == "!away" then
			if tAways[user.sName] ~= 1 then
				tAways[user.sName] = 1
				user:SendData("Awayer", "You are now set to away ..")
				frmHub:UnregBot(awpref..user.sName)
				frmHub:RegBot(awpref..user.sName)
			else
				user:SendData("Awayer", "You are away already ... ")
			end
			SendToAll("$Quit "..user.sName)
			return 1
		elseif cmd == "!back" then
			if tAways[user.sName] == 1 then
				tAways[user.sName] = nil
				frmHub:UnregBot(awpref..user.sName)
				SendToAll("Awayer", user.sName.." is back .. :)")
			else 
				user:SendData("Awayer", "You were not away... :)")
			end
			return 1
		elseif tAways[user.sName] == 1 then
			tAways[user.sName] = nil
			user:SendData("Awayer", "You spoke in main chat so you are not away anymore.")
			frmHub:UnregBot(awpref..user.sName)
		end
	end

end

function OpDisconnected(user)
	if GetItemByName(awpref..user.sName) then
		frmHub:UnregBot(awpref..user.sName)
	elseif GetItemByName(user.sName) then
		SendToAll("$Quit "..user.sName)
	end
end

Herodes

#2
got some more work on that ,...
---  Awayer v2 --- idea by QuitckThinker
--- by Herodes
--- This bot has been writen offline and based on no other script
--- Although the initial idea for the AwayBot is from tezlo's RetroBot...
--- This diplays a prefix for those operators and above that are away
--- !away    ---  is optional
--- !back
--- !awaylist
--- feel free to develop this further ...  
--- --- v 2 --- ---
--- currently has a problem with the following path ..
--- 1)  !away
--- 2) user reconnnects 
--- 3)  !back 
--- this produces a lot of shity names in the list ... dunno y ...:(
--- --- --- --- --- --- ---
tAways = {}

awpref = "[AWAY]"
defmsg = "I'm away. I might answer later if you're lucky."

function Main()
	frmHub:EnableFullData(1)
end

function NewUserConnected(user)
	for nick, msg in tAways do
		user:SendData("$Quit "..nick)
		user:SendData("You are missing "..nick)
	end
	if GetItemByName(user.sName) and tAways[user.sName] then
		SendToAll("$Quit "..user.sName)
	end
end

OpConnected = NewUserConnected

function DataArrival(user, data)

	if ( (user.bOperator) and (tAways[user.sName]) and (strsub(data, 1, 7) == "$MyINFO") ) then 
		local s,e,name = strfind(data, "%$MyINFO %$ALL (%S+)")
		frmHub:UnregBot(awpref..user.sName)
		frmHub:RegBot(awpref..user.sName)
		newinfo = gsub(data, user.sName, awpref..user.sName)
		SendToAll(newinfo)
		SendToAll("$Quit "..user.sName)
		return 1
	end

	if strsub(data, 1, 4) == "$To:" then
		local s,e,whoTo,from = strfind(data, "$To:%s"..awpref.."(%S+)%sFrom:(%S+)")
		if tAways[whoTo] then
			SendPmToNick(from, whoTo, tAways[whoTo])
		end
	end

	if strsub(data, 1, 8) == "$GetINFO" then
		local s,e,from, to = strfind(data, "$GetINFO%s(%S+)%s(%S+)")
		if tAways[from] == 1 then
			data = gsub(data, from, awpref..from)
			SendToAll("$Quit "..from)
		end
		if tAways[to] == 1 then
			data = gsub(data, to, awpref..to)
			SendToAll("$Quit "..to)
		end
		if GetItemByName(from) then
			oper =  GetItemByName(from)
			if oper.bOperator then
				frmHub:UnregBot(oper.bOperator)
			end
		end
		if strfind(data, "$GetINFO%s"..awpref..to.."%s"..to) or strfind(data, "$GetINFO%s"..awpref..from.."%s"..from) then
			return 1 
		end		
		SendToNick(to, data)
		return 1
	end

	if strsub(data, 1,1) == "<" then
		data =strsub(data, 1, strlen(data)-1)
		local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if cmd == "!away" then
			local s,e,arg = strfind(data, "%b<>%s+"..cmd.."%s(.*)")
			if arg == nil or arg == "" then arg = defmsg end
			if not tAways[user.sName] then
				local s,e,name,desc,tag, con,email,share   = strfind(user.sMyInfoString, "$MyINFO $ALL (%S+)%s+(.*)<([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
				tAways[user.sName] = {}
				tAways[user.sName]["info"] = {}
				if desc == nil then desc = "" end
				tAways[user.sName]["info"]["d"] = desc
				tAways[user.sName]["info"]["t"] = "<"..tag
				tAways[user.sName]["info"]["c"] = con
				if email == nil then email = "" end
				tAways[user.sName]["info"]["e"] = email
				tAways[user.sName]["info"]["s"] = share
				tAways[user.sName]["reason"] = arg
				user:SendData("Awayer", "You are now set to away ..")
				frmHub:UnregBot(awpref..user.sName)
				SendToAll("$MyINFO $ALL "..awpref..user.sName.." AwayMsg: "..arg..tAways[user.sName]["info"]["t"].."$ $"..tAways[user.sName]["info"]["c"].."$"..tAways[user.sName]["info"]["e"].."$$"..tAways[user.sName]["info"]["s"].."$")
				frmHub:RegBot(awpref..user.sName)
			else
				user:SendData("Awayer", "You are away already ... ")
			end
			SendToAll("$Quit "..user.sName)
			return 1
		elseif cmd == "!back" then
			if tAways[user.sName] then
				SendToAll("$MyINFO $ALL "..awpref..user.sName.." "..tAways[user.sName]["info"]["d"]..tAways[user.sName]["info"]["t"].."$ $"..tAways[user.sName]["info"]["c"].."$"..tAways[user.sName]["info"]["e"].."$$"..tAways[user.sName]["info"]["s"].."$")
				tAways[user.sName] = nil
				frmHub:UnregBot(awpref..user.sName)
				frmHub:RegBot(user.sName)
				SendToAll("Awayer", user.sName.." is back .. :)")
			else 
				user:SendData("Awayer", "You were not away... :)")
			end
			return 1
		elseif cmd == "!awaylist" then
			local list = "These users are set to away\r\n"
			local cnt = 0
			for nick, msg in tAways do
				cnt = cnt + 1
				list = list.."\t"..cnt..". "..nick.."\tAway Msg :"..msg.."\r\n"
			end
			user:SendData(list)
			return 1
		elseif tAways[user.sName] then
			SendToAll("$MyINFO $ALL "..awpref..user.sName.." "..tAways[user.sName]["info"]["d"]..tAways[user.sName]["info"]["t"].."$ $"..tAways[user.sName]["info"]["c"].."$"..tAways[user.sName]["info"]["e"].."$$"..tAways[user.sName]["info"]["s"].."$")
			tAways[user.sName] = nil
			user:SendData("Awayer", "You spoke in main chat so you are not away anymore.")
			frmHub:UnregBot(awpref..user.sName)
			frmHub:RegBot(user.sName)
		end
	end
end

function OpDisconnected(user)
	frmHub:UnregBot(awpref..user.sName)
	frmHub:UnregBot(user.sName)
	if GetItemByName(user.sName) then
		SendToAll("$Quit "..user.sName)
	end
end
It will not create any errors in PtokaX but there is the possiblity to mess up the users with Keys in the Userlist ...
try to convince ppl not use the steps in the script comments ...

QuikThinker

I was originally gonna jus create double profiles 4 the team so if they were jus gonna be in the hub idle they could login usin that name but I thought it'd easier with a script instead. I guess it's quite complicated coz u gotta include all the features of the profiles aswell?

Herodes

QuoteOriginally posted by QuikThinker
I was originally gonna jus create double profiles 4 the team so if they were jus gonna be in the hub idle they could login usin that name but I thought it'd easier with a script instead. I guess it's quite complicated coz u gotta include all the features of the profiles aswell?
Naah dont bother this script should be running nice ... apart from that glitch mentioned ...

I dont know how to tackle it until now so I would appreciate it if someone could go into the script and it fixed before I do ... :)
I have some stuff I dont think I understand how they happen with this script ...
Not how they are done BUt how they happen ...

Some scripted responses get to the userlist but I certainly haven't said it to do that .. :)

so someone, pls spare an hour to help me with this .. :s

QuikThinker

lol yea please........someone? :D

QuikThinker

I jus ran it & I get this message in main:
[18:25:39] You are now set to away ..
[18:25:39] Satellite <------ Gives the connection I state for sum reason :s

Plus it displays ma share as 0b when i'm away also.

Herodes

#7
yeah some debug shitty-chat ;) sorry ...
edited above for removing the connection send to main ...

I have tackled the garbage in the userlist by changing the order that stuff are processed in the script ( simple : moved some lines up and some other down) BUT :)
I am having problems with something else in the version I am preparing ...

I have
function OpDisconnected(user)
frmHub:RegBot(user.sName)
frmHub:UnregBot(user.sName)
SendToAll("$Quit "..user.sName)
end
and I still get the reserved nickname message if the user has gone throught this procedure
!away
!back //// or //// 'anything'
user disconnects
and on reconnection the nickname_reserved msg .... :((((((((((((((

any1 any ideas ?

Herodes

ok this is the script up to now ...
I still havent come over the last bug I posted ...
I wish , and dbl wish, for someone to tell me what is wrong with it .. ;?

---  Awayer v3 --- idea by QuitckThinker
--- by Herodes
--- This bot has been writen offline and based on no other script
--- Although the initial idea for the AwayBot is from tezlo's RetroBot...
--- This diplays a prefix for those operators and above that are away
--- It also places the Away message in the users description ...
--- --- --- This script works only for Operators (as intended) --- --- ---
--- !away    ---  is optional
--- !back
--- !awaylist
--- feel free to develop this further ...  
--- --- v 2 --- ---
--- currently has a problem with the following path ..
--- 1)  !away
--- 2) user reconnnects 
--- 3)  !back 
--- this produces a lot of shity names in the list ... dunno y ...:(
--- --- v 3 --- ---
--- fixed v2 problem but has abother one ...
--- following path ..
--- 1)  !away
--- 2)   or  !back
--- 3) user disconnects ...
--- 4) user receives nickname reserved message (???)
--- --- all other scenarios I have tested and work fine ...
--- --- --- --- --- --- ---
tAways = {}

awpref = "[AWAY]"
defmsg = "I'm away. I might answer later if you're lucky."

function Main()
	frmHub:EnableFullData(1)
end

function NewUserConnected(user)
	for nick, msg in tAways do
		user:SendData("$Quit "..nick)
		--- user:SendData("You are missing "..nick)
	end
	if GetItemByName(user.sName) and tAways[user.sName] then
		SendToAll("$Quit "..user.sName)
	end
end

OpConnected = NewUserConnected

function DataArrival(user, data)

	if ( (tAways[user.sName]) and (strsub(data, 1, 7) == "$MyINFO") ) then 
		local s,e,name = strfind(data, "%$MyINFO %$ALL (%S+)")
		frmHub:UnregBot(awpref..user.sName)
		frmHub:RegBot(awpref..user.sName)
		newinfo = gsub(data, user.sName, awpref..user.sName)
		SendToAll(newinfo)
		SendToAll("$Quit "..user.sName)
		return 1
	end

	if strsub(data, 1, 4) == "$To:" then
		local s,e,whoTo,from = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s%$")
		-- SendToAll("from "..from.." to "..whoTo)
		if strfind(whoTo, awpref) then
			whoTo = strsub(whoTo, strlen(awpref)+1, strlen(whoTo) )
		end
		-- SendToAll("the nick "..whoTo)
		if tAways[whoTo]["reason"] then
			SendPmToNick(from, whoTo, tAways[whoTo]["reason"].." ")
		end
		local s,e,msg = strfind(data, "%b<>%s+(%S+)")
		SendPmToNick(whoTo, from, msg)
	end

	if strsub(data, 1, 13) == "$ValidateNick" then
		local s,e,name = strfind(data, "%$ValidateNick%s(%S+)|")
		if tAways[name] then
			UnRegIt(name)
			--- SendToAll("connecting "..name)
		end
	end

	if strsub(data, 1, 5) == "$Quit" then
		local s,e,name = strfind(data, "%$Quit%s(%S+)")
		-- local usr = GetItemByName(name)
		--- if usr then
		-- if tAways[name] then
			UnRegIt(name)
		--- end
		--- SendToAll("disconnecting "..name)
	end
	
	if strsub(data, 1, 8) == "$GetINFO" then
		local s,e,from, to = strfind(data, "$GetINFO%s(%S+)%s(%S+)")
		if ( (from ~= awpref..to) or (to ~= awpref..from) ) then
			if tAways[from] == 1 then
				data = gsub(data, from, awpref..from)
				SendToAll("$Quit "..from)
			end
			if tAways[to] == 1 then
				data = gsub(data, to, awpref..to)
				SendToAll("$Quit "..to)
			end
			if GetItemByName(from) then
				local oper =  GetItemByName(from)
				if oper.bOperator then
					frmHub:UnregBot(oper.bOperator)
				end
			end
			SendToNick(to, data)
		elseif ( (strfind(data, "$GetINFO%s"..awpref..to.."%s"..to)) or (strfind(data, "$GetINFO%s"..awpref..from.."%s"..from)) ) then
			return 1
		end		
	end

	if strsub(data, 1,1) == "<" then
		data =strsub(data, 1, strlen(data)-1)
		local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (user.bOperator) then
			if cmd == "!away" then
				local s,e,arg = strfind(data, "%b<>%s+"..cmd.."%s(.*)")
				if arg == nil or arg == "" then arg = defmsg end
				if not tAways[user.sName] then
					local s,e,name,desc,tag, con,email,share   = strfind(user.sMyInfoString, "$MyINFO $ALL (%S+)%s+(.*)<([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
					tAways[user.sName] = {}
					tAways[user.sName] = {}
					if desc == nil then desc = "" end
					tAways[user.sName]["d"] = desc
					tAways[user.sName]["t"] = "<"..tag
					tAways[user.sName]["c"] = con
					if email == nil then email = "" end
					tAways[user.sName]["e"] = email
					tAways[user.sName]["s"] = share
					tAways[user.sName]["reason"] = arg
					user:SendData("Awayer", "You are now set to away ..")
					RegIt(awpref..user.sName)
					SendToAll("$MyINFO $ALL "..awpref..user.sName.." AwayMsg: "..arg..tAways[user.sName]["t"].."$ $"..tAways[user.sName]["c"].."$"..tAways[user.sName]["e"].."$$"..tAways[user.sName]["s"].."$|")
				else
					user:SendData("Awayer", "You are away already ... ")
				end
				SendToAll("$Quit "..user.sName.."|")
				return 1
			elseif cmd == "!back" then
				if tAways[user.sName] then
					UnRegIt(awpref..user.sName)
					SendToAll("Awayer", user.sName.." is back .. :)")
					RegIt(user.sName)
					SendToAll("$MyINFO $ALL "..user.sName.." "..tAways[user.sName]["d"]..tAways[user.sName]["t"].."$ $"..tAways[user.sName]["c"].."$"..tAways[user.sName]["e"].."$$"..tAways[user.sName]["s"].."$|")
					tAways[user.sName] = nil
				else 
					user:SendData("Awayer", "You were not away... :)")
				end
				return 1
			elseif cmd == "!awaylist" then
				local list = "These users are set to away\r\n"
				local cnt = 0
				for nick, msg in tAways do
					cnt = cnt + 1
					list = list.."\t"..cnt..". "..nick.."\tAway Msg :"..msg.."\r\n"
				end
				user:SendData(list)
				return 1
			elseif tAways[user.sName] then
				UnRegIt(awpref..user.sName)
				user:SendData("Awayer", "You spoke in main chat so you are not away anymore.|")
				RegIt(user.sName)
				SendToAll("$MyINFO $ALL "..user.sName.." "..tAways[user.sName]["d"]..tAways[user.sName]["t"].."$ $"..tAways[user.sName]["c"].."$"..tAways[user.sName]["e"].."$$"..tAways[user.sName]["s"].."$|")
				tAways[user.sName] = nil
			end
		end
	end
end

function OpDisconnected(user)
	if tAways[user.sName] then
		UnRegIt(awpref..user.sName)
		-- SendToAll("Was Away ... by the nick "..awpref..user.sName.." and the reason "..tAways[user.sName]["reason"])
	end
	UnRegIt(user.sName)
	SendToAll(user.sName)
	--- SendToAll("$Quit "..user.sName)
	--- SendToAll("$Quit "..awpref..user.sName)
end

function RegIt(name)
	frmHub:UnregBot(name)
	frmHub:RegBot(name)
end

function UnRegIt(name)
	frmHub:RegBot(name)
	frmHub:UnregBot(name)
	SendToAll("$Quit "..name.."|")
end

...pls ? :)

QuikThinker


SMF spam blocked by CleanTalk