This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Worldtime1.3.tcl working, again.

Support & discussion of released scripts, and announcements of new releases.
Post Reply
User avatar
LOQUILLO
Voice
Posts: 14
Joined: Wed Jul 21, 2004 4:45 pm
Location: Perú

Fixed

Post by LOQUILLO »

Hello friends, I had fixed this little bug, again.
<@LOQUILLO> !tz Lima
<@claus_sp> The time in Lima,Peru is

Code: Select all

####################################################################### 
####################################################################### 
#                       Worldtime by Murf                             # 
#                            v1.1                                     # 
#                            v1.2 (modified by LOQUILLO_)             # 
#  Gets the time from around the world from www.worldtimeserver.com   # 
#  Not much else to say, simple but handy.                            # 
#                                                                     # 
#                 Latest version @ http://www.blueday.org             # 
#                 Comments & Questions to murf@mindless.com           # 
####################################################################### 
#  Only tested on TCL v8.3 and Egg v1.6x, although I kept the code    # 
#  generic enough for TCL v8.0 and probably v1.3 of egg.              # 
####################################################################### 
#                                                                     # 
#  Commands                                                           # 
#                                                                     # 
#          .tz <city|country>                                         # 
#        or                                                           # 
#          /msg kinks .tz <city|country>                              # 
#                                                                     # 
#        City and country list is somewhat limited to major cities    # 
#        and countries.                                               # 
#                                                                     # 
#   Version                                                           # 
#    v1.2 March 3 2005 modified by LOQUILLO_ 
#         -- Solve output bug like: 
#            <hanson_sp> The time in Lima,Peru is <font size="7">1:31 PM 
#            and added all the cities and countries (somes codes was changed) available 
#             in http://www.worldtimeserver.com 
#  
#      v1.1 Nov 1 2001                                                # 
#        --  Got rid of 'string equal' so people with old (v8.0) TCL  # 
#            can run  (not really worthy of .1 but what the hell!)    # 
#                                                                     # 
#      v1.0 written in 2000 sometime                                  # 
#         -- first version and been running forever without problems  # 
#            or changes to the script.                                # 
#                                                                     # 
####################################################################### 
####################################################################### 

###Nothing to setup or configure##### 

##########binds###################### 
bind pub - !tz pub_world_time 
bind msg - .tz msg_world_time 

##########Procs###################### 
proc pub_world_time {nick uhost handle chan location} { 
  set loclist [get_tzloc $location $nick] 
  if {$loclist == 0} { 
     return 
  } 
  set url [lindex [split $loclist] 0] 
  set temploc [lindex [split $loclist] 1] 
  if {$temploc == "toilet"} { 
     putserv "PRIVMSG $chan : If ya gotta crap goto the toilet. No one wants\ 
your stank around here!" 
     return 
  } 
  if {$temploc == "kick"} { 
     putkick $chan $nick "It's time to stop being so lame" 
     return 
  } 
  set tztime [get_tztime $url] 
  regsub -all {_} $temploc { } outloc 
  putserv "PRIVMSG $chan :The time in $outloc is $tztime" 
  
} 

proc msg_world_time {nick uhost handle location} { 
  set loclist [get_tzloc $location $nick] 
  if {$loclist == 0} { 
     return 
  } 
  set url [lindex [split $loclist] 0] 
  set temploc [lindex [split $loclist] 1] 
  if {$temploc == "toilet"} { 
     putserv "NOTICE $nick : If ya gotta crap goto the toilet. No one wants\ 
your stank around here!" 
     return 
  } 
  if {$temploc == "kick"} { 
     putserv "NOTICE $nick : It's time to stop being so lame!" 
     return 
  } 
  set tztime [get_tztime $url] 
  regsub -all {_} $temploc { } outloc 
  putserv "NOTICE $nick :The time in $outloc is $tztime" 
  
} 

proc get_tztime {url} { 
  set tzsock [socket -async www.worldtimeserver.com 80] 
  puts $tzsock "GET $url HTTP/1.1" 
  puts $tzsock "Host: www.worldtimeserver.com" 
   puts $tzsock "Accept-Language: de-de,de;q=0.9,en-us;q=0.8,en;q=0.7,*;q=0.6" 
   puts $tzsock "Connection: close" 
   puts $tzsock "User-Agent: Tcl http client (TCL 8.4.7; worldtime 1.2; de-DE; CYGWIN_NT-5.1)" 
   puts $tzsock "" 
   flush $tzsock 
   while {![eof $tzsock]} { 
      append tzout [gets $tzsock] 
   } 
   close $tzsock 
   set tztime "" 
regexp {<div id="analog-digital"><font size="7">(.+?)</font></div>} $tzout {} tztime
#  regexp {<div align=\"center\"><font size=\"7\">(.{4,8})</font><br>} $tzout {} tztime 
  return $tztime 
} 

proc get_tzloc {location nick} { 
set city_list { 
UTC:UTC/GMT 
RU-KK&city=Abakan:Abakan,Russia 
CI&city=Abidjan:Abidjan,Cote_D'Ivoire 
AE&city=Abu_Dhabi:Abu_Dhabi,United_Arab_Emirates 
NG&city=Abuja:Abuja,Nigeria 
GH&city=Accra:Accra,Ghana 
PN&city=Adamstown:Adamstown,Pitcairn 
ET&city=Addis_Ababa:Addis_Ababa,Ethiopia 
AU-SA&city=Adelaide:Adelaide,Australia 
RU-AGB&city=Aginskoye:Aginskoye,Russia 
KZ1&city=Aktau:Aktau,Kazakhstan 
KZ2&city=Aktyubinsk:Aktyubinsk,Kazakhstan 
US-NY&city=Albany:Albany,United_States 
US-NM&city=Albuquerque:Albuquerque,United_States 
DZ&city=Algiers:Algiers,Algeria 
KZ&city=Almaty:Almaty,Kazakhstan 
ID3&city=Ambon:Ambon,Indonesia 
JO&city=Amman:Amman,Jordan 
NL&city=Amsterdam:Amsterdam,Netherlands 
RU-CHU&city=Anadyr':Anadyr',Russia 
US-AK&city=Anchorage:Anchorage,United_States 
AD&city=Andorra_La_Vella:Andorra_La_Vella,Andorra 
TR&city=Ankara:Ankara,Turkey 
US-MD&city=Annapolis:Annapolis,United_States 
MG&city=Antananarivo:Antananarivo,Madagascar 
WS&city=Apia:Apia,Samoa 
RU-ARK&city=Arkhangelsk:Arkhangelsk,Russia 
CA-NT2B&city=Arviat:Arviat,Canada 
TM&city=Ashgabat:Ashgabat,Turkmenistan 
ER&city=Asmara:Asmara,Eritrea 
KZ&city=Astana:Astana,Kazakhstan 
RU-AST&city=Astrakhan':Astrakhan',Russia 
PY&city=Asuncion:Asuncion,Paraguay 
GR&city=Athens:Athens,Greece 
US-GA&city=Atlanta:Atlanta,United_States 
KZ1&city=Atyrau:Atyrau,Kazakhstan 
NZ&city=Auckland:Auckland,NewZealand 
US-ME&city=Augusta:Augusta,United_States 
US-TX&city=Austin:Austin,United_States 
IQ&city=Baghdad:Baghdad,Iraq 
AR-BA&city=Bahía_Blanca:Bahía_Blanca,Argentina 
AZ&city=Baku:Baku,Azerbaijan 
US-MB&city=Baltimore:Baltimore,United_States 
ML&city=Bamako:Bamako,Mali 
BN&city=Bandar_Seri_Begawan:Bandar_Seri_Begawan,Brunei_Darussalam 
IN&city=Bangalore:Bangalore,India 
TH&city=Bangkok:Bangkok,Thailand 
CF&city=Bangui:Bangui,Central_African_Republic 
ID2&city=Banjarmasin:Banjarmasin,Indonesia 
GM&city=Banjul:Banjul,Gambia 
ES&city=Barcelona:Barcelona,Spain 
RU-ALT&city=Barnaul:Barnaul,Russia 
KN&city=Basseterre:Basseterre,SaintKitts_and_Nevis 
RU-SA2&city=Batagay:Batagay,Russia 
CN&city=Beijing:Beijing,China 
LB&city=Beirut:Beirut,Lebanon 
BR-PA1&city=Belém:Belém,Brazil 
GB&city=Belfast:Belfast,United_Kingdom 
RU-BEL&city=Belgorod:Belgorod,Russia 
CS&city=Belgrade:Belgrade,Serbia_and_Montenegro 
BZ&city=Belize_City:Belize_City,Belize 
BR-MG&city=Belo_Horizonte:Belo_Horizonte,Brazil 
DE&city=Berlin:Berlin,Germany 
CH&city=Bern:Bern,Switzerland 
US-MT&city=Billings:Billings,United_States 
GB&city=Birmingham:Birmingham,United_Kingdom 
US-AL&city=Birmingham:Birmingham,United_States 
RU-YEV&city=Birobidzhan:Birobidzhan,Russia 
KG&city=Bishkek:Bishkek,Kyrgyzstan 
US-ND&city=Bismarck:Bismarck,United_States 
GW&city=Bissau:Bissau,Guinea-Bissau 
RU-AMU&city=Blagoveshchensk:Blagoveshchensk,Russia 
CO&city=Bogota:Bogota,Colombia 
US-MA&city=Boise:Boise,United_States 
DE&city=Bonn:Bonn,Germany 
US-MA&city=Boston:Boston,United_States 
BR-DF&city=Brasilia:Brasilia,Brazil 
SK&city=Bratislava:Bratislava,Slovakia 
RU-IRK&city=Bratsk:Bratsk,Russia 
CG&city=Brazzaville:Brazzaville,Congo 
RU-CT&city=Bridgeport:Bridgeport,United_States 
BB&city=Bridgetown:Bridgetown,Barbados 
AU-QLD&city=Brisbane:Brisbane,Australia 
BE&city=Brussels:Brussels,Belgium 
RU-BRY&city=Bryansk:Bryansk,Russia 
RO&city=Bucharest:Bucharest,Romania 
HU&city=Budapest:Budapest,Hungary 
AR-DF&city=Buenos_Aires:Buenos_Aires,Argentina 
US-NY&city=Buffalo:Buffalo,United_States 
BI&city=Bujumbura:Bujumbura,Burundi 
US-VT&city=Burlington:Burlington,United_States 
EG&city=Cairo:Cairo,Egypt 
IN&city=Calcutta:Calcutta,India 
CA-AB&city=Calgary:Calgary,Canada 
AU-ACT&city=Canberra:Canberra,Australia 
ZACape&city=Town:Town,South_Africa 
VE&city=Caracas:Caracas,Venezuela 
GB&city=Cardiff:Cardiff,United_Kingdom 
MA&city=Casablanca:Casablanca,Morocco 
LC&city=Castries:Castries,Saint_Lucia 
AR-CT&city=Catamarca:Catamarca,Argentina 
GF&city=Cayenne:Cayenne,French_Guiana 
US-WV&city=Charleston:Charleston,United_States 
US-NC&city=Charlotte:Charlotte,United_States 
RU-CU&city=Cheboksary:Cheboksary,Russia 
RU-CHE&city=Chelyabinsk:Chelyabinsk,Russia 
CN&city=Chengdu:Chengdu,China 
IN&city=Chennai:Chennai,India 
RU-KC&city=Cherkessk:Cherkessk,Russia 
US-WY&city=Cheyenne:Cheyenne,United_States 
US-IL&city=Chicago:Chicago,United_States 
MD&city=Chisinau:Chisinau,Moldova,Republic_of 
RU-CHI&city=Chita:Chita,Russia 
CN&city=Chongqing:Chongqing,China 
US-OH&city=Cincinnati:Cincinnati,United_States 
MX2-3&city=Ciudad_Juárez:Ciudad_Juárez,Mexico 
US-OH&city=Cleveland:Cleveland,United_States 
LK&city=Colombo:Colombo,Sri_Lanka 
US-SC&city=Columbia:Columbia,United_States 
US-OH&city=Columbus:Columbus,United_States 
GN&city=Conakry:Conakry,Guinea 
US-NH&city=Concord:Concord,United_States 
DK&city=Copenhagen:Copenhagen,Denmark 
AR-CB&city=Córdoba:Córdoba,Argentina 
AR-CN&city=Corrientes:Corrientes,Argentina 
BJ&city=Cotonou:Cotonou,Benin 
CA-BC1&city=Creston:Creston,Canada 
MX2-2&city=Culiacán:Culiacán,Mexico 
BR-PR&city=Curitiba:Curitiba,Brazil 
SN&city=Dakar:Dakar,Senegal 
US-TX&city=Dallas:Dallas,United_States 
SY&city=Damascus:Damascus,Syrian_Arab_Republic 
TZ&city=Dar_es_Salaam:Dar_es_Salaam,Tanzania,United_Republic_of 
AU-NT&city=Darwin:Darwin,Australia 
CA-BC1&city=Dawson_Creek:Dawson_Creek,Canada 
CA-YT&city=Dawson:Dawson,Canada 
ID2&city=Denpasar:Denpasar,Indonesia 
US-CO&city=Denver:Denver,United_States 
US-IA&city=Des_Moines:Des_Moines,United_States 
US-MI&city=Detroit:Detroit,United_States 
BD&city=Dhaka:Dhaka,Bangladesh 
TL&city=Dili:Dili,Timor-Leste 
DJ&city=Djibouti:Djibouti,Djibouti 
QA&city=Doha:Doha,Qatar 
US-DE&city=Dover:Dover,United_States 
AE&city=Dubai:Dubai,United_Arab_Emirates 
IE&city=Dublin:Dublin,Ireland 
RU-TAY&city=Dudinka:Dudinka,Russia 
TJ&city=Dushanbe:Dushanbe,Tajikistan 
GB&city=Edinburgh:Edinburgh,United_Kingdom 
CA-AB&city=Edmonton:Edmonton,Canada 
US-TX1&city=ElPaso:ElPaso,United_States 
RU-KL&city=Elista:Elista,Russia 
MX3&city=Ensenada:Ensenada,Mexico 
US-IN1&city=Evansville:Evansville,United_States 
TK&city=Fakaofo:Fakaofo,Tokelau 
US-ND&city=Fargo:Fargo,United_States 
AR-FM&city=Formosa:Formosa,Argentina 
US-IN&city=Fort_Wayne:Fort_Wayne,United_States 
BR-CE&city=Fortaleza:Fortaleza,Brazil 
DE&city=Frankfurt:Frankfurt,Germany 
SL&city=Freetown:Freetown,SierraLeone 
TV&city=Funafuti:Funafuti,Tuvalu 
BW&city=Gaborone:Gaborone,Botswana 
US-IN1&city=Gary:Gary,United_States 
CH&city=Geneva:Geneva,Switzerland 
GY&city=Georgetown:Georgetown,Guyana 
GB&city=Glasgow:Glasgow,United_Kingdom 
RU-AL&city=Gorno-Altaisk:Gorno-Altaisk,Russia 
RU-CE&city=Groznyy:Groznyy,Russia 
MX&city=Guadalajara:Guadalajara,Mexico 
GT&city=Guatemala_City:Guatemala_City,Guatemala 
NL&city=Hague:Hague,The,Netherlands 
CA-NS&city=Halifax:Halifax,Canada 
BM&city=Hamilton:Hamilton,Bermuda 
VN&city=Hanoi:Hanoi,Viet_Nam 
ZW&city=Harare:Harare,Zimbabwe 
US-CT&city=Hartford:Hartford,United_States 
CU&city=Havana:Havana,Cuba 
FI&city=Helsinki:Helsinki,Finland 
MX2A&city=Hermosillo:Hermosillo,Mexico 
VN&city=Ho_Chi_Minh_City:Ho_Chi_Minh_City,Viet_Nam 
AU-TAS&city=Hobart:Hobart,Australia 
HK&city=HongKong:HongKong,HongKong 
SB&city=Honiara:Honiara,Solomon_Islands 
US-HI&city=Honolulu:Honolulu,United_States 
US-TX&city=Houston:Houston,United_States 
US-IN&city=Indianapolis:Indianapolis,United_States 
RU-IRK&city=Irkutsk:Irkutsk,Russia 
PK&city=Islamabad:Islamabad,Pakistan 
TR&city=Istanbul:Istanbul,Turkey 
RU-IVA&city=Ivanovo:Ivanovo,Russia 
RU-UD&city=Izhevsk:Izhevsk,Russia 
US-MS&city=Jackson:Jackson,United_States 
US-FL&city=Jacksonville:Jacksonville,United_States 
ID&city=Jakarta:Jakarta,Indonesia 
ID3&city=Jayapura:Jayapura,Indonesia 
IL&city=Jerusalem:Jerusalem,Israel 
ZA&city=Johannesburg:Johannesburg,South_Africa 
AR-JY&city=Jujuy:Jujuy,Argentina 
US-AK&city=Juneau:Juneau,United_States 
AF&city=Kabul:Kabul,Afghanistan 
RU-KGD&city=Kaliningrad:Kaliningrad,Russia 
RU-KLU&city=Kaluga:Kaluga,Russia 
UG&city=Kampala:Kampala,Uganda 
CD2&city=Kananga:Kananga,Congo,Democratic_Republic_of 
NG&city=Kano:Kano,Nigeria 
US-MO&city=Kansas_City:Kansas_City,United_States 
PK&city=Karachi:Karachi,Pakistan 
RU-TA&city=Kazan':Kazan',Russia 
RU-KEM&city=Kemerovo:Kemerovo,Russia 
RU-KHA&city=Khabarovsk:Khabarovsk,Russia 
SD&city=Khartoum:Khartoum,Sudan 
UA&city=Kiev:Kiev,Ukraine 
RW&city=Kigali:Kigali,Rwanda 
JM&city=Kingston:Kingston,Jamaica 
VC&city=Kingstown:Kingstown,Saint_Vincent_and_The_Grenadines 
CD&city=Kinshasa:Kinshasa,Congo,Democratic_Republic_of 
RU-KIR&city=Kirov:Kirov,Russia 
US-TN1&city=Knoxville:Knoxville,United_States 
FM&city=Kolonia:Kolonia,Micronesia,Federated_States_Of 
CD2&city=Kolwezi:Kolwezi,Congo,Democratic_Republic_of 
KZ&city=Konstanai:Konstanai,Kazakhstan 
PW&city=Koror:Koror,Palau 
RU-KOS&city=Kostroma:Kostroma,Russia 
RU-SA3&city=Kotenko:Kotenko,Russia 
PL&city=Krakow:Krakow,Poland 
RU-KDA&city=Krasnodar:Krasnodar,Russia 
RU-KYA&city=Krasnoyarsk:Krasnoyarsk,Russia 
MY&city=Kuala_Lumpur:Kuala_Lumpur,Malaysia 
RU-KOP&city=Kudymkar:Kudymkar,Russia 
ID2&city=Kupang:Kupang,Indonesia 
RU-KGN&city=Kurgan:Kurgan,Russia 
RU-KRS&city=Kursk:Kursk,Russia 
KW&city=KuwaitCity:KuwaitCity,Kuwait 
JP&city=Kyoto:Kyoto,Japan 
RU-TY&city=Kyzyl:Kyzyl,Russia 
KZ&city=Kyzylorda:Kyzylorda,Kazakhstan 
BOLa&city=Paz:Paz,Bolivia 
AR-BA&city=La_Plata:La_Plata,Argentina 
AR-LR&city=La_Rioja:La_Rioja,Argentina 
US-MI&city=Lansing:Lansing,United_States 
US-NV&city=Las_Vegas:Las_Vegas,United_States 
MX&city=León:León,Mexico 
US-KY&city=Lexington:Lexington,United_States 
GA&city=Libreville:Libreville,Gabon 
MW&city=Lilongwe:Lilongwe,Malawi 
PE&city=Lima:Lima,Peru 
US-NE&city=Lincoln:Lincoln,United_States 
RU-LIP&city=Lipetsk:Lipetsk,Russia 
PT&city=Lisbon:Lisbon,Portugal 
US-AR&city=Little_Rock:Little_Rock,United_States 
SI&city=Ljubljana:Ljubljana,Slovenia 
CA-SK1&city=Lloydminster:Lloydminster,Canada 
TG&city=Lome:Lome,Togo 
GB&city=London:London,United_Kingdom 
US-CA&city=Los_Angeles:Los_Angeles,United_States 
US-KY&city=Louisville:Louisville,United_States 
AO&city=Luanda:Luanda,Angola 
CD2&city=Lubumbashi:Lubumbashi,Congo,Democratic_Republic_of 
ZM&city=Lusaka:Lusaka,Zambia 
LU&city=Luxembourg:Luxembourg,Luxembourg 
US-WI&city=Madison:Madison,United_States 
ES&city=Madrid:Madrid,Spain 
RU-MAG&city=Magadan:Magadan,Russia 
MH&city=Majuro:Majuro,Marshall_Islands 
ID2&city=Makassar:Makassar,Indonesia 
RU-DA&city=Makhachkala:Makhachkala,Russia 
GQ&city=Malabo:Malabo,EquatorialGuinea 
MV&city=Male:Male,Maldives 
NI&city=Managua:Managua,Nicaragua 
BH&city=Manama:Manama,Bahrain 
BR-AM&city=Manaus:Manaus,Brazil 
PH&city=Manila:Manila,Philippines 
MZ&city=Maputo:Maputo,Mozambique 
AR-BA&city=Mar_del_Plata:Mar_del_Plata,Argentina 
LS&city=Maseru:Maseru,Lesotho 
RU-AD&city=Maykop:Maykop,Russia 
SZ&city=Mbabane:Mbabane,Swaziland 
CD2&city=Mbuji-Mayi:Mbuji-Mayi,Congo,Democratic_Republic_of 
SA&city=Mecca:Mecca,Saudi_Arabia 
ID&city=Medan:Medan,Indonesia 
AU-VIC&city=Melbourne:Melbourne,Australia 
US-TN&city=Memphis:Memphis,United_States 
AR-MZ&city=Mendoza:Mendoza,Argentina 
MX&city=Mexico_City:Mexico_City,Mexico 
US-FL&city=Miami:Miami,United_States 
IT&city=Milan:Milan,Italy 
US-WI&city=Milwaukee:Milwaukee,United_States 
US-MN&city=Minneapolis:Minneapolis,United_States 
BY&city=Minsk:Minsk,Belarus 
SO&city=Mogadishu:Mogadishu,Somalia 
LR&city=Monrovia:Monrovia,Liberia 
MX&city=Monterrey:Monterrey,Mexico 
UY&city=Montevideo:Montevideo,Uruguay 
US-AL&city=Montgomery:Montgomery,United_States 
US-VT&city=Montpelier:Montpelier,United_States 
CA-QC&city=Montreal:Montreal,Canada 
KM&city=Moroni:Moroni,Comoros 
RU-MOS&city=Moscow:Moscow,Russia 
IN&city=Mumbai:Mumbai,India 
RU-MUR&city=Murmansk:Murmansk,Russia 
OM&city=Muscat:Muscat,Oman 
KE&city=Nairobi:Nairobi,Kenya 
RU-KB&city=Nal'chik:Nal'chik,Russia 
RU-NEN&city=Nar'yan-Mar:Nar'yan-Mar,Russia 
US-TN&city=Nashville:Nashville,United_States 
BS&city=Nassau:Nassau,Bahamas 
RU-IN&city=Nazran:Nazran,Russia 
TD&city=N'Djamena:N'Djamena,Chad 
AR-NQ&city=Neuquén:Neuquén,Argentina 
IN&city=New_Delhi:New_Delhi,India 
US-LA&city=New_Orleans:New_Orleans,United_States 
US-NY&city=New_York:New_York,United_States 
US-NJ&city=Newark:Newark,United_States 
NE&city=Niamey:Niamey,Niger 
CY&city=Nicosia:Nicosia,Cyprus 
RU-KHM&city=Nizhnevartovsk:Nizhnevartovsk,Russia 
RU-NIZ&city=Nizhniy_Novgorod:Nizhniy_Novgorod,Russia 
US-AK&city=Nome:Nome,United_States 
RU-TAY&city=Noril'sk:Noril'sk,Russia 
MR&city=Nouakchott:Nouakchott,Mauritania 
RU-NGR&city=Novgorod:Novgorod,Russia 
RU-NVS&city=Novosibirsk:Novosibirsk,Russia 
GL&city=Nuuk:Nuuk,Greenland 
US-OK&city=Oklahoma_City:Oklahoma_City,United_States 
US-NE&city=Omaha:Omaha,United_States 
RU-OMS&city=Omsk:Omsk,Russia 
RU-ORL&city=Orël:Orël,Russia 
RU-ORE&city=Orenburg:Orenburg,Russia 
US-FL&city=Orlando:Orlando,United_States 
JP&city=Osaka:Osaka,Japan 
NO&city=Oslo:Oslo,Norway 
CA-ON&city=Ottawa:Ottawa,Canada 
BF&city=Ouagadougou:Ouagadougou,BurkinaFaso 
RU-KOR&city=Palana:Palana,Russia 
FM&city=Palikir:Palikir,Micronesia,Federated_States_Of 
PA&city=PanamaCity:PanamaCity,Panama 
SR&city=Paramaribo:Paramaribo,Suriname 
AR-ER&city=Paraná:Paraná,Argentina 
FR&city=Paris:Paris,France 
US-FL1&city=Pensacola:Pensacola,United_States 
RU-PNZ&city=Penza:Penza,Russia 
RU-PER&city=Perm:Perm,Russia 
AU-WA&city=Perth:Perth,Australia 
RU-KA&city=Petropavlovsk-Kamchatskiy:Petropavlovsk-Kamchatskiy,Russia 
RU-KR&city=Petrozavodsk:Petrozavodsk,Russia 
US-PA&city=Philadelphia:Philadelphia,United_States 
KH&city=PhnomPenh:PhnomPenh,Cambodia 
US-AZ&city=Phoenix:Phoenix,United_States 
US-SD&city=Pierre:Pierre,United_States 
US-PA&city=Pittsburgh:Pittsburgh,United_States 
MU&city=Port_Louis:Port_Louis,Mauritius 
PG&city=Port_Moresby:Port_Moresby,Papua_New_Guinea 
FK&city=Port_Stanley:Port_Stanley,Falkland_Islands_(Malvinas) 
HT&city=Port-au-Prince:Port-au-Prince,Haiti 
US-OR&city=Portland:Portland,United_States 
US-ME&city=Portland:Portland,United_States 
BR-RS&city=Porto_Alegre:Porto_Alegre,Brazil 
TT&city=Port-of-Spain:Port-of-Spain,Trinidad_and_Tobago 
VU&city=Port-Vila:Port-Vila,Vanuatu 
AR-MN&city=Posadas:Posadas,Argentina 
CZ&city=Prague:Prague,CzechRepublic 
CV&city=Praia:Praia,CapeVerde 
ZA&city=Pretoria:Pretoria,SouthAfrica 
US-RI&city=Providence:Providence,United_States 
RU-PSK&city=Pskov:Pskov,Russia 
MX&city=Puebla:Puebla,Mexico 
KP&city=Pyongyang:Pyongyang,Korea,Democratic_People's_Republic_of 
EC&city=Quito:Quito,Ecuador 
MA&city=Rabat:Rabat,Morocco 
US-NC&city=Raleigh:Raleigh,United_States 
PS&city=Ramallah:Ramallah,PalestinianTerritory 
MM&city=Rangoon:Rangoon,Myanmar 
US-SD1&city=Rapid_City:Rapid_City,United_States 
CK&city=Rarotonga:Rarotonga,CookIslands 
AR-CH&city=Rawson:Rawson,Argentina 
BR-PE&city=Recife:Recife,Brazil 
CA-SK&city=Regina:Regina,Canada 
US-NV&city=Reno:Reno,United_States 
AR-CC&city=Resistencia:Resistencia,Argentina 
IS&city=Reykjavik:Reykjavik,Iceland 
US-VA&city=Richmond:Richmond,United_States 
LV&city=Riga:Riga,Latvia 
BR-RJ&city=Rio_de_Janeiro:Rio_de_Janeiro,Brazil 
AR-SC&city=Rio_Gallegos:Rio_Gallegos,Argentina 
SA&city=Riyadh:Riyadh,Saudi_Arabia 
IT&city=Rome:Rome,Italy 
AR-SF&city=Rosario:Rosario,Argentina 
DM&city=Roseau:Roseau,Dominica 
RU-ROS&city=Rostov-na-Donu:Rostov-na-Donu,Russia 
RU-RYA&city=Ryazan':Ryazan',Russia 
US-CA&city=Sacramento:Sacramento,United_States 
GD&city=Saint_George's:Saint_George's,Grenada 
RU-YAN&city=Salekhard:Salekhard,Russia 
US-OR&city=Salem:Salem,United_States 
US-UT&city=Salt_Lake_City:Salt_Lake_City,United_States 
AR-SA&city=Salta:Salta,Argentina 
BR-BA&city=Salvador:Salvador,Brazil 
AT&city=Salzburg:Salzburg,Austria 
RU-SAM&city=Samara:Samara,Russia 
US-TX&city=San_Antonio:San_Antonio,United_States 
US-CA&city=San_Diego:San_Diego,United_States 
US-CA&city=San_Francisco:San_Francisco,United_States 
CR&city=San_Jose:San_Jose,Costa_Rica 
AR-SJ&city=San_Juan:San_Juan,Argentina 
PR&city=San_Juan:San_Juan,Puerto_Rico 
MX2&city=San_Lucas:San_Lucas,Mexico 
AR-SL&city=San_Luis:San_Luis,Argentina 
SV&city=San_Salvador:SanSalvador,El_Salvador 
YE&city=Sanaa:Sanaa,Yemen 
AR-SF&city=Santa_Fe:Santa_Fe,Argentina 
AR-LP&city=Santa_Rosa:Santa_Rosa,Argentina 
AR-SE&city=Santiago_del_Estero:Santiago_del_Estero,Argentina 
CL&city=Santiago:Santiago,Chile 
DO&city=Santo_Domingo:Santo_Domingo,Dominican_Republic 
BR-SP&city=Sao_Paulo:Sao_Paulo,Brazil 
BA&city=Sarajevo:Sarajevo,Bosnia_and_Herzegovina 
RU-MO&city=Saransk:Saransk,Russia 
RU-SAR&city=Saratov:Saratov,Russia 
CA-SK&city=Saskatoon:Saskatoon,Canada 
GL3&city=Scoresbysund:Scoresbysund,Greenland 
US-WA&city=Seattle:Seattle,United_States 
KR&city=Seoul:Seoul,Korea,Republicof 
CN&city=Shanghai:Shanghai,China 
SG&city=Singapore_City:Singapore_City,Singapore 
US-SD&city=Sioux_Falls:Sioux_Falls,United_States 
MK&city=Skopje:Skopje,Macedonia,The_Former_Yugoslav_Republic_Of 
RU-SMO&city=Smolensk:Smolensk,Russia 
BG&city=Sofia:Sofia,Bulgaria 
US-IL&city=Springfield:Springfield,United_States 
AG&city=St._John's:St._John's,Antigua_and_Barbuda 
CA-NF&city=St._John's:St._John's,Canada 
US-MO&city=St._Louis:St._Louis,United_States 
US-MN&city=St._Paul:St._Paul,United_States 
RU-LEN&city=St._Petersburg:St._Petersburg,Russia 
RU-STA&city=Stavropol':Stavropol',Russia 
SE&city=Stockholm:Stockholm,Sweden 
ID&city=Surabaya:Surabaya,Indonesia 
FJ&city=Suva:Suva,Fiji 
AU-NSW&city=Sydney:Sydney,Australia 
RU-KO&city=Syktyvkar:Syktyvkar,Russia 
TW&city=Taipei:Taipei,Taiwan 
US-FL&city=Tallahassee:Tallahassee,United_States 
EE&city=Tallinn:Tallinn,Estonia 
RU-TAM&city=Tambov:Tambov,Russia 
MA&city=Tangier:Tangier,Morocco 
UZ&city=Tashkent:Tashkent,Uzbekistan 
GE&city=Tbilisi:Tbilisi,Georgia 
HN&city=Tegucigalpa:Tegucigalpa,Honduras 
IR&city=Tehran:Tehran,Iran,Islamic_Republic_of 
IL&city=Tel_Aviv:Tel_Aviv,Israel 
MX2-1&city=Tepic:Tepic,Mexico 
US-IN&city=Terre_Haute:Terre_Haute,United_States 
BT&city=Thimphu:Thimphu,Bhutan 
GL2&city=Thule:Thule,Greenland 
MX3&city=Tijuana:Tijuana,Mexico 
AL&city=Tirane:Tirane,Albania 
JP&city=Tokyo:Tokyo,Japan 
RU-TOM&city=Tomsk:Tomsk,Russia 
US-KS&city=Topeka:Topeka,United_States 
CA-ON&city=Toronto:Toronto,Canada 
US-NJ&city=Trenton:Trenton,United_States 
LY&city=Tripoli:Tripoli,Libyan_Arab_Jamahiriya 
US-AZ&city=Tucson:Tucson,United_States 
AR-TM&city=Tucumán:Tucumán,Argentina 
RU-TUL&city=Tula:Tula,Russia 
TN&city=Tunis:Tunis,Tunisia 
RU-EVE&city=Tura:Tura,Russia 
RU-TVE&city=Tver':Tver',Russia 
RU-TYU&city=Tyumen':Tyumen',Russia 
RU-BA&city=Ufa:Ufa,Russia 
MN&city=Ulaanbaatar:Ulaanbaatar,Mongolia 
RU-BU&city=Ulan-Ude:Ulan-Ude,Russia 
RU-ULY&city=Ul'yanovsk:Ul'yanovsk,Russia 
KZ1&city=Uralsk:Uralsk,Kazakhstan 
AR-TF&city=Ushuaia:Ushuaia,Argentina 
RU-UOB&city=Ust'-Ordynskiy:Ust'-Ordynskiy,Russia 
LI&city=Vaduz:Vaduz,Liechtenstein 
MT&city=Valletta:Valletta,Malta 
CA-BC&city=Vancouver:Vancouver,Canada 
CA-BC&city=Victoria:Victoria,Canada 
SC&city=Victoria:Victoria,Seychelles 
AR-RN&city=Viedma:Viedma,Argentina 
AT&city=Vienna:Vienna,Austria 
LA&city=Vientiane:Vientiane,Lao_People's_Democratic_Republic 
LT&city=Vilnius:Vilnius,Lithuania 
US-VA&city=Virginia_Beach:Virginia_Beach,United_States 
RU-SE&city=Vladikavkaz:Vladikavkaz,Russia 
RU-VLA&city=Vladimir:Vladimir,Russia 
RU-PRI&city=Vladivostok:Vladivostok,Russia 
RU-VGG&city=Volgograd:Volgograd,Russia 
RU-VLG&city=Vologda:Vologda,Russia 
RU-KO&city=Vorkuta:Vorkuta,Russia 
RU-VOR&city=Voronezh:Voronezh,Russia 
PL&city=Warsaw:Warsaw,Poland 
UZ-DC&city=Washington:Washington,United_States 
NZ&city=Wellington:Wellington,NewZealand 
US-KS&city=Wichita:Wichita,United_States 
US-DE&city=Wilmington:Wilmington,United_States 
NA&city=Windhoek:Windhoek,Namibia 
CA-MB&city=Winnipeg:Winnipeg,Canada 
CN&city=Wuhan:Wuhan,China 
RU-SA&city=Yakutsk:Yakutsk,Russia 
CM&city=Yaounde:Yaounde,Cameroon 
RU-YAR&city=Yarolavl':Yarolavl',Russia 
RU-SVE&city=Yekaterinburg:Yekaterinburg,Russia 
AM&city=Yerevan:Yerevan,Armenia 
JP&city=Yokohama:Yokohama,Japan 
RU-ME&city=Yoshkar-Ola:Yoshkar-Ola,Russia 
RU-SAK&city=Yuzhno-Sakhalinsk:Yuzhno-Sakhalinsk,Russia 
HR&city=Zagreb:Zagreb,Croatia 
CH&city=Zurich:Zurich,Switzerland 
} 
  set itmatched 0 

  if {$location == ""} { 
     putserv "NOTICE $nick :\002\037Worldtime.tcl 1.2 Help\037:\002" 
     putserv "NOTICE $nick :USAGE: \002!tz\002 <city|country|city,country>" 
     putserv "NOTICE $nick :Cities are listed alphabetically, so if you enter\ 
a country, you will get the first city in the list for that country" 
     putserv "NOTICE $nick :\002\eg1 :\002 !tz Lima,Peru" 
     putserv "NOTICE $nick :\002\eg2 :\002 !tz Lima" 
     putserv "NOTICE $nick :\002\037End of Worldtime.tcl Help\037\002" 
     return 0 
  } 
  set inloc [string trim [string tolower $location]] 
  regsub  -all { } $inloc {_} tloc 
  foreach i $city_list { 
     set tempurl [lindex [split $i :] 0] 
     set temploc [lindex [split $i :] 1] 
     if {[string first $tloc [string tolower $temploc]] != -1} { 
        set itmatched 1 
        break 
     } 
  } 
  if {[string first mcmurdo $tloc] !=-1} { 
     set tempurl NZ&city=Wellington 
     set temploc Mcmurdo_Station,Antarctica 
     set itmatched 1 
  } 
  if {[string first south_pole $tloc] !=-1} { 
     set tempurl NZ&city=Wellington 
     set temploc South_Pole,Antarctica 
     set itmatched 1 
  } 
  if {[lsearch -exact {[censored] poo crap} $tloc] != -1} { 
     set tempurl UTC 
     set temploc toilet 
     set itmatched 1 
  } 
  if {[lsearch -exact {[censored] nigger [censored]} $tloc] != -1} { 
     set tempurl UTC 
     set temploc kick 
     set itmatched 1 
  } 
  if {$itmatched == 0} { 
     putserv "NOTICE $nick :Sorry no match on $inloc, try a different city" 
     return 0 
  } 
  if {[string compare [lindex [split $temploc ,] 1] United_States] == 1} { 
     set temploc [lindex [split $temploc ,] 0] 
  } 
set tempurl [split $tempurl &] 
  set url "/current_time_in_[lindex $tempurl 0].aspx?[lindex $tempurl 1]" 
  return "$url $temploc" 
} 

putlog "WorldTime v1.1 by Murf (modified by LOQUILLO_) loaded" 
Now bot answer:
<@LOQUILLO> !tz Lima
<@claus_sp> The time in Lima,Peru is 00:38
<@LOQUILLO> !tz amsterdam
<@claus_sp> The time in Amsterdam,Netherlands is 06:42
<@LOQUILLO> !tz Lima
<@claus_sp> The time in Lima,Peru is 00:42

Now show time.
;)
LOQUILLO
IRC Network: EFnet
Channel: #Spanglish
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

What does it mean?

Code: Select all

  if {[lsearch -exact {[censored] poo crap} $tloc] != -1} {
and

Code: Select all

  if {[lsearch -exact {[censored] nigger [censored]} $tloc] != -1} {
I think forum blocks badwords from code and change them to [censored], so code what was copypasted from here wouldnt work.

Later:
I understand, I can change [censored] to any word I like to prevent commands like !tz idiot.
User avatar
LOQUILLO
Voice
Posts: 14
Joined: Wed Jul 21, 2004 4:45 pm
Location: Perú

Post by LOQUILLO »

username wrote:What does it mean?

Code: Select all

  if {[lsearch -exact {[censored] poo crap} $tloc] != -1} {
and

Code: Select all

  if {[lsearch -exact {[censored] nigger [censored]} $tloc] != -1} {
I think forum blocks badwords from code and change them to [censored], so code what was copypasted from here wouldnt work.

Later:
I understand, I can change [censored] to any word I like to prevent commands like !tz idiot.
oh! here the newest

Code: Select all

 if {[lsearch -exact {s-h-i-t poo crap} $tloc] != -1} {

Code: Select all

if {[lsearch -exact {f-u-c-k nigger c-u-n-t} $tloc] != -1} {
you have in there the right words but you need delete the "-" in them.
LOQUILLO
IRC Network: EFnet
Channel: #Spanglish
f
froggie
Voice
Posts: 2
Joined: Sat Aug 18, 2007 7:44 pm

Lost it again

Post by froggie »

Not to open an old wound, but I believe the worldtime tcl has broke again. I had the old fix, and sometime between then and now, its fallen over again.

Anyone want to have a fresh look at it?
I am, the Pirate Froglet.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Use the script from this post.

line 109 - change from:

Code: Select all

regexp {<div id="analog-digital"><font size="7">(.+?)</font></div>} $tzout {} tztime
line 109 - change to:

Code: Select all

regexp {<div id="analog-digital">.+?<font size="7">(.+?)</font>.+?</div>} $tzout {} tztime
line 111 - change from:

Code: Select all

 return $tztime
line 111 - change to:

Code: Select all

return [string trim $tztime]
<speechles> !tz san francisco
<bot> The time in San Francisco,United States is 18:18
<speechles> !tz new york
<bot> The time in New York,United States is 21:18
Dunno if that is what the expected output should be but if it is, here you go. :lol:
f
froggie
Voice
Posts: 2
Joined: Sat Aug 18, 2007 7:44 pm

yay!

Post by froggie »

Woot, works again, thank you! :mrgreen:
I am, the Pirate Froglet.
Z
Zircon
Op
Posts: 191
Joined: Mon Aug 21, 2006 4:22 am
Location: Montreal

Post by Zircon »

Hi all

Worldtime.tcl isnt working again. I think something did change in the website and the script cant parse it correctly. Does anyone have a fix for it ? maybe speechles can help us :)
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Zircon wrote:Hi all

Worldtime.tcl isnt working again. I think something did change in the website and the script cant parse it correctly. Does anyone have a fix for it ? maybe speechles can help us :)
Sure I can, this is a simple regexp fix. Enjoy :wink:

line 109 - change from:

Code: Select all

regexp {<div id="analog-digital">.+?<font size="7">(.+?)</font>.+?</div>} $tzout {} tztime
line 109 - change to:

Code: Select all

regexp {<div id="analog-digital">.+?<span class="font7">(.+?)</span>.+?</div>} $tzout {} tztime
Conversely, for a bit more added info, you can change line 109 & 110 to this:

Code: Select all

regexp {<div id="analog-digital">.+?<span class="font7">(.+?)<.+?<span class="font1">(.+?)<} $tzout {} tztime tzzone
return "[string trim $tztime] [string trim $tzzone]"
#NoWordWrap##########################################################################################################
#NoWordWrap### only present to defeat linefeeds on the forum, isn't code you need to use.
example from irc wrote:<speechles> !tz san francisco
<sp33chy> The time in San Francisco,United States is 13:14 Pacific Daylight Time (PDT) -0700 UTC
<speechles> !tz berlin
<sp33chy> The time in Berlin,Germany is 22:16 Central European Summer Time (CEST) +0200 UTC
Tip: You can put what is below after your get html routine, but before the actual parsing begins, as a way to help debug.

Code: Select all

# DEBUG DEBUG                    
set $_debug [open "my_debug.txt" w]
puts $_debug $VARIABLE_STORING_YOUR_HTML
close $_debug
Load your my_debug.txt into a program such as RegexBuddy or similar, it makes dealing with regular expressions childs play.
Last edited by speechles on Sat Sep 22, 2007 6:59 pm, edited 1 time in total.
Z
Zircon
Op
Posts: 191
Joined: Mon Aug 21, 2006 4:22 am
Location: Montreal

Post by Zircon »

Hello speechles

Thanks a lot, it s working again, and thanks for the other infos :)
p
panasonic
Voice
Posts: 25
Joined: Sat Sep 15, 2007 5:27 am

Post by panasonic »

hi!
can u update the latest fixes on the first page so we dont have to scroll pages to see where's the latest fixes?

can i know whether this script can be set to active on certain channel the bot is in by setting e.g .chanset #channel +worldtime ?

btw thanks for this great script!
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

panasonic wrote:hi!
can u update the latest fixes on the first page so we dont have to scroll pages to see where's the latest fixes?
Nah, doing on the first page makes it too easy (not to mention, I'm not LOQUILLO so how do you suggest I edit his post?). Let's instead bury the link to the the full working script here in this part of the thread.. Make them work for their bread.. heh.. Anyways, to get it (click here worldtime v1.3)
panasonic wrote:can i know whether this script can be set to active on certain channel the bot is in by setting e.g .chanset #channel +worldtime ?
It will now work using .chanset #yourchan +worldtime per your request.

Code: Select all

#    v1.3 Nov 02 2007 updated by speechles                            #
#       -- Fixed the regexp scraper.                                  #
#       -- Added scraper for new info to display, exciting! :P        #
#       -- Added chanset ability .chanset #yourchan +worldtime        #
#       -- Added preliminary Multi-Language ability.                  #
#       -- Script now scrapes entire output line directly from the    #
#          webpage, and how it has multilanguage capability, default  #
#          at the moment is english.                                  #
sample from irc wrote:<speechles> !tz .de san francisco
<sp33chy> The current time in San Francisco, California, United States is 17:20 Pacific Daylight Time (PDT) -0700 UTC @ Freitag, 2. November 2007
<speechles> !tz san francisco
<sp33chy> The current time in San Francisco, California, United States is 5:20 PM Pacific Daylight Time (PDT) -0700 UTC @ Friday, November 02, 2007
<speechles> !tz .fr san francisco
<sp33chy> The current time in San Francisco, California, United States is 17:15 Pacific Daylight Time (PDT) -0700 UTC @ vendredi 2 novembre 2007
Now you have a 'full blown' time script. The multi language is functional, but just the date seems to be changing not the 'The current time in...' line (blame the website)... enjoy never the less :wink:
Take note: The multi-language at the moment is an undocumented feature and the comments do not reference it in the usage portion, because of it's limitations. It's there if you want to use it for some reason...
p
panasonic
Voice
Posts: 25
Joined: Sat Sep 15, 2007 5:27 am

Post by panasonic »

thanks sir, it works great!

Code: Select all

<panasonic> !time new york
<chanBot> The current time in New York, New York, United States is 2:02 AM Eastern Daylight Time (EDT) -0400 UTC @ Saturday, November 03, 2007
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

<speechles> !tz san fran
<sp33chy> The current time in San Francisco, California, United States is 8:24 AM Pacific Standard Time (PST) -0800 UTC @ Sunday, November 25, 2007

<speechles> !tz .fr australia
<sp33chy> The current time in Adelaide, South Australia, Australia is 02:55 Central Daylight Time (CDT) +1030 UTC @ lundi 26 novembre 2007
Corrected minor issue with script giving no reply. Method used to parse now allows for much greater changes in html, so minor website changes should no longer affect this script.
Enjoy WorldTime v1.3 available here.
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

Post by Exedore »

!This last upgrade works perfect!

BUT..

¿What should I do, to make the bot sends the text in spanish?

Code: Select all

<speechles> !tz san fran
<sp33chy> La hora actual en San Francisco, California, Estados Unidos es 8:24 AM Pacific Standard Time (PST) -0800 UTC @ Domingo 25 de Noviembre de 2007
Or at least partially...

This TCL is great!

Thxs
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Exedore wrote:!This last upgrade works perfect!

BUT..

¿What should I do, to make the bot sends the text in spanish?

Code: Select all

<speechles> !tz san fran
<sp33chy> La hora actual en San Francisco, California, Estados Unidos es 8:24 AM Pacific Standard Time (PST) -0800 UTC @ Domingo 25 de Noviembre de 2007
Or at least partially...

This TCL is great!

Thxs
The partially part I can do for you, in fact, you already have the ability to do so.
<speechles> !tz .es san francisco
<sp33chy> The current time in San Francisco, California, United States is 22:04 Pacific Daylight Time (PDT) -0700 UTC @ miércoles, 16 de abril de 2008
<speechles> !tz .fr new york
<sp33chy> The current time in New York, New York, United States is 01:08 Eastern Daylight Time (EDT) -0400 UTC @ jeudi 17 avril 2008
<speechles> !tz .it london
<sp33chy> The current time in London, United Kingdom is 6.08 DST +0100 UTC @ giovedì 17 aprile 2008
Unfortunately, you can see the parts which remain in english (this is a limitation of the website, not the script). But, you can use this for any regional dialect and it will work similar to how it does in the unoffficial google script.
Post Reply