1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #39 from ailin-nemui/sync

run syncdocs.sh and syncscripts.sh

(cherry picked from commit 85a9dc146d)
This commit is contained in:
ailin-nemui 2021-09-22 12:33:10 +02:00 committed by Ailin Nemui
parent 117758fb90
commit 0ba449d8be
6 changed files with 104 additions and 80 deletions

View File

@ -2,7 +2,7 @@
<h1>Frequently Asked Questions</h1>
<h3 id="q-why-doesnt-irssi-display-colors-even-when-ircii-etc-displays-them">Q: Why doesnt irssi display colors even when ircii etc. displays them?</h3>
<p>A: They force ANSI colors even if terminal doesnt support them. By default, irssi uses colors only if terminfo/termcap so says. The correct way to fix this would be to change your TERM environment to a value where colors work, like xterm-color or color_xterm (eg. <code>TERM=xterm-color irssi</code>). If this doesnt help, then use the evil way of <code>/SET term_force_colors ON</code>.</p>
<p>A: They force ANSI colors even if terminal doesnt support them. By default, irssi uses colors only if terminfo/termcap so says. The correct way to fix this would be to change your TERM environment to a value where colors work, like xterm-256color or color_xterm (eg. <code>TERM=xterm-256color irssi</code>). If this doesnt help, then use the evil way of <code>/SET term_force_colors ON</code>.</p>
<h3 id="q-how-do-i-easily-write-text-to-channel-that-starts-with--character">Q: How do I easily write text to channel that starts with / character?</h3>
@ -54,7 +54,7 @@
<h3 id="q-will-there-be-detach-like-feature">Q: Will there be /DETACH-like feature?</h3>
<p>A: <a href="https://tmux.github.io/">tmux</a>, <a href="https://www.gnu.org/software/screen/screen.html">screen</a> and <a href="http://dtach.sf.net/">dtach</a> can be used to do it just fine.</p>
<p>A: <a href="https://tmux.github.io/">tmux</a>, <a href="https://www.gnu.org/software/screen/screen.html">screen</a> and <a href="https://sourceforge.net/projects/dtach/">dtach</a> can be used to do it just fine.</p>
<h3 id="q-how-do-i-run-scripts-automatically-at-startup">Q: How do I run scripts automatically at startup?</h3>

View File

@ -4,8 +4,8 @@ Q: Why doesnt irssi display colors even when ircii etc. displays them?
A: They force ANSI colors even if terminal doesnt support them. By default,
irssi uses colors only if terminfo/termcap so says. The correct way to fix this
would be to change your TERM environment to a value where colors work, like
xterm-color or color_xterm (eg. TERM=xterm-color irssi). If this doesnt help,
then use the evil way of /SET term_force_colors ON.
xterm-256color or color_xterm (eg. TERM=xterm-256color irssi). If this doesnt
help, then use the evil way of /SET term_force_colors ON.
Q: How do I easily write text to channel that starts with / character?
A: / /text
@ -119,6 +119,6 @@ A: Check [6]here
[1] https://github.com/irssi-import/xirssi
[2] https://tmux.github.io/
[3] https://www.gnu.org/software/screen/screen.html
[4] http://dtach.sf.net/
[4] https://sourceforge.net/projects/dtach/
[5] https://dgl.cx/irssi/hack-whois-in-current-window.pl
[6] https://irssi.org/assets/irssi.wav

View File

@ -226,7 +226,7 @@ Ctrl-P, Ctrl-N - Jump to previous / next window
<p>And finally channels:</p>
<div><div><pre><code>/CHANNEL ADD -auto -bots *!*user@host -botcmd "/^msg $0 op pass" #irssi efnet
<div><div><pre><code>/CHANNEL ADD -auto -bots *!*bot@host.org -botcmd "/^msg $0 op pass" #irssi efnet
/CHANNEL ADD -auto #secret IRCnet password
</code></pre></div></div>
@ -395,7 +395,7 @@ Ctrl-X - set the next server in list active
<p><code>/HELP bind</code> tells pretty much everything there is to know about keyboard bindings. However, theres the problem of how to bind some non-standard keys. They might differ a bit with each terminal, so youll need to find out what exactly the keypress produces. Easiest way to check that would be to see what it prints in <code>cat</code>. Heres an example for pressing F1 key:</p>
<div><div><pre><code> [user@host] ~% cat
<div><div><pre><code> [cras@hurina] ~% cat
^[OP
</code></pre></div></div>

View File

@ -218,7 +218,7 @@ IRC network, other servers are automatically connected in same network if the
And finally channels:
/CHANNEL ADD -auto -bots *!*user@host -botcmd "/^msg $0 op pass" #irssi efnet
/CHANNEL ADD -auto -bots *!*bot@host.org -botcmd "/^msg $0 op pass" #irssi efnet
/CHANNEL ADD -auto #secret IRCnet password
-bots and -botcmd should be the only ones needing a bit of explaining. Theyre
@ -442,7 +442,7 @@ They might differ a bit with each terminal, so youll need to find out what
exactly the keypress produces. Easiest way to check that would be to see what
it prints in cat. Heres an example for pressing F1 key:
[user@host] ~% cat
[cras@hurina] ~% cat
^[OP
So in irssi you would use /BIND ^[OP /ECHO F1 pressed. If you use multiple

View File

@ -6,36 +6,27 @@ use Irssi::Irc;
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "1.00";
$VERSION = "1.01";
%IRSSI = (
authors => 'Timo Sirainen',
name => 'quitmsg',
description => 'Random quit messages',
license => 'Public Domain',
changed => 'Sun Mar 10 23:18 EET 2002'
changed => 'Mon Jul 22 20:00 EET 2020'
);
my $quitfile = glob "~/.irssi/irssi.quit";
my $quitfile = Irssi::get_irssi_dir() . "/irssi.quit";
sub cmd_quit {
my ($data, $server, $channel) = @_;
return if ($data ne "");
open (f, "<", $quitfile) || return;
my $lines = 0; while(<f>) { $lines++; };
open (my $fh, "<", $quitfile) || return;
my @lines = <$fh>;
my $line = int(rand($lines))+1;
my $quitmsg;
seek(f, 0, 0); $. = 0;
while(<f>) {
next if ($. != $line);
chomp;
$quitmsg = $_;
last;
}
close(f);
my $quitmsg = $lines[int(rand(@lines))];
chomp($quitmsg);
close($fh);
foreach my $server (Irssi::servers) {
$server->command("/disconnect ".$server->{tag}." $quitmsg");

View File

@ -5,7 +5,7 @@
use strict;
our $VERSION = '2003020807';
our $VERSION = '2020042700';
our %IRSSI = (
authors => 'Stefan \'tommie\' Tomanek',
contact => 'stefan@pico.ruhr.de',
@ -23,12 +23,15 @@ use Irssi 20020324;
use CPAN::Meta::YAML;
use LWP::UserAgent;
use POSIX;
use version;
# GnuPG is not always needed
$have_gpg = 0;
eval "use GnuPG qw(:algo :trust);";
$have_gpg = 1 if not ($@);
my $irssi_version = qv(Irssi::parse_special('v$J') =~ s/-.*//r);
sub show_help {
my $help = "scriptassist $VERSION
/scriptassist check
@ -39,15 +42,15 @@ sub show_help {
Search the script database
/scriptassist info <scripts>
Display information about <scripts>
".#/scriptassist ratings <scripts>
# Retrieve the average ratings of the the scripts
#/scriptassist top <num>
# Retrieve the first <num> top rated scripts
"/scriptassist new <num>
/scriptassist ratings <scripts|all>
Retrieve the average ratings of the the scripts
/scriptassist top <num>
Retrieve the first <num> top rated scripts
/scriptassist new <num>
Display the newest <num> scripts
".#/scriptassist rate <script> <stars>
# Rate the script with a number of stars ranging from 0-5
"/scriptassist contact <script>
/scriptassist rate <script>
Rate the script if you like it
/scriptassist contact <script>
Write an email to the author of the script
(Requires OpenURL)
/scriptassist cpan <module>
@ -95,6 +98,7 @@ sub call_openurl {
$code->($url);
} else {
print CLIENTCRAP "%R>>%n Please install openurl.pl";
print CLIENTCRAP "%R>>%n or open < $url > manually";
}
}
@ -188,7 +192,7 @@ sub get_unknown {
foreach (keys %$db) {
next unless defined $db->{$_}{commands};
foreach my $item (split / /, $db->{$_}{commands}) {
return { $_ => $db->{$_} } if ($item =~ /^$cmd$/i);
return { $_ => +{%{$db->{$_}}} } if ($item =~ /^$cmd$/i);
}
}
return undef;
@ -264,47 +268,80 @@ sub script_info {
$result{$sname}{modules}{$mod}{installed} = module_exist($mod);
}
}
if (defined $xml->{$plname}{depends}) {
my $depends = $xml->{$plname}{depends};
foreach my $dep (split(/ /, $depends)) {
$result{$sname}{depends}{$dep}{installed} = 1;
}
}
# if (defined $xml->{$plname}{depends}) {
# my $depends = $xml->{$plname}{depends};
# foreach my $dep (split(/ /, $depends)) {
# $result{$sname}{depends}{$dep}{installed} = 1; #(defined ${ 'Irssi::Script::'.$dep });
# }
# }
}
return \%result;
}
sub get_rate_url {
my ($src) = @_;
my $ua = LWP::UserAgent->new(env_proxy=>1, keep_alive=>1, timeout=>30);
$ua->agent('ScriptAssist/'.$VERSION);
my $request = HTTP::Request->new('GET', $src);
my $response = $ua->request($request);
unless ($response->is_success) {
my $error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
die("Fetching ratings location failed: $error");
}
my $votes_url;
for my $tag ($response->content() =~ /<script([^>]*)>/g) {
my $attr = " $tag ";
($votes_url = $1) =~ s/\.\w+$/.yml/
if $attr =~ /\sasync\s/ && $attr =~ m{\ssrc="(https?://.*?/votes\.\w+)"\s};
}
unless ($votes_url) {
die("Fetching ratings failed: Could not find votes script\n");
}
$request = HTTP::Request->new('GET', $votes_url);
$response = $ua->request($request);
if (!$response->is_success) {
my $error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
die("Fetching ratings failed: $error");
}
my $data = $response->content();
utf8::decode($data);
CPAN::Meta::YAML->read_string($data)->[0];
}
sub rate_script {
my ($script, $stars) = @_;
my $ua = LWP::UserAgent->new(env_proxy=>1, keep_alive=>1, timeout=>30);
$ua->agent('ScriptAssist/'.2003020803);
my $request = HTTP::Request->new('GET', 'http://ratings.irssi.de/irssirate.pl?&stars='.$stars.'&mode=rate&script='.$script);
my $response = $ua->request($request);
unless ($response->is_success() && $response->content() =~ /You already rated this script/) {
return 1;
} else {
return 0;
}
my $xml = get_scripts();
my $votes = get_rate_url(map { $_->{source} } values %$xml);
my ($sname, $plname, $pname) = get_names($script, $xml);
die "Script $script not found\n" unless $votes->{$plname};
return $votes->{$plname}{u}
}
sub get_ratings {
my ($scripts, $limit) = @_;
my $ua = LWP::UserAgent->new(env_proxy=>1, keep_alive=>1, timeout=>30);
$ua->agent('ScriptAssist/'.2003020803);
my $script = join(',', @{$scripts});
my $request = HTTP::Request->new('GET', 'http://ratings.irssi.de/irssirate.pl?script='.$script.'&sort=rating&limit='.$limit);
my $response = $ua->request($request);
my %result;
if ($response->is_success()) {
foreach (split /\n/, $response->content()) {
if (/<tr><td><a href=".*?">(.*?)<\/a>/) {
my $entry = $1;
if (/"><\/td><td>([0-9.]+)<\/td><td>(.*?)<\/td><td>/) {
$result{$entry} = [$1, $2];
}
}
my $xml = get_scripts();
my $votes = get_rate_url(map { $_->{source} } values %$xml);
foreach (keys %{$votes}) {
if ($xml->{$_}) {
$xml->{$_}{votes} = $votes->{$_}{v};
}
}
my %result;
if (@{$scripts}) {
foreach (@{$scripts}) {
my ($sname, $plname, $pname) = get_names($_, $xml);
next unless (defined $xml->{$plname} || ( exists $Irssi::Script::{$pname} && exists $Irssi::Script::{$pname}{IRSSI} ));
$result{$plname} = [$xml->{$plname}{votes}];
}
} else {
my @keys = sort { $xml->{$b}{votes} <=> $xml->{$a}{votes}
|| $xml->{$b}{modified} cmp $xml->{$a}{modified} }
grep { !$xml->{$_}{HIDDEN} && $xml->{$_}{votes} ne '' } keys %$xml;
foreach (splice @keys, 0, $limit) {
$result{$_} = [$xml->{$_}{votes}];
}
}
die "No such script found\n" unless keys %result;
return \%result;
}
@ -597,13 +634,8 @@ sub print_rate {
my (%data) = @_;
my $line;
foreach my $script (sort keys(%data)) {
if ($data{$script}) {
$line .= "%go%n %9".$script."%9 has been rated";
} else {
$line .= "%ro%n %9".$script."%9 : Already rated this script";
}
call_openurl($data{$script});
}
print CLIENTCRAP draw_box('ScriptAssist', $line, 'rating', 1) ;
}
sub print_ratings {
@ -617,8 +649,7 @@ sub print_ratings {
push @line, "%yo%n";
}
push @line, "%9".$script."%9";
push @line, $data{$script}{rating};
push @line, "[".$data{$script}{votes}." votes]";
push @line, "[".(length $data{$script}{rating} ? $data{$script}{rating} : 'no')." votes]";
push @table, \@line;
}
print CLIENTCRAP draw_box('ScriptAssist', array2table(@table), 'ratings', 1) ;
@ -845,7 +876,8 @@ sub get_scripts {
}
$fetched = 1;
my $data = $response->content();
my ($src, $type);
my $src = $site;
my $type = '';
if ($site =~ /(.*\/).+\.(.+)/) {
$src = $1;
$type = $2;
@ -1115,9 +1147,9 @@ sub cmd_scripassist {
} elsif ($args[0] eq 'ratings' && defined $args[1]) {
shift @args;
bg_do("ratings ".join(' ', @args));
} elsif ($args[0] eq 'rate' && defined $args[1] && defined $args[2]) {
} elsif ($args[0] eq 'rate' && defined $args[1]) {
shift @args;
bg_do("rate ".join(' ', @args)) if ($args[2] >= 0 && $args[2] < 6);
bg_do("rate ".join(' ', @args));
} elsif ($args[0] eq 'info' && defined $args[1]) {
shift @args;
bg_do("info ".join(' ', @args));
@ -1158,6 +1190,7 @@ sub sig_command_script_load {
sub sig_default_command {
my ($cmd, $server) = @_;
return unless Irssi::settings_get_bool("scriptassist_check_unknown_commands");
return if ($cmd =~ /^\d+$/ && $irssi_version >= v1.2.0 && Irssi::settings_get_bool("window_number_commands"));
bg_do('unknown '.$cmd);
}
@ -1213,11 +1246,11 @@ foreach my $cmd ( ( 'check',
'search',
# '-h',
'help',
# 'ratings',
# 'rate',
'ratings',
'rate',
'info',
# 'echo',
# 'top',
'top',
'cpan',
'autorun',
'new' ) ) {