Pokedex: Provide beta-veekun links.
authorZhorken <zhorken@gmail.com>
Mon, 8 Mar 2010 19:30:44 +0000 (14:30 -0500)
committerZhorken <zhorken@gmail.com>
Mon, 8 Mar 2010 19:30:44 +0000 (14:30 -0500)
plugins/Pokedex/plugin.py

index 6268144..4a1b6f3 100644 (file)
@@ -40,6 +40,8 @@ import pokedex.db
 import pokedex.db.tables as tables
 import pokedex.lookup
 
+import urllib
+
 class Pokedex(callbacks.Plugin):
     """Add the help for "@plugin help Pokedex" here
     This should describe *how* to use this plugin."""
@@ -113,13 +115,15 @@ class Pokedex(callbacks.Plugin):
         if isinstance(obj, tables.Pokemon):
             reply_template = \
                 u"""#{id} {name}, {type}-type Pokémon.  Has {abilities}.  """ \
-                """Is {stats}."""
+                """Is {stats}.  """ \
+                """http://beta.veekun.com/dex/pokemon/{link_name}"""
             self._reply(irc, reply_template.format(
                 id=obj.id,
                 name=obj.name,
                 type='/'.join(_.name for _ in obj.types),
                 abilities=' or '.join(_.name for _ in obj.abilities),
                 stats='/'.join(str(_.base_stat) for _ in obj.stats),
+                link_name=urllib.quote(obj.name.lower()),
                 )
             )
 
@@ -127,7 +131,8 @@ class Pokedex(callbacks.Plugin):
             reply_template = \
                 u"""{name}, {type}-type {damage_class} move.  """ \
                 """{power} power; {accuracy}% accuracy; {pp} PP.  """ \
-                """{effect}"""
+                """{effect}  """ \
+                """http://beta.veekun.com/dex/moves/{link_name}"""
             self._reply(irc, reply_template.format(
                 name=obj.name,
                 type=obj.type.name,
@@ -136,25 +141,29 @@ class Pokedex(callbacks.Plugin):
                 accuracy=obj.accuracy,
                 pp=obj.pp,
                 effect=unicode(obj.short_effect.as_html),
+                link_name=urllib.quote(obj.name.lower()),
                 )
             )
 
         elif isinstance(obj, tables.Type):
-            self._reply(irc, u"""{name}, a type.""".format(
+            self._reply(irc, u"""{name}, a type.  http://beta.veekun.com/dex/types/{link_name}""".format(
                 name=obj.name,
+                link_name=urllib.quote(obj.name.lower()),
                 )
             )
 
         elif isinstance(obj, tables.Item):
-            self._reply(irc, u"""{name}, an item.""".format(
+            self._reply(irc, u"""{name}, an item.  http://beta.veekun.com/dex/items/{link_name}""".format(
                 name=obj.name,
+                link_name=urllib.quote(obj.name.lower()),
                 )
             )
 
         elif isinstance(obj, tables.Ability):
-            self._reply(irc, u"""{name}, an ability.  {effect}""".format(
+            self._reply(irc, u"""{name}, an ability.  {effect}  http://beta.veekun.com/dex/abilities/{link_name}""".format(
                 name=obj.name,
                 effect=obj.effect,
+                link_name=urllib.quote(obj.name.lower()),
                 )
             )