[Request] Away 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

[Request] Away script

Started by Snooze, 22 March, 2004, 16:05:53

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Snooze

Looking for a simple standalone away script ... or a few hints on howto make one :)




*Snooze

Corayzon

-- cSlave 0.2.1 :: away.lua :: writin by Corayzon
-------------------------------------------------------------------------------------
awayList = {}

function saveAwayList()
   appendto(sysPath.."data/tempsettings.lua")
   local sOut = "--Away List Table\r\n"
   if awayList ~= nil then
      for user, setting in awayList do
         sOut = sOut.."awayList[\""..user.."\"] = \""..setting.."\"\r\n"
      end
   end
   write(sOut.."\r\n")
   writeto()
end

function doAwayCommand(user, data, cmd)
   if cmd == cmdaway then
      setAway(user, data)
      return 1

   elseif cmd == cmdback then
      setBack(user, data)
      return 1

   elseif cmd == cmdawaylist then
      getAwayList(user)
      return 0
   end
end

function setAway(user, data)
   _,_,cmd,reason = strfind(data, "%b<>%s+(%S+)%s+(.+)")
   if (reason==nil) then
      reason = "none"
      SendToAll(sBot, awaymsg1..user.sName..awaymsg2)
      awayList[user.sName] = reason
   else
      SendToAll(sBot, awaymsg1..user.sName..awaymsg3..reason)
      awayList[user.sName] = reason
   end
end

function setBack(user, data)
   _,_,cmd,reason = strfind(data, "%b<>%s+(%S+)%s+(.+)")
   if (reason==nil) then
      if awayList[user.sName] ~= nil then
         SendToAll(sBot, backmsg1..user.sName..backmsg2)
         awayList[user.sName] = nil
      end
   else
      if awayList[user.sName] ~= nil then
         SendToAll(sBot, backmsg1..user.sName..backmsg2..reason)
         awayList[user.sName] = nil
      end
   end
end

function getAwayList(user)
   local sOut = msgawaylist
   for username, suspects in awayList do
      sOut = sOut.."\t\t"..username.." ["..awayList[username].."]\r\n"
   end
   user:SendPM(sBot, sOut.."\r\n")
end


------------------------------------------------------------------

This is for the cSlave system...but u should get the idea... ;)

Snooze

Thanks Corayzon :)

Thats just what i had in mind :))


**Snooze

Snooze

Umm.. two problems i cant seam to fix :(

function setBack(user, data) 
_,_,cmd,reason = strfind(data, "%b<>%s+(%S+)%s+(.+)") 
if (reason==nil) then 
if awayList[user.sName] ~= nil then 
SendToAll(Bot, user.sName.." no longer set to 'Away'")  
awayList[user.sName] = nil 
end 
else 
if awayList[user.sName] ~= nil then 
SendToAll(Bot, user.sName.."is no longer away with the reason:"..reason) 
awayList[user.sName] = nil 
end 
end 
end 

function getAwayList(user) 
local sOut = msgawaylist
for username, suspects in awayList do 
sOut = sOut.."\t\t"..username.." ["..awayList[username].."]\r\n"
end 
user:SendPM(Bot, sOut.."\r\n") 
end

- when calling the back setBack(user, data)  function i cant get it to go behind the first reponce ..

- and i cant get it to read the awaylist :( - reason


Please advise..


**Snooze

Corayzon

#4
oh...wops...this is part of cSlave and u need some settings for the above to work correctly...i sujest u just download it and use the references u need...


Corayzon

local sOut = msgawaylist

msgawaylist == nil!

Corayzon

this is what ur missing...tri starting again and editing these settings and not the script itself

-- Away\Back Options
awaymsg1 = ""
awaymsg2 = " is now away"
awaymsg3 = " is now away because: "
backmsg1 = ""
backmsg2 = " is now back "
msgawaylist = "\r\n\r\n\tA w a y   L i s t\r\n\r\n"

by the way...how do i make it go

code
---------------------
and then show the tab marks n shit in the quote???


Snooze

Um... Any chance of you helping me add so if a user sends a PM to a user in the awayList = {} he/she will recieve the away msg ? :))



**Snooze

raz

if u r using Dc++ den u should be able 2 do /away and /back as it is built in. If u want it 2 appear on main then u need a script!!
 :D

Snooze

Um... Any chance of you helping me add so if a user sends a PM to a user in the awayList = {} he/she will recieve the away msg ? :))



**Snooze

raz

/away and /back !! for example if i am away and u pm me u will recieve the msg i have put myself away as!! this is built into dc++.
 :D

Snooze

Thanks for the reply raz - though it were not what i were looking for ...


**Snooze

raz

What are you looking 4 ??
i don't think i understand u!!
 :D

Corayzon

um...yea dude u can...but it will interfer with dc's inbuilt one...

But if u would like to do then u would do something like the following...have no time to write up...work in 2 mins...

when a msg comes in u check the username from who its to...

then u check this against the awayList[user.sName]...

and if so then u send the pm to the sender with the away string...

but doing so will make 2 msgs come if the users dc is minimized to...

what im looking at doing is making the setBack\setAway commands update the internal dc away ;)

hope this made sense...and if u want some help...ill write up a demo for ya 2night :D

enjoy ppl!

Snooze

hey Corayzon,

I know its a already builin feature in DC++, though the users in my hub dont use the builin feature at all.

It's for a preivate hub thats been running for ages so my users are used to using the scripted version and are now asking me to bring it back ;)

A small demo on howto read the away msg in the DataArrival would be really nice :))




**Snooze

Corayzon

um here dude....im not testin this one, just writing in ere...so it might need some work before it works...

but it would be something like so...

sAwayMsg = "#u is away because: #x"

function DataArrival(user, data)
	if strfind( data, "$To") then
		local s, e, toUser, fromUser, sMessage = strfind(data,    "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
		if awayList[toUser] then
			user:SendPM(toUser, translateString(sAwayMsg, toUser, fromUser, awayList[toUser])
		end
	end
end

function translateString(sString, sUserName, e, x, t)
	-- System Strings
	sString, _ = gsub(sString, "#h", frmHub:GetHubName())

	-- Input Strings
	sString, _ = gsub(sString, "#u", sUserName)
	sString, _ = gsub(sString, "#e", e)
	sString, _ = gsub(sString, "#x", x)
	if t ~= nil then sString, _ = gsub(sString, "#t", t) end
	return sString
end

Ive even included info how to make great editable settings  :rolleyes:

If this dont work and u cant get to...i guess ill test it and fix it for ya  8)

Snooze

Worked perfectly :))

Thanks for taking the time to answer these newbie questions and explaning you solutions so well :))

---------------------------------
Small error - missing ) in this line:

user:SendPM(toUser, translateString(sAwayMsg, toUser, fromUser, awayList[toUser])


**Snooze

Corayzon

i allways do that...as in forget the ')' hehe...

np dude...im allways happy to help...y hide script when other ppl can use it ;)

anyways...happy to hear i help ya out...if u need anything else...ill tri my hardest to help ya =]

also dude...add my icq ;)

im allways helping ya so masse well

Corayzon

also...u guys like my translateString(sString, sUserName, e, x, t) command???

Snooze

Thanks for ICQ invite but im not running ICQ due to firewall blocking it at work :(

Corayzon

no problemo dude :D

D-J Valhala

#22
Coraizon... hi :)
can you please post the complite script?
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

SMF spam blocked by CleanTalk