Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions scripts/example.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
use strict;
use vars qw($VERSION %IRSSI);

use Irssi;

$VERSION = '0.01';
%IRSSI = (
authors => 'noname',
contact => 'noname@example.org',
name => 'example',
description => 'This script really does nothing. Sorry.',
license => 'Public Domain',
url => 'https://scripts.irssi.org/',
changed => '2019-06-07',
modules => '',
commands=> 'example',
);

my $help = << "END";
%9Name%9
$IRSSI{name}
%9Version%9
$VERSION
%9description%9
$IRSSI{description}
%9See also%9
null.pl
https://perldoc.perl.org/perl.html
https://github.com/irssi/irssi/blob/master/docs/perl.txt
https://github.com/irssi/irssi/blob/master/docs/signals.txt
https://github.com/irssi/irssi/blob/master/docs/formats.txt
END

my $test_str;

sub cmd {
my ($args, $server, $witem)=@_;
if (defined $witem) {
$witem->printformat(MSGLEVEL_CLIENTCRAP, 'example_theme',
$test_str, $test_str, $test_str);
} else {
Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'example_theme',
$test_str, $test_str, $test_str);
}
}

sub cmd_help {
my ($args, $server, $witem)=@_;
$args=~ s/\s+//g;
if ($IRSSI{name} eq $args) {
Irssi::print($help, MSGLEVEL_CLIENTCRAP);
Irssi::signal_stop();
}
}

sub sig_setup_changed {
$test_str= Irssi::settings_get_str($IRSSI{name}.'_test_str');
}

Irssi::theme_register([
'example_theme', '{hilight $0} $1 {error $2}',
]);

Irssi::signal_add('setup changed', \&sig_setup_changed);

Irssi::settings_add_str($IRSSI{name} ,$IRSSI{name}.'_test_str', 'hello world!');
Comment thread
dwfreed marked this conversation as resolved.

Irssi::command_bind($IRSSI{name}, \&cmd);
Irssi::command_bind('help', \&cmd_help);

sig_setup_changed();