Guest User

Untitled

a guest
Oct 14th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.81 KB | None | 0 0
  1. # USAGE: /topicmod [newtopic]
  2.  
  3. sub cmd_topicmod {
  4.         my ($newtopic, $server, $witem) = @_;
  5.         my $topiclen = 80;
  6.         my $oldtopic;
  7.         my $divider = " || ";
  8.  
  9.         if (!$server || !$server->{connected}) {
  10.                 Irssi::print("Not connected to server");
  11.                 return;
  12.         }
  13.  
  14.         if($witem && $witem->{type} eq "CHANNEL") {
  15.                 $oldtopic = $witem->{topic};
  16.                 my $temptopic = $newtopic . $divider . $oldtopic;
  17.                 if(length($temptopic) <= 80) {
  18.                         $server->command("TOPIC ".$witem->{name}." ".$temptopic);
  19.                 } else {
  20.                         Irssi::print("Topic too long");                      
  21.                 }
  22.         }
  23. }        
  24.  
  25. Irssi::command_bind('topicmod', 'cmd_topicmod');
Add Comment
Please, Sign In to add comment