summaryrefslogtreecommitdiff
path: root/.irssi
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2015-09-28 23:53:45 +0000
committerSean Whitton <spwhitton@spwhitton.name>2015-09-28 23:53:45 +0000
commit1327c39ee166d84980504875e6dc2b7afb63dc55 (patch)
tree534d4e795e02c16b937b9e21291d1d8387c66a6f /.irssi
parent6524d8838efc94dde51b2d5d1eb526c5b95aa7b3 (diff)
downloaddotfiles-1327c39ee166d84980504875e6dc2b7afb63dc55.tar.gz
neater away script
Diffstat (limited to '.irssi')
-rwxr-xr-x.irssi/scripts/autorun/anotherway.pl54
-rw-r--r--.irssi/scripts/autorun/autoaway.pl143
2 files changed, 54 insertions, 143 deletions
diff --git a/.irssi/scripts/autorun/anotherway.pl b/.irssi/scripts/autorun/anotherway.pl
new file mode 100755
index 00000000..f7a0ca88
--- /dev/null
+++ b/.irssi/scripts/autorun/anotherway.pl
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+#
+# by Stefan Tomanek <stefan@pico.ruhr.de>
+
+use strict;
+use vars qw($VERSION %IRSSI);
+$VERSION = "2003010201";
+%IRSSI = (
+ authors => "Stefan 'tommie' Tomanek",
+ contact => "stefan\@pico.ruhr.de",
+ name => "anotherway",
+ description => "Another auto away script",
+ license => "GPLv2",
+ changed => "$VERSION",
+);
+use Irssi 20020324;
+use vars qw($timer @signals);
+
+@signals = ('message own_public', 'message own_private');
+
+sub go_away {
+ #Irssi::print "%R>>%n Going away...$timer";
+ Irssi::timeout_remove($timer);
+ my $reason = Irssi::settings_get_str("anotherway_reason");
+ my @servers = Irssi::servers();
+ return unless @servers;
+ Irssi::signal_remove($_ , "reset_timer") foreach (@signals);
+ $servers[0]->command('AWAY '.$reason);
+ Irssi::signal_add($_ , "reset_timer") foreach (@signals);
+}
+
+sub reset_timer {
+ #Irssi::print "%R>>%n RESET";
+ Irssi::signal_remove($_ , "reset_timer") foreach (@signals);
+ foreach (Irssi::servers()) {
+ $_->command('AWAY') if $_->{usermode_away};
+ last;
+ }
+ #Irssi::signal_add('nd', "reset_timer");
+ Irssi::timeout_remove($timer);
+ my $timeout = Irssi::settings_get_int("anotherway_timeout");
+ $timer = Irssi::timeout_add($timeout*1000, "go_away", undef);
+ Irssi::signal_add($_, "reset_timer") foreach (@signals);
+}
+
+Irssi::settings_add_str($IRSSI{name}, 'anotherway_reason', 'a-nother-way');
+Irssi::settings_add_int($IRSSI{name}, 'anotherway_timeout', 300);
+
+{
+ Irssi::signal_add($_, "reset_timer") foreach (@signals);
+ reset_timer();
+}
+
+print CLIENTCRAP '%B>>%n '.$IRSSI{name}.' '.$VERSION.' loaded';
diff --git a/.irssi/scripts/autorun/autoaway.pl b/.irssi/scripts/autorun/autoaway.pl
deleted file mode 100644
index be6cbf7b..00000000
--- a/.irssi/scripts/autorun/autoaway.pl
+++ /dev/null
@@ -1,143 +0,0 @@
-# /AUTOAWAY <n> - Mark user away after <n> seconds of inactivity
-# /AWAY - play nice with autoaway
-# New, brighter, whiter version of my autoaway script. Actually works :)
-# (c) 2000 Larry Daffner (vizzie@airmail.net)
-# You may freely use, modify and distribute this script, as long as
-# 1) you leave this notice intact
-# 2) you don't pretend my code is yours
-# 3) you don't pretend your code is mine
-#
-# share and enjoy!
-
-# A simple script. /autoaway <n> will mark you as away automatically if
-# you have not typed any commands in <n> seconds. (<n>=0 disables the feature)
-# It will also automatically unmark you away the next time you type a command.
-# Note that using the /away command will disable the autoaway mechanism, as
-# well as the autoreturn. (when you unmark yourself, the autoaway wil
-# restart again)
-
-# Thanks to Adam Monsen for multiserver and config file fix
-
-use strict;
-use Irssi;
-use Irssi::Irc;
-
-use vars qw($VERSION %IRSSI);
-$VERSION = "0.3";
-%IRSSI = (
- authors => 'Larry "Vizzie" Daffner',
- contact => 'vizzie@airmail.net',
- name => 'Automagic away setting',
- description => 'Automatically goes away after defined inactivity',
- license => 'BSD',
- url => 'http://www.flamingpackets.net/~vizzie/irssi/',
- changed => 'Tue Oct 19 14:41:15 CDT 2010',
- changes => 'Applied multiserver/store config patch from Adam Monsen'
-);
-
-my ($autoaway_sec, $autoaway_to_tag, $autoaway_state);
-$autoaway_state = 0;
-
-#
-# /AUTOAWAY - set the autoaway timeout
-#
-sub cmd_autoaway {
- my ($data, $server, $channel) = @_;
-
- if (!($data =~ /^[0-9]+$/)) {
- Irssi::print("autoaway: usage: /autoaway <seconds>");
- return 1;
- }
-
- $autoaway_sec = $data;
-
- if ($autoaway_sec) {
- Irssi::settings_set_int("autoaway_timeout", $autoaway_sec);
- Irssi::print("autoaway timeout set to $autoaway_sec seconds");
- } else {
- Irssi::print("autoway disabled");
- }
-
- if (defined($autoaway_to_tag)) {
- Irssi::timeout_remove($autoaway_to_tag);
- $autoaway_to_tag = undef;
- }
-
- if ($autoaway_sec) {
- $autoaway_to_tag =
- Irssi::timeout_add($autoaway_sec*1000, "auto_timeout", "");
- }
-}
-
-#
-# away = Set us away or back, within the autoaway system
-sub cmd_away {
- my ($data, $server, $channel) = @_;
-
- if ($data eq "") {
- $autoaway_state = 0;
- # If $autoaway_state is 2, we went away by typing /away, and need
- # to restart autoaway ourselves. Otherwise, we were autoaway, and
- # we'll let the autoaway return take care of business.
-
- if ($autoaway_state eq 2) {
- if ($autoaway_sec) {
- $autoaway_to_tag =
- Irssi::timeout_add($autoaway_sec*1000, "auto_timeout", "");
- }
- }
- } else {
- if ($autoaway_state eq 0) {
- Irssi::timeout_remove($autoaway_to_tag);
- $autoaway_to_tag = undef;
- $autoaway_state = 2;
- }
- }
-}
-
-sub auto_timeout {
- my ($data, $server) = @_;
-
- # we're in the process.. don't touch anything.
- $autoaway_state = 3;
- foreach my $server (Irssi::servers()) {
- $server->command("/AWAY autoaway after $autoaway_sec seconds");
- }
-
- Irssi::timeout_remove($autoaway_to_tag);
- $autoaway_state = 1;
-}
-
-sub reset_timer {
- if ($autoaway_state eq 1) {
- $autoaway_state = 3;
- foreach my $server (Irssi::servers()) {
- $server->command("/AWAY");
- }
-
- $autoaway_state = 0;
- }
- if ($autoaway_state eq 0) {
- if (defined($autoaway_to_tag)) {
- Irssi::timeout_remove($autoaway_to_tag);
- $autoaway_to_tag = undef();
- }
- if ($autoaway_sec) {
- $autoaway_to_tag = Irssi::timeout_add($autoaway_sec*1000
- , "auto_timeout", "");
- }
- }
-}
-
-Irssi::settings_add_int("misc", "autoaway_timeout", 0);
-
-my $autoaway_default = Irssi::settings_get_int("autoaway_timeout");
-if ($autoaway_default) {
- $autoaway_to_tag =
- Irssi::timeout_add($autoaway_default*1000, "auto_timeout", "");
-
-}
-
-Irssi::command_bind('autoaway', 'cmd_autoaway');
-Irssi::command_bind('away', 'cmd_away');
-Irssi::signal_add('send command', 'reset_timer');