Looking for a simple standalone away script ... or a few hints on howto make one :)
*Snooze
-- 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... ;)
Thanks Corayzon :)
Thats just what i had in mind :))
**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
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...
local sOut = msgawaylist
msgawaylist == nil!
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???
thanks
[code*] [/code*]
with no *'s
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
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
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
/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
Thanks for the reply raz - though it were not what i were looking for ...
**Snooze
What are you looking 4 ??
i don't think i understand u!!
:D
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!
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
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)
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
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
also...u guys like my translateString(sString, sUserName, e, x, t) command???
Thanks for ICQ invite but im not running ICQ due to firewall blocking it at work :(
no problemo dude :D
Coraizon... hi :)
can you please post the complite script?