From: vague666 Date: Mon, 17 May 2021 13:09:36 +0000 (+0200) Subject: [securemsg] Add clear command to clear message queue without action X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=2bfba3740373f17f6ba4fdeef93fffee583c8c52;p=irssi-scripts.irssi.org.git [securemsg] Add clear command to clear message queue without action --- diff --git a/scripts/securemsg.pl b/scripts/securemsg.pl index 3b7cfb6..41fa7e7 100644 --- a/scripts/securemsg.pl +++ b/scripts/securemsg.pl @@ -42,7 +42,7 @@ use Irssi::TextUI; use vars qw($VERSION %IRSSI); -$VERSION = "2.2.1"; +$VERSION = "2.3.0"; my $APPVERSION = "Securemsg v$VERSION"; %IRSSI = ( authors => "Jari Matilainen, a lot of code borrowed from whitelist.pl by David O\'Rourke and Karl Siegemund", @@ -51,7 +51,7 @@ my $APPVERSION = "Securemsg v$VERSION"; description => "An irssi adaptation of securequery.mrc found in the Acidmax mIRC script. :), now with multiserver support", sbitems => "securemsg", license => "GPLv2", - changed => "10.09.2007 11:30pm GST" + changed => "17.05.2021 15:00" ); my $whitenick; @@ -403,6 +403,7 @@ Commands: SM HELP - SHOWS THIS HELP SM ADD|DEL NICK|HOST | - ADDS/DELETES A SPACE SEPARATED LIST OF NICKS OR HOSTS SM NICKS|HOSTS - DISPLAYS THE CURRENT WHITELISTED NICKS OR HOSTS +SM CLEAR [net ] - CLEAR CURRENT MESSAGES FROM nick WITHOUT ACCEPTING OR REJECTING nick SM ACCEPT [net ] [message] - ALLOWS MSG'S FROM nick SM REJECT [net ] [message] - DOESN'T ALLOW MESSAGES FROM nick SM REJIDX - - DOESN'T ALLOW MESSAGES FROM ALL NICKS IN THE GIVEN RANGE @@ -516,6 +517,38 @@ sub cmd_show { } } +sub cmd_clear { + my ($args, $server, $witem) = @_; + my ($nick, $net) = _get_nn($args); + my $server; + + if((!defined $nick) || (!exists $messages{$nick})) { + usage; + return; + } + + if(defined $net && !(($net eq " ") || ($net eq ""))) { + foreach (keys %{$messages{$nick}}) { + if($_ eq $net) { + $server = Irssi::server_find_tag($_); + last; + } + } + } + elsif(keys(%{$messages{$nick}}) == 1) { + foreach (keys %{$messages{$nick}}) { + $server = Irssi::server_find_tag($_); + } + } + else { + print("You have to specify a chatnet, for example /sm clear john net EFNet"); + return; + } + + delete $messages{$nick}{lc($server->{tag})}{messages}; + refresh_securemsg(); +} + sub securemsg { my ($item,$get_size_only) = @_; my $result = 0; @@ -572,6 +605,7 @@ Irssi::command_bind('sm del',\&cmd_del); Irssi::command_bind('sm nicks',\&cmd_nicks); Irssi::command_bind('sm hosts',\&cmd_hosts); Irssi::command_bind('sm show',\&cmd_show); +Irssi::command_bind('sm clear',\&cmd_clear); Irssi::command_bind('sm showall',\&cmd_showall); Irssi::command_bind('sm accept',\&cmd_accept); Irssi::command_bind('sm reject',\&cmd_reject);