2 from basic_commands
import reply
, troggie
3 from globals import commands
5 def title(who
, where
, args
, all
=False):
6 "$title <url>: Asks Hal to fetch the title of a given URL. Not very useful in a channel, where it's done implicitly whenever someone says a URL."
8 reply(who
, where
, "[%s]" % (html
.get_title(args
)), all
)
11 reply(who
, where
, "Error retrieving URL '%s'." % args
, all
)
12 title
= troggie(title
)
13 commands
['title'] = (perms
.voice
, title
)
15 def title_implicit(who
, where
, args
):
16 "Implicit version of $title."
17 title(who
, where
, args
, all
=True)
18 commands
['title implicit'] = (perms
.voice
, title_implicit
)
20 def calc(who
, where
, args
):
21 "$calc <math>: Asks Google's calculator to do some math for you."
23 reply(who
, where
, "Google says: %s" % html
.google_calc(args
), all
=True)
26 reply(who
, where
, "Ewwww... Google barfed on me.", all
=True)
28 commands
['calc'] = (perms
.voice
, calc
)
30 def google(who
, where
, args
):
31 "$google <search>: Asks Google for its first result for a given search."
33 url
= html
.first_google(args
)
34 reply(who
, where
, "Google says: %s [%s]." % (url
, html
.get_title(url
)), all
=True)
37 reply(who
, where
, "Ewwww... Google barfed on me.", all
=True)
38 #google = troggie(google)
39 commands
['google'] = (perms
.voice
, google
)
41 def jig(who
, where
, args
):
42 "$jig <search>: Ask Google for its first result for a given search, restricted to Jayisgames."
43 google(who
, where
, args
+ " site:jayisgames.com")
45 commands
['jig'] = (perms
.voice
, jig
)
47 def wp(who
, where
, args
):
48 "$wp <search> or $wikipedia <search>: Asks Google for its first result for a given search, restricted to Wikipedia."
49 google(who
, where
, args
+ " site:en.wikipedia.org")
50 commands
['wp'] = (perms
.voice
, wp
)
51 commands
['wikipedia'] = (perms
.voice
, wp
)
53 def onr(who
, where
, args
, comic
=None):
54 "$onr <search>: Searches OhNoRobot.com, returns the first result."
56 url
= html
.first_onr(args
, comic
)
57 reply(who
, where
, "OhNoRobot.com says: %s [%s]." % (url
, html
.get_title(url
)), all
=True)
60 reply(who
, where
, "Oh no! No luck.", all
=True)
61 commands
['onr'] = (perms
.voice
, onr
)
63 def xkcd(who
, where
, args
):
64 "$xkcd <search>: Searches XKCD comics with OhNoRobot.com."
65 onr(who
, where
, args
, 56)
66 commands
['xkcd'] = (perms
.voice
, xkcd
)
68 def weather(who
, where
, args
):
69 "$weather <zipcode or location>: Asks Hal for the weather in a given location. Unfortunately, he doesn't know how yet."
70 reply(who
, where
, "I'm sorry, troggie isn't here, and I don't know how to do that.")
71 weather
= troggie(weather
)
72 commands
['weather'] = (perms
.voice
, weather
)