Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
e8683efc
Commit
e8683efc
authored
14 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup
parent
8283ce21
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/ircbots/weather/weather_commands.js
+33
-12
33 additions, 12 deletions
exec/ircbots/weather/weather_commands.js
with
33 additions
and
12 deletions
exec/ircbots/weather/weather_commands.js
+
33
−
12
View file @
e8683efc
Bot_Commands
[
"
WEATHER
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
WEATHER
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
var
i
;
var
lstr
;
if
(
!
cmd
[
1
])
cmd
[
1
]
=
onick
;
...
...
@@ -8,22 +10,41 @@ Bot_Commands["WEATHER"].command = function (target,onick,ouh,srv,lvl,cmd) {
var
usr
=
new
User
(
system
.
matchuser
(
cmd
[
1
]));
cmd
.
shift
();
if
(
typeof
(
usr
)
==
'
object
'
)
query
=
usr
.
location
;
if
(
!
query
)
query
=
cmd
.
join
(
'
'
);
query
=
query
.
replace
(
/
[
]
/
,
'
%20
'
);
lstr
=
usr
.
location
;
if
(
!
lstr
)
lstr
=
cmd
.
join
(
'
'
);
query
=
encodeURIComponent
(
lstr
);
var
weather_url
=
"
http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=
"
+
query
;
var
location_url
=
"
http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=
"
+
query
;
var
Weather
=
new
XML
((
new
HTTPRequest
().
Get
(
weather
_url
)).
replace
(
/<
\?
.*
\?
>
[\r\n\s]
*/
,
''
));
var
Location
=
new
XML
((
new
HTTPRequest
().
Get
(
location
_url
)).
replace
(
/<
\?
.*
\?
>
[\r\n\s]
*/
,
''
));
var
str
=
Weather
.
display_location
.
full
+
"
-
"
+
Weather
.
temperature_string
+
"
(Observed at:
"
+
Weather
.
observation_location
.
city
+
"
)
"
;
/* if (Weather.display_location.full=="" || !Weather.temperature_string=="")
str = "No result."; */
switch
(
Location
.
location
.
length
())
{
case
0
:
if
(
Location
.
nearby_weather_stations
.
length
()
==
0
)
{
srv
.
o
(
target
,
"
Unable to locate
"
+
lstr
);
break
;
}
// Fall-through
case
1
:
var
Weather
=
new
XML
((
new
HTTPRequest
().
Get
(
weather_url
)).
replace
(
/<
\?
.*
\?
>
[\r\n\s]
*/
,
''
));
var
str
=
Weather
.
display_location
.
full
;
str
+=
"
-
"
+
Weather
.
weather
;
str
+=
"
,
"
+
Weather
.
temp_c
+
"
degrees (
"
+
(
parseInt
(
Weather
.
temp_c
)
+
273
)
+
"
K,
"
+
Weather
.
temp_f
+
"
F)
"
;
str
+=
"
Wind
"
+
Weather
.
wind_string
;
if
(
Weather
.
display_location
.
city
!=
Weather
.
observation_location
.
city
)
str
+=
"
(Observed at:
"
+
Weather
.
observation_location
.
city
+
"
)
"
;
str
+=
'
(Provided by Weather Underground, Inc.)
'
;
srv
.
o
(
target
,
str
);
break
;
default
:
srv
.
o
(
target
,
"
Multiple matches for
"
+
lstr
);
for
(
i
in
Location
.
location
)
srv
.
o
(
target
,
lstr
+
'
:
'
+
Location
.
location
[
i
].
name
);
break
;
}
srv
.
o
(
target
,
str
);
return
true
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment