aboutsummaryrefslogtreecommitdiffstats
path: root/trivia
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-08-22 17:45:20 +0000
committerterminaldweller <devi@terminaldweller.com>2023-08-22 17:45:20 +0000
commit0ddfe89492fa77cfd72aacb74022b680c8665e48 (patch)
treef562424880442f2cb05cc6bfd3158d37815a4560 /trivia
parenta fix for the dead channels (diff)
downloadirssi-scripts-0ddfe89492fa77cfd72aacb74022b680c8665e48.tar.gz
irssi-scripts-0ddfe89492fa77cfd72aacb74022b680c8665e48.zip
added a trivia script
Diffstat (limited to 'trivia')
-rw-r--r--trivia/trivia.pl41
1 files changed, 41 insertions, 0 deletions
diff --git a/trivia/trivia.pl b/trivia/trivia.pl
new file mode 100644
index 0000000..6cc0fea
--- /dev/null
+++ b/trivia/trivia.pl
@@ -0,0 +1,41 @@
+use Irssi;
+use strict;
+
+our $VERSION = "0.1";
+our %IRSSI = (
+ authors => 'terminaldweller',
+ contact => 'https://terminaldweller.com',
+ name => 'trivia',
+ description => 'lets you add trivial info for a window as a expando',
+ license => 'GPL3 or newer',
+ url => 'https://github.com/irssi/scripts.irssi.org',
+);
+
+my %trivia_list = ();
+my $trivia = "";
+
+sub window_changed_handler {
+ my $window = Irssi::active_win();
+ my $server = Irssi::active_server();
+ my $current_window_item_string = $server->{tag}."/".$window->{active}->{name};
+ if (exists $trivia_list{$current_window_item_string}) {
+ $trivia = $trivia_list{$current_window_item_string};
+ } else {
+ $trivia = "IRC";
+ }
+}
+
+Irssi::expando_create('trivia', sub {
+ return $trivia;
+}, {});
+
+sub setup_changed {
+ %trivia_list = map { my @temp = split(',', $_); $temp[0] => $temp[1] } split(' ', Irssi::settings_get_str('trivia_list'));
+}
+
+Irssi::settings_add_str('misc','trivia_list','');
+Irssi::signal_add('window changed' => 'window_changed_handler');
+Irssi::signal_add('setup changed' => 'setup_changed');
+
+%trivia_list = map { my @temp = split(',', $_); $temp[0] => $temp[1] } split(' ', Irssi::settings_get_str('trivia_list'));
+Irssi::print(%trivia_list);