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
1c9c5a68
Commit
1c9c5a68
authored
11 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Deal with non-present nick.
parent
7443cea6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exec/ircbots/weather/weather_commands.js
+57
-52
57 additions, 52 deletions
exec/ircbots/weather/weather_commands.js
exec/ircbots/whereis/whereis.js
+24
-19
24 additions, 19 deletions
exec/ircbots/whereis/whereis.js
with
81 additions
and
71 deletions
exec/ircbots/weather/weather_commands.js
+
57
−
52
View file @
1c9c5a68
...
...
@@ -15,64 +15,69 @@ Bot_Commands["WEATHER"].command = function (target,onick,ouh,srv,lvl,cmd) {
cmd
.
shift
();
if
(
cmd
[
0
])
nick
=
cmd
[
0
];
lstr
=
get_nicklocation
(
srv
.
users
[
nick
.
toUpperCase
()].
uh
,
srv
.
users
[
nick
.
toUpperCase
()].
servername
,
nick
);
if
(
!
lstr
)
{
var
usr
=
new
User
(
system
.
matchuser
(
nick
));
if
(
typeof
(
usr
)
==
'
object
'
)
lstr
=
usr
.
location
;
if
(
srv
.
users
[
nick
.
toUpperCase
()]
==
undefined
)
{
srv
.
o
(
target
,
nick
+
'
, who the f^@% is
'
+
nick
+
"
?
"
);
}
if
(
!
lstr
&&
cmd
[
0
])
lstr
=
cmd
.
join
(
'
'
);
var
query
=
encodeURIComponent
(
lstr
);
else
{
lstr
=
get_nicklocation
(
srv
.
users
[
nick
.
toUpperCase
()].
uh
,
srv
.
users
[
nick
.
toUpperCase
()].
servername
,
nick
);
if
(
!
lstr
)
{
var
usr
=
new
User
(
system
.
matchuser
(
nick
));
if
(
typeof
(
usr
)
==
'
object
'
)
lstr
=
usr
.
location
;
}
if
(
!
lstr
&&
cmd
[
0
])
lstr
=
cmd
.
join
(
'
'
);
var
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_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
;
try
{
var
Location
=
new
XML
((
new
HTTPRequest
().
Get
(
location_url
)).
replace
(
/<
\?
.*
\?
>
[\r\n\s]
*/
,
''
));
}
catch
(
e
)
{
srv
.
o
(
target
,
"
Unable to resolve location
"
+
lstr
);
return
true
;
}
try
{
var
Location
=
new
XML
((
new
HTTPRequest
().
Get
(
location_url
)).
replace
(
/<
\?
.*
\?
>
[\r\n\s]
*/
,
''
));
}
catch
(
e
)
{
srv
.
o
(
target
,
"
Unable to resolve location
"
+
lstr
);
return
true
;
}
switch
(
Location
.
location
.
length
())
{
case
0
:
if
(
Location
.
nearby_weather_stations
.
length
()
==
0
)
{
srv
.
o
(
target
,
"
Unable to locate
"
+
lstr
);
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
;
}
// Fall-through
case
1
:
var
Weather
=
new
XML
((
new
HTTPRequest
().
Get
(
weather_url
)).
replace
(
/<
\?
.*
\?
>
[\r\n\s]
*/
,
''
));
default
:
srv
.
o
(
target
,
"
Multiple matches for
"
+
lstr
);
if
(
Location
.
location
.
length
()
>
7
)
srv
.
o
(
target
,
lstr
+
"
matches
"
+
Location
.
location
.
length
()
+
"
places... listing the first 7.
"
);
var
outstr
=
""
;
var
outcnt
=
0
;
for
(
i
in
Location
.
location
)
{
if
(
outcnt
)
outstr
+=
"
;
"
;
outstr
+=
Location
.
location
[
i
].
name
;
outcnt
++
;
if
(
outcnt
>=
7
)
break
;
}
srv
.
o
(
target
,
lstr
+
'
:
'
+
outstr
+
'
.
'
);
break
;
}
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
);
if
(
Location
.
location
.
length
()
>
7
)
srv
.
o
(
target
,
lstr
+
"
matches
"
+
Location
.
location
.
length
()
+
"
places... listing the first 7.
"
);
var
outstr
=
""
;
var
outcnt
=
0
;
for
(
i
in
Location
.
location
)
{
if
(
outcnt
)
outstr
+=
"
;
"
;
outstr
+=
Location
.
location
[
i
].
name
;
outcnt
++
;
if
(
outcnt
>=
7
)
break
;
}
srv
.
o
(
target
,
lstr
+
'
:
'
+
outstr
+
'
.
'
);
break
;
}
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
exec/ircbots/whereis/whereis.js
+
24
−
19
View file @
1c9c5a68
...
...
@@ -27,29 +27,34 @@ Bot_Commands["WHEREIS"].command = function (target,onick,ouh,srv,lvl,cmd) {
return
true
;
}
location
=
get_nicklocation
(
srv
.
users
[
find
.
toUpperCase
()].
uh
,
srv
.
users
[
find
.
toUpperCase
()].
servername
,
find
);
if
(
location
)
{
lstr
=
find
+
'
is
'
;
if
(
location
.
cityName
==
''
)
lstr
+=
'
somewhere in
'
;
else
lstr
+=
'
around
'
+
location
.
cityName
+
'
,
'
;
if
(
location
.
regionName
!=
''
)
lstr
+=
location
.
regionName
+
'
,
'
;
if
(
location
.
countryName
!=
''
)
lstr
+=
location
.
countryName
;
if
(
srv
.
users
[
find
.
toUpperCase
()]
==
undefined
)
{
lstr
=
find
+
'
, who the f^@% is
'
+
find
+
"
?
"
;
}
else
{
var
usr
=
new
User
(
system
.
matchuser
(
cmd
[
1
]));
location
=
get_nicklocation
(
srv
.
users
[
find
.
toUpperCase
()].
uh
,
srv
.
users
[
find
.
toUpperCase
()].
servername
,
find
);
if
(
location
)
{
lstr
=
find
+
'
is
'
;
if
(
location
.
cityName
==
''
)
lstr
+=
'
somewhere in
'
;
else
lstr
+=
'
around
'
+
location
.
cityName
+
'
,
'
;
if
(
location
.
regionName
!=
''
)
lstr
+=
location
.
regionName
+
'
,
'
;
if
(
location
.
countryName
!=
''
)
lstr
+=
location
.
countryName
;
}
else
{
var
usr
=
new
User
(
system
.
matchuser
(
cmd
[
1
]));
if
(
typeof
(
usr
)
==
'
object
'
&&
usr
.
location
)
lstr
=
find
+
'
is located at
'
+
usr
.
location
;
}
if
(
typeof
(
usr
)
==
'
object
'
&&
usr
.
location
)
lstr
=
find
+
'
is located at
'
+
usr
.
location
;
}
if
(
!
lstr
)
lstr
=
"
Unable to locate
"
+
find
;
if
(
!
lstr
)
lstr
=
"
Unable to locate
"
+
find
;
}
srv
.
o
(
target
,
lstr
);
...
...
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