All pastes #907674 Raw Edit

irssi settings weirdness

public text v1 · immutable
·published 2008-02-17 20:41 UTC
rendered paste body
#!/usr/bin/perl

use warnings;
use strict;

use Irssi qw/
	settings_add_str settings_add_bool settings_add_int
	settings_get_str settings_get_bool settings_get_int
	settings_set_str settings_set_bool settings_set_int
	command command_bind command_unbind
	signal_emit signal_add_last
	timeout_add timeout_remove/;

our $VERSION = "0.1";
our %IRSSI = (
	authors     => 'Urchlay',
	contact     => 'Urchlay on NewNet',
	name        => 'urlmanager',
	description => 'Selectively strip colors from channels',
	license     => 'GNU GPLv2 or later',
	url         => 'none',
);

our $use_set_bool = 1;

sub pub_strip {
	my ($server, $text, $nick, $hostmask, $channel) = @_;

	my @list = split " ", settings_get_str('no_color_channels');
	if(grep { $channel =~ /$_/i } @list) {
		if($use_set_bool) {
			print "settings_set_bool('hide_colors', 1)";
			settings_set_bool('hide_colors', 1);
		} else {
			command("/set hide_colors ON");
		}
	} else {
		if($use_set_bool) {
			settings_set_bool('hide_colors', 0);
			print "settings_set_bool('hide_colors', 0)";
		} else {
			command("/set hide_colors OFF");
		}
	}

	command("/set hide_colors");
}

settings_add_str('colors_per_channel', 'no_color_channels', '');
signal_add_last('message public', \&pub_strip);

print "hide_colors: " .  settings_get_bool('hide_colors');

settings_set_bool('hide_colors', 0);

print "hide_colors: " .  settings_get_bool('hide_colors');