country.tcl

Do you have script in mind but no ability to make it, type in what it should do, and you might be lucky.

country.tcl

Postby panfleto » Tue Aug 17, 2010 1:21 pm

Hi,

I'd like a script for eggdrop to find country codes and viceversa.

!country US
<bot> result: code US is from United States
!country United States
<bot> result: United States code is US


This one only does it from 2 letter codes to country:

Code: Select all
# country.tcl by Jay Monk <jaym@utdallas.edu>
# COMMANDS
# country <node>    (dcc or public)

# Do not use pico to edit this file, it'll break
# up the long lines.. and this file has some LONG lines!

bind dcc - country dcc_country
bind pub - country pub_country

proc dcc_country {hand idx arg} {
  global country symbol
  if {$arg == "" || [llength $arg] > 1} {
    putdcc $idx "Correct usage: .country <node>"
    putdcc $idx "      Example: .country .[lindex $symbol [rand [llength $country]]]"
    return 0
  }
  set this [lsearch -exact $symbol [string trimleft [string toupper $arg] .]]
  if {$this > -1} {
    putdcc $idx "Country name for .[string trimleft [string toupper $arg] .] is [lindex $country $this]"
    return 1
  } else {
    putdcc $idx "No country name found for .[string trimleft [string toupper $arg] .]"
    return 0
  }
}

proc pub_country {nick uhost hand arg} {
  global country symbol channel
  if {$arg == "" || [llength $arg] > 1} {
    putserv "PRIVMSG $channel :Correct usage: .country <node>"
    putserv "PRIVMSG $channel :      Example: .country .[lindex $symbol [rand [llength $country]]]"
    return 0
  }
  set this [lsearch -exact $symbol [string trimleft [string toupper $arg] .]]
  if {$this > -1} {
    putserv "PRIVMSG $channel :Country name for .[string trimleft [string toupper $arg] .] is [lindex $country $this]"
    return 1
  } else {
    putserv "PRIVMSG $channel :No country name found for .[string trimleft [string toupper $arg] .]"
    return 0
  }
}

set country {
 "AFGHANISTAN" "ALBANIA" "ALGERIA" "AMERICAN SAMOA"
 "ANDORRA" "ANGOLA" "ANGUILLA" "ANTARCTICA"
 "ANTIGUA AND BARBUDA" "ARGENTINA" "ARMENIA" "ARUBA"
 "AUSTRALIA" "AUSTRIA" "AZERBAIJAN" "BAHAMAS"
 "BAHRAIN" "BANGLADESH" "BARBADOS" "BELARUS"
 "BELGIUM" "BELIZE" "BENIN" "BERMUDA"
 "BHUTAN" "BOLIVIA" "BOSNIA" "BOTSWANA"
 "BOUVET ISLAND" "BRAZIL" "BRITISH INDIAN OCEAN TERRITORY" "BRUNEI DARUSSALAM"
 "BULGARIA" "BURKINA FASO" "BURUNDI" "BYELORUSSIAN SSR"
 "CAMBODIA" "CAMEROON" "CANADA" "CAP VERDE"
 "CAYMAN ISLANDS" "CENTRAL AFRICAN REPUBLIC" "CHAD" "CHILE"
 "CHINA" "CHRISTMAS ISLAND" "COCOS (KEELING) ISLANDS" "COLOMBIA"
 "COMOROS" "CONGO" "COOK ISLANDS" "COSTA RICA"
 "COTE D'IVOIRE" "CROATIA" "HRVATSKA" "CUBA"
 "CYPRUS" "CZECHOSLOVAKIA" "DENMARK" "DJIBOUTI"
 "DOMINICA" "DOMINICAN REPUBLIC" "EAST TIMOR" "ECUADOR"
 "EGYPT" "EL SALVADOR" "EQUATORIAL GUINEA" "ESTONIA"
 "ETHIOPIA" "FALKLAND ISLANDS" "MALVINAS" "FAROE ISLANDS"
 "FIJI" "FINLAND" "FRANCE" "FRENCH GUIANA"
 "FRENCH POLYNESIA" "FRENCH SOUTHERN TERRITORIES" "GABON" "GAMBIA"
 "GEORGIA" "GERMANY" "DEUTSCHLAND" "GHANA"
 "GIBRALTAR" "GREECE" "GREENLAND" "GRENADA"
 "GUADELOUPE" "GUAM" "GUATEMALA" "GUINEA"
 "GUINEA BISSAU" "GYANA" "HAITI" "HEARD AND MC DONALD ISLANDS"
 "HONDURAS" "HONG KONG" "HUNGARY" "ICELAND"
 "INDIA" "INDONESIA" "IRAN" "IRAQ"
 "IRELAND" "ISRAEL" "ITALY" "JAMAICA"
 "JAPAN" "JORDAN" "KAZAKHSTAN" "KENYA"
 "KIRIBATI" "NORTH KOREA" "SOUTH KOREA" "KUWAIT"
 "KYRGYZSTAN" "LAOS" "LATVIA" "LEBANON"
 "LESOTHO" "LIBERIA" "LIBYAN ARAB JAMAHIRIYA" "LIECHTENSTEIN"
 "LITHUANIA" "LUXEMBOURG" "MACAU" "MACEDONIA"
 "MADAGASCAR" "MALAWI" "MALAYSIA" "MALDIVES"
 "MALI" "MALTA" "MARSHALL ISLANDS" "MARTINIQUE"
 "MAURITANIA" "MAURITIUS" "MEXICO" "MICRONESIA"
 "MOLDOVA" "MONACO" "MONGOLIA" "MONTSERRAT"
 "MOROCCO" "MOZAMBIQUE" "MYANMAR" "NAMIBIA"
 "NAURU" "NEPAL" "NETHERLANDS" "NETHERLANDS ANTILLES"
 "NEUTRAL ZONE" "NEW CALEDONIA" "NEW ZEALAND" "NICARAGUA"
 "NIGER" "NIGERIA" "NIUE" "NORFOLK ISLAND"
 "NORTHERN MARIANA ISLANDS" "NORWAY" "OMAN" "PAKISTAN"
 "PALAU" "PANAMA" "PAPUA NEW GUINEA" "PARAGUAY"
 "PERU" "PHILIPPINES" "PITCAIRN" "POLAND"
 "PORTUGAL" "PUERTO RICO" "QATAR" "REUNION"
 "ROMANIA" "RUSSIAN FEDERATION" "RWANDA" "SAINT KITTS AND NEVIS"
 "SAINT LUCIA" "SAINT VINCENT AND THE GRENADINES" "SAMOA" "SAN MARINO"
 "SAO TOME AND PRINCIPE" "SAUDI ARABIA" "SENEGAL" "SEYCHELLES"
 "SIERRA LEONE" "SINGAPORE" "SLOVENIA" "SOLOMON ISLANDS"
 "SOMALIA" "SOUTH AFRICA" "SPAIN" "SRI LANKA"
 "ST. HELENA" "ST. PIERRE AND MIQUELON" "SUDAN" "SURINAME"
 "SVALBARD AND JAN MAYEN ISLANDS" "SWAZILAND" "SWEDEN" "SWITZERLAND"
 "CANTONS OF HELVETIA" "SYRIAN ARAB REPUBLIC" "TAIWAN" "TAJIKISTAN"
 "TANZANIA" "THAILAND" "TOGO" "TOKELAU"
 "TONGA" "TRINIDAD AND TOBAGO" "TUNISIA" "TURKEY"
 "TURKMENISTAN" "TURKS AND CAICOS ISLANDS" "TUVALU" "UGANDA"
 "UKRAINIAN SSR" "UNITED ARAB EMIRATES" "UNITED KINGDOM" "GREAT BRITAIN"
 "UNITED STATES OF AMERICA" "UNITED STATES MINOR OUTLYING ISLANDS" "URUGUAY" "SOVIET UNION"
 "UZBEKISTAN" "VANUATU" "VATICAN CITY STATE" "VENEZUELA"
 "VIET NAM" "VIRGIN ISLANDS (US)" "VIRGIN ISLANDS (UK)" "WALLIS AND FUTUNA ISLANDS"
 "WESTERN SAHARA" "YEMEN" "YUGOSLAVIA" "ZAIRE"
 "ZAMBIA" "ZIMBABWE" "COMMERCIAL ORGANIZATION (US)" "EDUCATIONAL INSTITUTION (US)"
 "NETWORKING ORGANIZATION (US)" "MILITARY (US)" "NON-PROFIT ORGANIZATION (US)" "GOVERNMENT (US)"
 "KOREA - DEMOCRATIC PEOPLE'S REPUBLIC OF" "KOREA - REPUBLIC OF" "LAO PEOPLES' DEMOCRATIC REPUBLIC" "RUSSIA"
 "SLOVAKIA" "CZECH"
}

set symbol {
 AF AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE
 BZ BJ BM BT BO BA BW BV BR IO BN BG BF BI BY KH CM CA CV KY CF
 TD CL CN CX CC CO KM CG CK CR CI HR HR CU CY CS DK DJ DM DO TP
 EC EG SV GQ EE ET FK FK FO FJ FI FR GF PF TF GA GM GE DE DE GH
 GI GR GL GD GP GU GT GN GW GY HT HM HN HK HU IS IN ID IR IQ IE
 IL IT JM JP JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU
 MO MK MG MW MY MV ML MT MH MQ MR MU MX FM MD MC MN MS MA MZ MM
 NA NR NP NL AN NT NC NZ NI NE NG NU NF MP NO OM PK PW PA PG PY
 PE PH PN PL PT PR QA RE RO RU RW KN LC VC WS SM ST SA SN SC SL
 SG SI SB SO ZA ES LK SH PM SD SR SJ SZ SE CH CH SY TW TJ TZ TH
 TG TK TO TT TN TR TM TC TV UG UA AE UK GB US UM UY SU UZ VU VA
 VE VN VI VG WF EH YE YU ZR ZM ZW COM EDU NET MIL ORG GOV KP KR
 LA SU SK CZ
}
panfleto
 

Re: country.tcl

Postby Cristian » Tue Aug 17, 2010 2:33 pm

then update it, using ISO 3-alpha codes.

Fx. http://www.unc.edu/~rowlett/units/codes/country.htm have country names and ISO 3-alpha codes
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: country.tcl

Postby panfleto » Wed Aug 18, 2010 9:57 am

I'd like a script for eggdrop to find country codes and viceversa.

This one only does it from 2 letter codes to country



cks wrote:then update it, using ISO 3-alpha codes.

Fx. http://www.unc.edu/~rowlett/units/codes/country.htm have country names and ISO 3-alpha codes



This way it will change from 2 to 3 letter codes but won't do what I requested (find country codes and viceversa).

Thanks anyway :)
panfleto
 

Re: country.tcl

Postby Cristian » Wed Aug 18, 2010 1:28 pm

sorry I misread your post. This should do the trick, I left out the dcc commands.

remember to update the symbol variable, with the link given previously.

Code: Select all
# country.tcl by Jay Monk <jaym@utdallas.edu>
# COMMANDS
# country <node>    (dcc or public)

# Do not use pico to edit this file, it'll break
# up the long lines.. and this file has some LONG lines!

bind pub - .country pub_country

proc pub_country {nick uhost hand channel arg} {
   global country symbol
   if {$arg == ""} {
      putserv "PRIVMSG $channel :Correct usage: .country <node>"
      putserv "PRIVMSG $channel :Example: .country [lindex $symbol [rand [llength $country]]]"
      return 0
   }
   if {[string length $arg] < 4} {
      set this [lsearch $symbol [string trimleft [string toupper $arg]]]
      if {$this > -1} {
         putserv "PRIVMSG $channel :Country name for [string trimleft $arg .] is [lindex $country $this]"
         return 1
      } else {
         putserv "PRIVMSG $channel :No country name found for [string trimleft $arg .]"
         return 0
      }
   } else {
      set this [lsearch $country [string trimleft [string toupper $arg]]]
      
      if {$this > -1} {
         putserv "PRIVMSG $channel :Symbol name for [string trimleft $arg .] is [lindex $symbol $this]"
         return 1
      } else {
         putserv "PRIVMSG $channel :No symbol name found for [string trimleft $arg .]"
         return 0
      }      

   }
}

set country {
 "AFGHANISTAN" "ALBANIA" "ALGERIA" "AMERICAN SAMOA"
 "ANDORRA" "ANGOLA" "ANGUILLA" "ANTARCTICA"
 "ANTIGUA AND BARBUDA" "ARGENTINA" "ARMENIA" "ARUBA"
 "AUSTRALIA" "AUSTRIA" "AZERBAIJAN" "BAHAMAS"
 "BAHRAIN" "BANGLADESH" "BARBADOS" "BELARUS"
 "BELGIUM" "BELIZE" "BENIN" "BERMUDA"
 "BHUTAN" "BOLIVIA" "BOSNIA" "BOTSWANA"
 "BOUVET ISLAND" "BRAZIL" "BRITISH INDIAN OCEAN TERRITORY" "BRUNEI DARUSSALAM"
 "BULGARIA" "BURKINA FASO" "BURUNDI" "BYELORUSSIAN SSR"
 "CAMBODIA" "CAMEROON" "CANADA" "CAP VERDE"
 "CAYMAN ISLANDS" "CENTRAL AFRICAN REPUBLIC" "CHAD" "CHILE"
 "CHINA" "CHRISTMAS ISLAND" "COCOS (KEELING) ISLANDS" "COLOMBIA"
 "COMOROS" "CONGO" "COOK ISLANDS" "COSTA RICA"
 "COTE D'IVOIRE" "CROATIA" "HRVATSKA" "CUBA"
 "CYPRUS" "CZECHOSLOVAKIA" "DENMARK" "DJIBOUTI"
 "DOMINICA" "DOMINICAN REPUBLIC" "EAST TIMOR" "ECUADOR"
 "EGYPT" "EL SALVADOR" "EQUATORIAL GUINEA" "ESTONIA"
 "ETHIOPIA" "FALKLAND ISLANDS" "MALVINAS" "FAROE ISLANDS"
 "FIJI" "FINLAND" "FRANCE" "FRENCH GUIANA"
 "FRENCH POLYNESIA" "FRENCH SOUTHERN TERRITORIES" "GABON" "GAMBIA"
 "GEORGIA" "GERMANY" "DEUTSCHLAND" "GHANA"
 "GIBRALTAR" "GREECE" "GREENLAND" "GRENADA"
 "GUADELOUPE" "GUAM" "GUATEMALA" "GUINEA"
 "GUINEA BISSAU" "GYANA" "HAITI" "HEARD AND MC DONALD ISLANDS"
 "HONDURAS" "HONG KONG" "HUNGARY" "ICELAND"
 "INDIA" "INDONESIA" "IRAN" "IRAQ"
 "IRELAND" "ISRAEL" "ITALY" "JAMAICA"
 "JAPAN" "JORDAN" "KAZAKHSTAN" "KENYA"
 "KIRIBATI" "NORTH KOREA" "SOUTH KOREA" "KUWAIT"
 "KYRGYZSTAN" "LAOS" "LATVIA" "LEBANON"
 "LESOTHO" "LIBERIA" "LIBYAN ARAB JAMAHIRIYA" "LIECHTENSTEIN"
 "LITHUANIA" "LUXEMBOURG" "MACAU" "MACEDONIA"
 "MADAGASCAR" "MALAWI" "MALAYSIA" "MALDIVES"
 "MALI" "MALTA" "MARSHALL ISLANDS" "MARTINIQUE"
 "MAURITANIA" "MAURITIUS" "MEXICO" "MICRONESIA"
 "MOLDOVA" "MONACO" "MONGOLIA" "MONTSERRAT"
 "MOROCCO" "MOZAMBIQUE" "MYANMAR" "NAMIBIA"
 "NAURU" "NEPAL" "NETHERLANDS" "NETHERLANDS ANTILLES"
 "NEUTRAL ZONE" "NEW CALEDONIA" "NEW ZEALAND" "NICARAGUA"
 "NIGER" "NIGERIA" "NIUE" "NORFOLK ISLAND"
 "NORTHERN MARIANA ISLANDS" "NORWAY" "OMAN" "PAKISTAN"
 "PALAU" "PANAMA" "PAPUA NEW GUINEA" "PARAGUAY"
 "PERU" "PHILIPPINES" "PITCAIRN" "POLAND"
 "PORTUGAL" "PUERTO RICO" "QATAR" "REUNION"
 "ROMANIA" "RUSSIAN FEDERATION" "RWANDA" "SAINT KITTS AND NEVIS"
 "SAINT LUCIA" "SAINT VINCENT AND THE GRENADINES" "SAMOA" "SAN MARINO"
 "SAO TOME AND PRINCIPE" "SAUDI ARABIA" "SENEGAL" "SEYCHELLES"
 "SIERRA LEONE" "SINGAPORE" "SLOVENIA" "SOLOMON ISLANDS"
 "SOMALIA" "SOUTH AFRICA" "SPAIN" "SRI LANKA"
 "ST. HELENA" "ST. PIERRE AND MIQUELON" "SUDAN" "SURINAME"
 "SVALBARD AND JAN MAYEN ISLANDS" "SWAZILAND" "SWEDEN" "SWITZERLAND"
 "CANTONS OF HELVETIA" "SYRIAN ARAB REPUBLIC" "TAIWAN" "TAJIKISTAN"
 "TANZANIA" "THAILAND" "TOGO" "TOKELAU"
 "TONGA" "TRINIDAD AND TOBAGO" "TUNISIA" "TURKEY"
 "TURKMENISTAN" "TURKS AND CAICOS ISLANDS" "TUVALU" "UGANDA"
 "UKRAINIAN SSR" "UNITED ARAB EMIRATES" "UNITED KINGDOM" "GREAT BRITAIN"
 "UNITED STATES OF AMERICA" "UNITED STATES MINOR OUTLYING ISLANDS" "URUGUAY" "SOVIET UNION"
 "UZBEKISTAN" "VANUATU" "VATICAN CITY STATE" "VENEZUELA"
 "VIET NAM" "VIRGIN ISLANDS (US)" "VIRGIN ISLANDS (UK)" "WALLIS AND FUTUNA ISLANDS"
 "WESTERN SAHARA" "YEMEN" "YUGOSLAVIA" "ZAIRE"
 "ZAMBIA" "ZIMBABWE" "COMMERCIAL ORGANIZATION (US)" "EDUCATIONAL INSTITUTION (US)"
 "NETWORKING ORGANIZATION (US)" "MILITARY (US)" "NON-PROFIT ORGANIZATION (US)" "GOVERNMENT (US)"
 "KOREA - DEMOCRATIC PEOPLE'S REPUBLIC OF" "KOREA - REPUBLIC OF" "LAO PEOPLES' DEMOCRATIC REPUBLIC" "RUSSIA"
 "SLOVAKIA" "CZECH"
}

set symbol {
 AFG ALA DZA ASM AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE
 BZ BJ BM BT BO BA BW BV BR IO BN BG BF BI BY KH CM CA CV KY CF
 TD CL CN CX CC CO KM CG CK CR CI HR HR CU CY CS DK DJ DM DO TP
 EC EG SV GQ EE ET FK FK FO FJ FI FR GF PF TF GA GM GE DE DE GH
 GI GR GL GD GP GU GT GN GW GY HT HM HN HK HU IS IN ID IR IQ IE
 IL IT JM JP JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU
 MO MK MG MW MY MV ML MT MH MQ MR MU MX FM MD MC MN MS MA MZ MM
 NA NR NP NL AN NT NC NZ NI NE NG NU NF MP NO OM PK PW PA PG PY
 PE PH PN PL PT PR QA RE RO RU RW KN LC VC WS SM ST SA SN SC SL
 SG SI SB SO ZA ES LK SH PM SD SR SJ SZ SE CH CH SY TW TJ TZ TH
 TG TK TO TT TN TR TM TC TV UG UA AE UK GB US UM UY SU UZ VU VA
 VE VN VI VG WF EH YE YU ZR ZM ZW COM EDU NET MIL ORG GOV KP KR
 LA SU SK CZ
}
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: country.tcl

Postby panfleto » Wed Aug 18, 2010 6:55 pm

Thank you very much, cks :D
panfleto
 


Return to TCL Scripting Request

Who is online

Users browsing this forum: No registered users and 1 guest

cron