# awaysys.irc by phos # and yall thought i was finished # greets go to those that have emailed me # thanks for your support # # released on 7/12/05 # MY PEOPLE; alyssa kulj rza sgamer and my dog butane # danfare@jircii.info for feedback # http://deep.jircii.info/ for more of my scripts echo("* awaysys.irc: /awayset /away /back /lview"); alias away { if ($1 eq "help") { echo("/awayset /away /back /lview"); return; } $away = "true"; $_nicks = " "; if ($1 eq " ") { $amsg = "eaten"; } else { $amsg = "$1-"; } if (getProperty("pubmsg") eq "on") { call("/ame is now away: $amsg"); } sendRaw("away :" . "$amsg"); stopTimer($icheck); } alias awayset { if ($1 eq "") { call("/lawtog"); return; } if ($1 eq "atime") { if ($2 < 15) { echo("/awayset: sorry, please select 15 minutes or greater"); return; } $mintosec = $2 * 60; setProperty("atime", $mintosec); echo("/awayset: setting $1" . ": $2 minutes"); return; } if ($1 eq "sound") { if (-isFile "$2-" ) { setProperty("sound", "$2-"); $snd = soundFile(); echo("/awayset: changed sound file to: $snd"); } else { echo("/awayset: sorry, unable to locate $2- $+ . please check your /path/to/file.wav"); } return; } $regex = '(on|off)'; if ($2 ismatch $regex) { @match = matches($2, $regex); $match = @match[0]; if ($1 eq "pubmsg") { echo("/awayset: setting $1" . ": $2"); setProperty("pubmsg", $match); return; } if ($1 eq "page") { echo("/awayset: setting $1" . ": $2"); setProperty("page", $match); return; } if ($1 eq "playsnd") { echo("/awayset: setting $1" . ": $2"); setProperty("playsnd", $match); return; } if ($1 eq "log") { echo("/awayset: setting $1" . ": $2"); setProperty("log", $match); return; } if ($1 eq "notify") { echo("/awayset: setting $1" . ": $2"); setProperty("notify", $match); return; } if ($1 eq "auto") { echo("/awayset: setting $1" . ": $2"); setProperty("auto", $match); if ($match eq "on") { if ($icheck exists) { return; } $icheck = addTimer(&idlecheck, 2000); return; } else if ($icheck exists) { stopTimer($icheck); } } else { echo("/awayset: $1 is not known, please choose from list."); call("/lawtog"); } return; } else { echo("/away: /awayset toggle \bon|off\b"); return; } } sub idlecheck { if ($away eq "true") { return; } $itime = getIdleTime("$me"); $spectime = getProperty("atime"); if ($itime >= "$spectime") { $_spectime = $spectime / 60; call("/away idle $_spectime minutes (automatically set away)"); stopTimer($icheck); return; } } alias back { $away = "false"; $_nicks = " "; if (getProperty("auto") eq "on") { $icheck = addTimer(&idlecheck, 2000); } if (getProperty("pubmsg") eq "on") { call("/ame is back"); } if (getProperty("log") eq "on") { call("/lview"); } sendRaw("away"); } on public { if (getProperty("playsnd") eq "on") { if ("$me" isin "$1-") { awaySoundPlay(); } } } on msg { if ($away eq "true") { if (getProperty("playsnd") eq "on") { awaySoundPlay(); } if (getProperty("log") eq "on") { $__nick = $nick; $closewin = addTimer(&clWindow, 250, 1); call("writeLogFile MSG $nick $1-"); } if (getProperty("notify") eq "on") { if ($nick isin $_nicks) { return; } else { $_nicks = "$_nicks $nick"; call("/notice $nick i am currently away: $amsg"); } } } } sub clWindow { closeWindow("$__nick"); $__nick = ""; } on notice { if ($away eq "true") { if (getProperty("playsnd") eq "on") { awaySoundPlay(); } if (getProperty("log") eq "on") { call("writeLogFile NOTICE $nick $1-"); } } } on request { if ($away eq "true") { if (uc($1) eq "PAGE" && getProperty("page") eq "on") { awaySoundPlay(); } if (getProperty("playsnd") eq "on") { awaySoundPlay(); } if (getProperty("log") eq "on") { call("writeLogFile CTCP $nick $1-"); } } } on disconnect { if (getProperty("auto") eq "on") { stopTimer($icheck); } } on connect { if (getProperty("auto") eq "on") { $icheck = addTimer(&idlecheck, 2000); } } alias lawtog { echo("/awayset list " . "h" x 59); echo("h pubmsg: use /ame to let other users aware you are afk h" ); echo("h page: allow other users to /ctcp yournick page, play sound h"); echo("h playsnd: play a sound file for all private events (msg,notice,ctcp) h"); echo("h sound: which sound do you want to use (/path/to/sound.wav) h"); echo("h log: close incoming msg windows and save text to logfile h"); echo("h notify: notice people who msg,notice or ctcp you with away msg h"); echo("h auto: set away automatically for a specified idle time h"); echo("h atime: set how long before automatically set away (minutes) h"); echo("h" x 73); } sub soundFile { $sfile = getProperty("sound"); return $sfile; } sub awaySoundPlay { $sfile = getProperty("sound"); $snd = loadSound($sfile); soundPlay($snd); return; } #logging shiit alias writeLogFile { $_log = "$1-"; $ts = getTime(); $network = getServerNetwork(); $path = getScriptResource("awaysys.irc", "$network" . ".awaylog.log"); $x = ">> $+ $path"; $logfile = openf("$x"); @_log = readAll($logfile); println($logfile, "$ts $_log"); closef($logfile); } sub getTime { $_time = formatDate('MM/dd hh:mm:ss'); return $_time; } alias lview { logViewWindow(); } sub logViewWindow { #example taken from fakever.irc by blue-elf for window scripting (confusing to me) $network = getServerNetwork(); $path = getScriptResource("awaysys.irc", "$network" . ".awaylog.log"); $f = openf($path); @log = readAll($f); closef($f); @logArray = array(); if (-iswindow "While you were away...") { activateWindow("While you were away..."); } else { $logWin = showSortedList("While you were away...", "__logView", @logArray, " "); } foreach $_log (@log) { push(@logArray, $_log); } refreshData($logWin); activateWindow("While you were away..."); } menu __logView { $network = getServerNetwork(); $path = getScriptResource("awaysys.irc", "$network" . ".awaylog.log"); item "Clear LogFile" { deleteFile("$path"); clear(@logArray); refreshData($logWin); } }