aboutsummaryrefslogtreecommitdiffstats
path: root/auto-server
diff options
context:
space:
mode:
authorricho <richo@psych0tik.net>2011-01-01 14:43:50 +0000
committerricho <richo@psych0tik.net>2011-01-01 14:45:18 +0000
commit7aae676e7108f672c91f05ad5dccf4dab531a534 (patch)
treed75989c155ea6a01554e01dd43fdd84318937867 /auto-server
parentuberprompt: hopefully a fix for Irssi::Nick not found irssi bug weirdness. (diff)
downloadirssi-scripts-richoH-master.tar.gz
irssi-scripts-richoH-master.zip
Uses the channel add [] infracstructure as a datastore.richoH-master
Diffstat (limited to 'auto-server')
-rw-r--r--auto-server/auto_server.pl48
1 files changed, 42 insertions, 6 deletions
diff --git a/auto-server/auto_server.pl b/auto-server/auto_server.pl
index 82382f7..7054664 100644
--- a/auto-server/auto_server.pl
+++ b/auto-server/auto_server.pl
@@ -1,3 +1,6 @@
+# This script was initially written by shabble, this fork (and molestation) is
+# built upon his original work.
+#
# USAGE:
#
# the primary command used is /join+ #channelname
@@ -13,6 +16,10 @@
# Then use /join+ #foo, and if you are not already connected to freenode, it
# will connect you, and then join that channel.
+# TODO:
+# Autocompletion for channel names
+# address conflict resolution
+# fix that disgusting race condition
use strict;
use warnings;
@@ -39,16 +46,17 @@ sub _debug_print {
our $VERSION = '0.1';
our %IRSSI = (
- authors => 'shabble',
- contact => 'shabble+irssi@metavore.org',
- name => 'auto-join',
- description => 'connects to a specified server in order to connect'
- ' to a channel there, without having first to'
+ authors => 'shabble, richo',
+ contact => 'richo@psych0tik.net',
+ name => 'auto-join-ng',
+ description => 'connects to a specified server in order to connect' .
+ ' to a channel there, without having first to' .
' connect to the server',
license => 'Public Domain',
);
my $channel_map;
+my @hack_channels;
my $pending_joins;
sub auto_server_init {
@@ -67,8 +75,36 @@ sub setup_changed {
parse_channel_map();
}
+# This is a tremendous kludge.
+# If anyone knows a better way to get this listing, I'd like to hear it.
+# This has so many race condition bugs I just don't even know where to start.
+sub retrieve_channels {
+ @hack_channels = ();
+ Irssi::signal_add_first('print text', 'haxy_print_hook');
+ Irssi::command("CHANNEL LIST");
+ Irssi::signal_remove('print text', 'haxy_print_hook');
+ return join(" ", @hack_channels);
+}
+
+
+# The idea for how to do this courtesy of http://wouter.coekaerts.be/site/irssi/aliases
+sub haxy_print_hook {
+ Irssi::signal_remove('print text', 'haxy_print_hook');
+ Irssi::signal_stop();
+ my $data = $_[1];
+ # Hose control characters
+ $data =~ s/\x04.//g;
+ if ($data =~ m/^#/) {
+ my @items = split /\s+/, $data;
+ push(@hack_channels, $items[0]);
+ push(@hack_channels, $items[1]);
+ }
+ Irssi::signal_add_first('print text', 'haxy_print_hook');
+}
+
sub parse_channel_map {
- my $data = Irssi::settings_get_str('joinplus_server_maps');
+ #my $data = Irssi::settings_get_str('joinplus_server_maps');
+ my $data = retrieve_channels();
my @items = split /\s+/, $data;
if (@items % 2 == 0) {
$channel_map = { @items }; # risky?