Konversation/Scripts/Import mIRC server list/da: Difference between revisions

From KDE UserBase Wiki
(Importing a new version from external source)
(Updating to match new version of source page)
 
(5 intermediate revisions by one other user not shown)
Line 37: Line 37:
== Hjælp  ==
== Hjælp  ==


Any questions look for Woosta on Freenode or ask your local perl guru
Har du spørgsmål, så find Woosta Freenode eller spørg din lokale perlguru.


== Licence ==
== Licens ==


(c)2007 Rick Measham. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
(c)2007 Rick Measham. Dette program er fri software; du kan videredistribuere det og/eller modificere der under samme betingelser som for Perl selv.


== The Script ==
== Scriptet ==


{{Input|<syntaxhighlight lang="perl">
{{Input|<syntaxhighlight lang="perl">
Line 109: Line 109:
BEGIN {
BEGIN {


<!--T:27-->
my $konvs = `ps ax | grep konversation | grep -v grep`;
my $konvs = `ps ax | grep konversation | grep -v grep`;
if ($konvs =~ /konversation/){
if ($konvs =~ /konversation/){
Line 116: Line 115:
}
}


<!--T:28-->
my @mod_list = ('Config::Tiny', 'File::Copy', 'LWP::Simple');
my @mod_list = ('Config::Tiny', 'File::Copy', 'LWP::Simple');


<!--T:29-->
# If there isn't a konversationrc in the ARGV, add File::HomeDir
# If there isn't a konversationrc in the ARGV, add File::HomeDir
push(@mod_list, 'File::HomeDir')
push(@mod_list, 'File::HomeDir')
Line 125: Line 122:
|| ($ENV{KDEHOME} && -r "$ENV{KDEHOME}/share/config/konversationrc");
|| ($ENV{KDEHOME} && -r "$ENV{KDEHOME}/share/config/konversationrc");


<!--T:30-->
foreach my $mod (@mod_list){
foreach my $mod (@mod_list){
eval {
eval {
Line 183: Line 179:




<!--T:38-->
print "Counting existing server groups\n";
print "Counting existing server groups\n";
my $gcount = 0;
my $gcount = 0;
Line 259: Line 254:
print "Completed. It is now safe to start konversation.\n";
print "Completed. It is now safe to start konversation.\n";
</syntaxhighlight>}}
</syntaxhighlight>}}
[[Category:Internet]]
[[Category:Internet/da]]
[[Category:Advanced Users]]
[[Category:Avancerede brugere/da]]

Latest revision as of 17:43, 23 February 2013

Other languages:

Information =

Dette script læser mIRC's serverliste fra mirc.com og importerer den til din serverliste i Konversation.

  • Det vil IKKE overskrive dine eksisterende servere, men vil føje listen til din eksisterende liste.
  • Det integrere ikke: Hvis du allerede har en freenode gruppe, så vil du have to freenode grupper efter at have kørt scriptet.
  • Det sætter alle NYE servere til at bruge din standardprofil.
  • Det antager, at du ønsker at forbinde til den første port, som er oplistet i mIRC-config'en. (Konversation synes ikke at understøtte flere porte).

Brug

Kopiér scriptet herunder til et nyt tekstdokument og Gem det som 'konversation_servers' (eller hvad du nu synes er passende; husk blot at ændre tilsvarende i det følgende!)

Sørg for at afslutte Konversation (det er ikke nok blot at lukke programmet), og kør så:

perl konversation_servers

or

perl konversation_servers /path/to/konversationrc

For at køre det, skal du have nogle perlmoduler installeret:

Du ksn undvære File::HomeDir, hvis du medtager stien til konversationrc i kommandolinjekaldet eller hvis miljøvariablen KDEHOME er sat og konversationrc er, hvor den skal være.

Garanti

DETTE SCRIPT LEVERES MED ABSOLUT INGEN GARANTIER.

Hjælp

Har du spørgsmål, så find Woosta på Freenode eller spørg din lokale perlguru.

Licens

(c)2007 Rick Measham. Dette program er fri software; du kan videredistribuere det og/eller modificere der under samme betingelser som for Perl selv.

Scriptet

#!/usr/bin/perl

#  INFORMATION
#  ====================================================================
#  This script reads the mIRC server list from
#  'http://www.mirc.co.uk/servers.ini' and imports it into your
#  Konversation server list.
#
#  * It will NOT overwrite your existing servers, but will append the
#    list to your existing list.
#  * It doesn't integrate: If you have a freenode group now, you will
#    have two freenode groups once you run it.
#  * It sets all NEW servers to use your default profile
#  * It assumes you want to connect on the first port listed in the
#    mIRC config. (Konversation doesn't appear to have the concept of
#    multiple ports)

#  USAGE
#  ====================================================================
#  Make sure you quit (not just close) Konversation, and then run:
#
#     perl konversation_servers
#        OR
#     perl konversation_servers /path/to/konversationrc
#
#  To run it, you will need several perl modules installed:
#    * Config::Tiny
#    * LWP::Simple
#    * File::HomeDir
#
#  You can skip File::HomeDir if you include the path to your
#  konversationrc in the command line call or if your KDEHOME
#  environment variable is set and your konversationrc is where
#  is should be.
#

#  WARRANTY
#  ====================================================================
#  THIS SCRIPT COMES WITH NO WARRANTY AT ALL.
#  Any questions look for Woosta on Freenode
#

#  SUPPORT
#  ====================================================================
#  Any questions look for Woosta on Freenode or ask your local perl guru
#

#  LICENCE
#  ====================================================================
#  (c)2007 Rick Measham.  This program is free software; you can 
#  redistribute it and/or modify it under the same terms as Perl itself.
#


# Change this if it moves!
my $mirc_url = 'http://www.mirc.co.uk/servers.ini';


use warnings;
use strict;

BEGIN {

my $konvs = `ps ax | grep konversation | grep -v grep`;
	if ($konvs =~ /konversation/){
		print "You need to quit konversation before running this script.\n";
		exit(1);
	}

my @mod_list = ('Config::Tiny', 'File::Copy', 'LWP::Simple');

# If there isn't a konversationrc in the ARGV, add File::HomeDir
	push(@mod_list, 'File::HomeDir')
		unless ($ARGV[0] && -r $ARGV[0])
			|| ($ENV{KDEHOME} && -r "$ENV{KDEHOME}/share/config/konversationrc");

foreach my $mod (@mod_list){
		eval {
			(my $fn = $mod) =~ s|::|/|g;
			require $fn.'.pm';
		};
		if( $@ ){
			print "You are missing $mod. Please install this perl module and then try again.\n";
			exit(1);
		}
		import $mod;
	}
}



my $konvrc =
	($ARGV[0]) ? $ARGV[0]
	: ($ENV{KDEHOME} && -r "$ENV{KDEHOME}/share/config/konversationrc") ? "$ENV{KDEHOME}/share/config/konversationrc"
	: File::HomeDir->my_home . "/.kde/share/config/konversationrc";

print "Reading konversationrc from $konvrc\n";

if( ! -r $konvrc ){
	print "Unable to read konversationrc from $konvrc. Please include the path on the command line:\n";
	print "    /path/to/konversationrc\n";
	exit(1);
}


print "Getting server list from mirc\n";
my $servlist = get($mirc_url);
print "   done.\n";



print "Creating a backup of your current konversationrc to $konvrc.bak\n";
copy($konvrc, "$konvrc.bak");
print "   done.\n";



print "Reading INI files\n";
my $mIRC = Config::Tiny->read_string( $servlist );
my $konv = Config::Tiny->read( $konvrc );
print "   done.\n";



print "Counting existing servers\n";
my $scount = 0;
while( exists $konv->{"Server $scount"} ){
	$scount++;
}
print "   Next available server is $scount\n";



print "Counting existing server groups\n";
my $gcount = 0;
while( exists $konv->{"ServerGroup $gcount"} ){
	$gcount++;
}
print STDERR "   Next available group is $gcount\n";



print "Parsing mIRC's server list\n";
my %group;
foreach my $s ( keys %{ $mIRC->{servers} } ){

my ($name, $server, $port, $group)
		= $mIRC->{servers}{$s}
		=~ /(.+?)SERVER:(.+?):(\d+).*?GROUP:(.+)/;

next unless $group && $server && $port;

$name =~ s/^$group: //;

push(@{$group{$group}}, { name=>$name, server=>$server, port=>$port });

}
print "   done.\n";



print "Generating data for konversationrc\n";
foreach my $g ( sort keys %group ){

$konv->{"ServerGroup $gcount"} = {
		AutoConnect         => 'false',
		AutoJoinChannels    => '',
		ChannelHistory      => '',
		ConnectCommands     => '',
		EnableNotifications => 'true',
		Expanded            => 'false',
		Identity            => 'Default Identity',
		Name                => $g,
		NotifyList          => '',
	};

foreach my $s ( @{ $group{$g} } ){

$konv->{"Server $scount"} = {
			Password   => '',
			Port       => $s->{port},
			SSLEnabled => 'false',
			Server     => $s->{server},
		};

$konv->{"ServerGroup $gcount"}{ServerList} =
			($konv->{"ServerGroup $gcount"}{ServerList} || '')
			.(($konv->{"ServerGroup $gcount"}{ServerList}) ? ',' : '')
			."Server $scount";

$scount++;
	}

$gcount++;
}
$gcount--; $scount--;
print "   done. There are now $gcount groups and $scount servers.\n";



print "Writing konversationrc\n";
$konv->write($konvrc);
print "   done.\n";



print "Completed. It is now safe to start konversation.\n";