summary refs log tree commit diff stats
AgeCommit message (Expand)Author
2013-06-12Don't open libcanberra connection for every eventTingPing
2013-06-09Merge pull request #640 from orium/default-languageTingPing
2013-06-09Add irc_ban_type to preferencesTingPing
2013-06-09Specify what for completion amountTingPing
2013-06-09Emit FOUNDIP in server sessionTingPing
2013-06-09Add completion_amount to prefsTingPing
2013-06-09Fix printing ipv6 addresses with identdTingPing
2013-06-08Add more mnemonics to the menuTingPing
2013-06-08Merge pull request #641 from orium/possible-buffer-overflow-fixTingPing
2013-06-08Minor cosmetic changesDiogo Sousa
2013-06-08Renamed tbuf to buf in create_mask() to avoid confusion.Diogo Sousa
2013-06-08Fixed possible overflow in create_mask().Diogo Sousa
2013-06-08Now the default configuration tries to set the language from the systemDiogo Sousa
2013-06-07Change default irc_ban_type to 1TingPing
2013-06-07Add QUIET commandTingPing
2013-06-07Take two at fixing xtext copying to secondary clipboardTingPing
2013-06-07Merge pull request #636 from Remmy/masterTingPing
2013-06-07Add Serenity-IRC to the list of networks available by default.Remco Rijnders
2013-06-06Save chanopt after any changesTingPing
2013-06-06Add chanopt for stripping colorsTingPing
2013-06-06Add autoconnect option to menu of networksTingPing
2013-06-06Make autojoin a toggle menuTingPing
2013-06-05Handle /CAP LIST outputTingPing
2013-06-05update help message for /menuTingPing
2013-06-04Add missing gtk_tree_path_free()TingPing
2013-06-04Add copy option to right click in banlistTingPing
2013-06-04Merge pull request #634 from youknowone/ipv6TingPing
2013-06-04Retrieve reachable addresses only.Jeong YunWon
2013-06-04copy xtext selection to all clipboardsTingPing
2013-06-04Improve error message from /load -eTingPing
2013-06-04Python: revert 43bd9483ceTingPing
2013-06-04fix loading startup.txt automaticallyTingPing
2013-06-03treat banlist event as a generic list event (for quiets etc)TingPing
2013-06-02translate servlist tabsTingPing
2013-06-02Rename favorite channels to autojoin channelsTingPing
2013-06-02Merge pull request #633 from FionnK/masterTingPing
2013-06-03Remove IPv6 check for IRCNode entry in server list.Fionn Kelleher
2013-06-03Add IRCNode to the server list.Fionn Kelleher
2013-06-02Python: return true/false from set/del_pluginprefTingPing
2013-06-02Python: Save pluginprefs to seperate filesTingPing
2013-06-01be more specific about sysinfo menu entryTingPing
2013-06-01configure.ac: Use pkg-config's CFLAGS for libxml2 instead of guessing our own.Arnav Singh
2013-05-31Add valleynode to network listTingPing
2013-05-30fix crashTingPing
2013-05-29add .js to list of loadable filetypesTingPing
2013-05-25Don't send previous session's passwordTingPing
2013-05-25Merge pull request #625 from orium/network-name-improveTingPing
2013-05-25Improved server_get_network(): if we don't have the current network in theDiogo Sousa
2013-05-24Merge pull request #624 from Niichan/masterTingPing
2013-05-24Added PonyChat to network listSam Dodrill
href='#n158'>158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257




                                              
                                                                                   







                                                              
                                                                       
















                                                                  
                                                                       












                                                        
                                                                       












                                                                              
                                                                       



































































                                                                 
                                                                                       






























































































































                                                                               
package IRC;
sub IRC::register {
  my ($script_name, $version, $callback) = @_;
  my $package = caller;
  $callback = Xchat::Embed::fix_callback( $package, undef, $callback) if $callback;
  Xchat::register( $script_name, $version, undef, $callback );
}


sub IRC::add_command_handler {
  my ($command, $callback) = @_;
  my $package = caller;

  $callback = Xchat::Embed::fix_callback( $package, undef, $callback );

  # starting index for word_eol array
  # this is for compatibility with '' as the command
  my $start_index = $command ? 1 : 0;

  Xchat::hook_command( $command,
		       sub {
			 no strict 'refs';
			 return &{$callback}($_[1][$start_index]);
		       }
		     );
  return;
}

sub IRC::add_message_handler {
  my ($message, $callback) = @_;
  my $package = caller;
  $callback = Xchat::Embed::fix_callback( $package, undef, $callback );

  Xchat::hook_server( $message,
		      sub {
			no strict 'refs';
			return &{$callback}( $_[1][0] );
		      }
		    );
  return;
}

sub IRC::add_print_handler {
  my ($event, $callback) = @_;
  my $package = caller;
  $callback = Xchat::Embed::fix_callback( $package, undef, $callback );
  Xchat::hook_print( $event,
		     sub {
		       my @word = @{$_[0]};
		       no strict 'refs';
		       return &{$callback}( join( ' ', @word[0..3] ), @word );
		     }
		   );
  return;
}

sub IRC::add_timeout_handler {
  my ($timeout, $callback) = @_;
  my $package = caller;
  $callback = Xchat::Embed::fix_callback( $package, undef, $callback );
  Xchat::hook_timer( $timeout,
		     sub {
		       no strict 'refs';
		       &{$callback};
		       return 0;
		     }
		   );
  return;
}

sub IRC::command {
  my $command = shift;
  if( $command =~ m{^/} ) {
    $command =~ s{^/}{};
    Xchat::command( $command );
  } else {
    Xchat::command( qq[say $command] );
  }
}

sub IRC::command_with_channel {
  my ($command, $channel, $server) = @_;
  my $old_ctx = Xchat::get_context;
  my $ctx = Xchat::find_context( $channel, $server );

  if( $ctx ) {
    Xchat::set_context( $ctx );
    IRC::command( $command );
    Xchat::set_context( $ctx );
  }
}

sub IRC::command_with_server {
  my ($command, $server) = @_;
  my $old_ctx = Xchat::get_context;
  my $ctx = Xchat::find_context( undef, $server );

  if( $ctx ) {
    Xchat::set_context( $ctx );
    IRC::command( $command );
    Xchat::set_context( $ctx );
  }
}

sub IRC::dcc_list {
  my @dccs;
  for my $dcc ( Xchat::get_list( 'dcc' ) ) {
    push @dccs, $dcc->{nick};
    push @dccs, $dcc->{file} ? $dcc->{file} : '';
    push @dccs, @{$dcc}{qw(type status cps size)};
    push @dccs, $dcc->{type} == 0 ? $dcc->{pos} : $dcc->{resume};
    push @dccs, $dcc->{address32};
    push @dccs, $dcc->{destfile} ? $dcc->{destfile} : '';
  }
  return @dccs;
}

sub IRC::channel_list {
  my @channels;
  for my $channel ( Xchat::get_list( 'channels' ) ) {
    push @channels, @{$channel}{qw(channel server)},
      Xchat::context_info( $channel->{context} )->{nick};
  }
  return @channels;
}

sub IRC::get_info {
  my $id = shift;
  my @ids = qw(version nick channel server configdir xchatdir away network host topic);
  
  if( $id >= 0 && $id <= 8 && $id != 5 ) {
    my $info = Xchat::get_info($ids[$id]);
    return defined $info ? $info : '';
  } else {
    if( $id == 5 ) {
      return Xchat::get_info( 'away' ) ? 1 : 0;
    } else {
      return 'Error2';
    }
  }
}

sub IRC::get_prefs {
  return 'Unknown variable' unless defined $_[0];
  my $result = Xchat::get_prefs(shift);
  return defined $result ? $result : 'Unknown variable';
}

sub IRC::ignore_list {
  my @ignores;
  for my $ignore ( Xchat::get_list( 'ignore' ) ) {
    push @ignores, $ignore->{mask};
    my $flags = $ignore->{flags};
    push @ignores, $flags & 1, $flags & 2, $flags & 4, $flags & 8, $flags & 16,
      $flags & 32, ':';
  }
  return @ignores;
}

sub IRC::print {
  Xchat::print( $_ ) for @_;
  return;
}

sub IRC::print_with_channel {
  Xchat::print( @_ );
}

sub IRC::send_raw {
  Xchat::commandf( qq[quote %s], shift );
}

sub IRC::server_list {
  my @servers;
  for my $channel ( Xchat::get_list( 'channels' ) ) {
    push @servers, $channel->{server} if $channel->{server};
  }
  return @servers;
}

sub IRC::user_info {
  my $user;
  if( @_ > 0 ) {
    $user = Xchat::user_info( shift );
  } else {
    $user = Xchat::user_info();
  }

  my @info;
  if( $user ) {
    push @info, $user->{nick};
    if( $user->{host} ) {
      push @info, $user->{host};
    } else {
      push @info, 'FETCHING';
    }
    push @info, $user->{prefix} eq '@' ? 1 : 0;
    push @info, $user->{prefix} eq '+' ? 1 : 0;
  }
  return @info;
}

sub IRC::user_list {
  my ($channel, $server) = @_;
  my $ctx = Xchat::find_context( $channel, $server );
  my $old_ctx = Xchat::get_context;

  if( $ctx ) {
    Xchat::set_context( $ctx );
    my @users;
    for my $user ( Xchat::get_list( 'users' ) ) {
      push @users, $user->{nick};
      if( $user->{host} ) {
	push @users, $user->{host};
      } else {
	push @users, 'FETCHING';
      }
      push @users, $user->{prefix} eq '@' ? 1 : 0;
      push @users, $user->{prefix} eq '+' ? 1 : 0;
      push @users, ':';
    }
    Xchat::set_context( $old_ctx );
    return @users;
  } else {
    return;
  }
}

sub IRC::user_list_short {
  my ($channel, $server) = @_;
  my $ctx = Xchat::find_context( $channel, $server );
  my $old_ctx = Xchat::get_context;

  if( $ctx ) {
    Xchat::set_context( $ctx );
    my @users;
    for my $user ( Xchat::get_list( 'users' ) ) {
      my $nick = $user->{nick};
      my $host = $user->{host} || 'FETCHING';
      push @users, $nick, $host;
    }
    Xchat::set_context( $old_ctx );
    return @users;
  } else {
    return;
  }

}

sub IRC::add_user_list {}
sub IRC::sub_user_list {}
sub IRC::clear_user_list {}
sub IRC::notify_list {}
sub IRC::perl_script_list {}

1