구글 날씨 API를 이용해서 적절하게 완성. 제작하는데 소요된 시간은 한시간정도..;
사용법 : !날씨 지역 (국내 도시는 한글로 써도 되지만, 외국 도시의 경우 영어로 써줄것)
; ————————————————————
; | Made by Xeriars |
; | (변경해서 쓰는건 니맘대로지만 이 부분은 지우지 말아주세요.) |
; ————————————————————
on *:text:#: {
if ($1 == !날씨) {
if (!$2) {
msg $chan 사용법 : !날씨 지역” (ex : !날씨 서울)
halt
}
unset %weather.*
set %weather.id $replace($2-,$chr(32),+)
set %weather.id2 $replace(%weather.id,강릉,gangneung,경주,gyeongju,고양,goyang,광명,gwangmyeong,광주,gwangju,구미,gumi,군산,gunsan,군포,gunpo,김해,gimhae,대구,daegu,대전,daejeon,동해,donghae,목포,mokpo,부산,busan,부천,bucheon,서귀포,seogwipo,서울,seoul,성남,seongnam,송탄,songtan,수원,suwon)
set %weather.id2 $replace(%weather.id2,시흥,siheung,안산,ansan,안양,anyang,용인,yongin,울릉도,ulleung-do,울산,ulsan,원주,wonju,의정부,uijeongbu,익산,iksan,인천,incheon,일산,ilsan,전주,jeonju,제주,jeju,진주,jinju,철원,cheorwon,청주,cheongju)
set %weather.id2 $replace(%weather.id2,춘천,chuncheon,파주,paju,평택,pyeongtaek,포항,pohang,흑산도,heuksan-do,충주,chungju,상주,sangju,창원,changwon,천안,cheonan,여수,yeosu,안동,andong,양산,yangsan,태안,taean,진해,jinhae,오산,osan,순천,suncheon,당진,dangjin,마산,masan,삼척,samchok,거제,kuje)
set %weather.chan $chan
sockclose weather
sockopen weather www.google.co.kr 80
halt
}
}
on *:sockopen:weather*: {
sockwrite -nt $sockname GET /ig/api?weather= $+ %weather.id2 HTTP/1.1
sockwrite -nt $sockname User-Agent: Mozilla/4.0
sockwrite -nt $sockname Host: www.google.co.kr
sockwrite -nt $sockname Connection: Close
sockwrite -nt $sockname $crlf
}
on *:sockread:weather: {
sockread %tmp
set %weather.end </xml_api_reply>
set %weather.error problem_cause data
if (%weather.error isin %tmp) {
msg %weather.chan 일시적으로 정보가 사용이 불가능한 지역이거나 검색이 지원되지 않는 지역입니다.
sockclose $sockname
unset %weather.*
}
set %weather.date $remove($gettok(%tmp,9,62),<forecast_date data=,”,$chr(47))
set %weather.condition $remove($gettok(%tmp,14,62),<condition data=,”,$chr(47))
set %weather.tempf $remove($gettok(%tmp,15,62),<temp,$chr(95),data,=,”,$chr(47))
set %weather.tempc $remove($gettok(%tmp,16,62),<temp,$chr(95),data,=,”,$chr(47))
set %weather.humidity $remove($gettok(%tmp,17,62),<humidity data=”습도: ,”,$chr(47))
set %weather.wind $remove($gettok(%tmp,19,62),<wind_condition data=”바람: ,”,$chr(47))
set %weather.week $remove($gettok(%tmp,22,62),<day_of_week data=,”,$chr(47))
set %weather.tomorrow $remove($gettok(%tmp,26,62),<condition data=,”,$chr(47))
set %weather.tomorrow2 $remove($gettok(%tmp,29,62),<day_of_week data=,”,$chr(47))
set %weather.a3days $remove($gettok(%tmp,33,62),<condition data=,”,$chr(47))
set %weather.a3days2 $remove($gettok(%tmp,36,62),<day_of_week data=,”,$chr(47))
set %weather.kmh2ms $mid($calc($remove($gettok(%weather.wind,2,44),kmh) * 1000 / 3600),1,3) m/s
if (%weather.end isin %tmp) {
msg %weather.chan 지역명 : $replace(%weather.id,+,$chr(32)) / 날짜 : %weather.date $+ ( $+ %weather.week $+ ) / 상태 : %weather.condition / 기온 : $mid(%weather.tempc,3) °C ( $+ $mid(%weather.tempf,3) °F) / 습도 : %weather.humidity / 풍속 : $replace(%weather.wind,kmh,km/h) ( $+ %weather.kmh2ms $+ ) / 내일( $+ %weather.tomorrow2 $+ ) : %weather.tomorrow / 모래( $+ %weather.a3days2 $+ ) : %weather.a3days
sockclose $sockname
unset %weather.*
}
}