1# Print the country name in /WHOIS replies 2# /COUNTRY <code> prints the name for the country code 3# Installation: Add $whois_country somewhere in your /FORMAT whois line 4 5use strict; 6use Irssi 20021028; 7 8use vars qw($VERSION %IRSSI); 9$VERSION = "1.0.1"; 10%IRSSI = ( 11 authors => "Timo Sirainen", 12 contact => "tss\@iki.fi", 13 name => "country", 14 description => "Print the country name in /WHOIS replies", 15 license => "Public Domain", 16 changed => "Mon Oct 28 00:29:26 EET 2002" 17); 18 19my %countries; 20my $last_country = ""; 21 22sub sig_whois { 23 my ($server, $data, $nick, $host) = @_; 24 my ($me, $nick, $user, $host) = split(" ", $data); 25 26 if ($host =~ /\.([a-zA-Z]+)$/) { 27 $last_country = $countries{lc $1}; 28 } else { 29 $last_country = ""; 30 } 31} 32 33sub expando_whois_country { 34 return $last_country; 35} 36 37sub cmd_country { 38 my $country = lc shift; 39 if ($country eq "") { 40 Irssi::print("USAGE: /COUNTRY <country code>"); 41 return; 42 } 43 44 my $name = $countries{$country}; 45 if (!$name) { 46 Irssi::print("Unknown country code: $country"); 47 } else { 48 Irssi::print("$country is $name"); 49 } 50} 51 52Irssi::command_bind('country', \&cmd_country); 53Irssi::signal_add_first('event 311', \&sig_whois); 54Irssi::expando_create('whois_country', \&expando_whois_country, 55 { 'event 311' => 'None' } ); 56 57my $countryfile = ' 58# list taken from http://www.iana.org/cctld/cctld-whois.htm 59# on 27-10-2002 by Lam 60ac Ascension Island 61ad Andorra 62ae United Arab Emirates 63af Afghanistan 64ag Antigua and Barbuda 65ai Anguilla 66al Albania 67am Armenia 68an Netherlands Antilles 69ao Angola 70aq Antarctica 71ar Argentina 72as American Samoa 73at Austria 74au Australia 75aw Aruba 76az Azerbaijan 77ba Bosnia and Herzegovina 78bb Barbados 79bd Bangladesh 80be Belgium 81bf Burkina Faso 82bg Bulgaria 83bh Bahrain 84bi Burundi 85bj Benin 86bm Bermuda 87bn Brunei Darussalam 88bo Bolivia 89br Brazil 90bs Bahamas 91bt Bhutan 92bv Bouvet Island 93bw Botswana 94by Belarus 95bz Belize 96ca Canada 97cc Cocos (Keeling) Islands 98cd Congo Democratic Republic of the 99cf Central African Republic 100cg Congo Republic of 101ch Switzerland 102ci Cote d\\\'Ivoire 103ck Cook Islands 104cl Chile 105cm Cameroon 106cn China 107co Colombia 108cr Costa Rica 109cu Cuba 110cv Cap Verde 111cx Christmas Island 112cy Cyprus 113cz Czech Republic 114de Germany 115dj Djibouti 116dk Denmark 117dm Dominica 118do Dominican Republic 119dz Algeria 120ec Ecuador 121ee Estonia 122eg Egypt 123eh Western Sahara 124er Eritrea 125es Spain 126et Ethiopia 127fi Finland 128fj Fiji 129fk Falkland Islands (Malvina) 130fm Micronesia Federal State of 131fo Faroe Islands 132fr France 133ga Gabon 134gd Grenada 135ge Georgia 136gf French Guiana 137gg Guernsey 138gh Ghana 139gi Gibraltar 140gl Greenland 141gm Gambia 142gn Guinea 143gp Guadeloupe 144gq Equatorial Guinea 145gr Greece 146gs South Georgia and the South Sandwich Islands 147gt Guatemala 148gu Guam 149gw Guinea-Bissau 150gy Guyana 151hk Hong Kong 152hm Heard and McDonald Islands 153hn Honduras 154hr Croatia/Hrvatska 155ht Haiti 156hu Hungary 157id Indonesia 158ie Ireland 159il Israel 160im Isle of Man 161in India 162io British Indian Ocean Territory 163iq Iraq 164ir Iran (Islamic Republic of) 165is Iceland 166it Italy 167je Jersey 168jm Jamaica 169jo Jordan 170jp Japan 171ke Kenya 172kg Kyrgyzstan 173kh Cambodia 174ki Kiribati 175km Comoros 176kn Saint Kitts and Nevis 177kp Korea Democratic People\\\'s Republic 178kr Korea Republic of 179kw Kuwait 180ky Cayman Islands 181kz Kazakhstan 182la Lao People\\\'s Democratic Republic 183lb Lebanon 184lc Saint Lucia 185li Liechtenstein 186lk Sri Lanka 187lr Liberia 188ls Lesotho 189lt Lithuania 190lu Luxembourg 191lv Latvia 192ly Libyan Arab Jamahiriya 193ma Morocco 194mc Monaco 195md Moldova Republic of 196mg Madagascar 197mh Marshall Islands 198mk Macedonia Former Yugoslav Republic 199ml Mali 200mm Myanmar 201mn Mongolia 202mo Macau 203mp Northern Mariana Islands 204mq Martinique 205mr Mauritania 206ms Montserrat 207mt Malta 208mu Mauritius 209mv Maldives 210mw Malawi 211mx Mexico 212my Malaysia 213mz Mozambique 214na Namibia 215nc New Caledonia 216ne Niger 217nf Norfolk Island 218ng Nigeria 219ni Nicaragua 220nl Netherlands 221no Norway 222np Nepal 223nr Nauru 224nu Niue 225nz New Zealand 226om Oman 227pa Panama 228pe Peru 229pf French Polynesia 230pg Papua New Guinea 231ph Philippines 232pk Pakistan 233pl Poland 234pm St. Pierre and Miquelon 235pn Pitcairn Island 236pr Puerto Rico 237ps Palestinian Territories 238pt Portugal 239pw Palau 240py Paraguay 241qa Qatar 242re Reunion Island 243ro Romania 244ru Russian Federation 245rw Rwanda 246sa Saudi Arabia 247sb Solomon Islands 248sc Seychelles 249sd Sudan 250se Sweden 251sg Singapore 252sh St. Helena 253si Slovenia 254sj Svalbard and Jan Mayen Islands 255sk Slovak Republic 256sl Sierra Leone 257sm San Marino 258sn Senegal 259so Somalia 260sr Suriname 261st Sao Tome and Principe 262sv El Salvador 263sy Syrian Arab Republic 264sz Swaziland 265tc Turks and Caicos Islands 266td Chad 267tf French Southern Territories 268tg Togo 269th Thailand 270tj Tajikistan 271tk Tokelau 272tm Turkmenistan 273tn Tunisia 274to Tonga 275tp East Timor 276tr Turkey 277tt Trinidad and Tobago 278tv Tuvalu 279tw Taiwan 280tz Tanzania 281ua Ukraine 282ug Uganda 283uk United Kingdom 284um US Minor Outlying Islands 285us United States 286uy Uruguay 287uz Uzbekistan 288va Holy See (City Vatican State) 289vc Saint Vincent and the Grenadines 290ve Venezuela 291vg Virgin Islands (British) 292vi Virgin Islands (USA) 293vn Vietnam 294vu Vanuatu 295wf Wallis and Futuna Islands 296ws Western Samoa 297ye Yemen 298yt Mayotte 299yu Yugoslavia 300za South Africa 301zm Zambia 302zw Zimbabwe 303# these are my own inventions 304com commercial 305net network 306org organisation 307edu educational 308mil military 309gov government 310aero air-transport 311biz business 312coop cooperative 313info informative 314museum museum 315name individual 316pro profession 317'; 318 319foreach my $line (split(/\n/, $countryfile)) { 320 chomp $line; 321 next if ($line =~ /^#/ || $line eq ""); 322 323 my ($code, $name) = split(/\t/, $line); 324 $countries{$code} = $name; 325} 326