summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-10-15 23:17:57 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-10-15 23:17:57 +0200
commita125494316f52e8371645d14c92e274ab007868b (patch)
tree2616350d8068251cfd44909f64af65c41b51394c /modules
parent2da87e8611522e54415021b339b2c2631f054e6f (diff)
weather: Added location.
Diffstat (limited to 'modules')
-rw-r--r--modules/weather.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/weather.py b/modules/weather.py
index 9e44721..60dc183 100644
--- a/modules/weather.py
+++ b/modules/weather.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+#-*- coding: utf-8 -*-
info = {
'author': 'Atle H. Havsø',
@@ -16,6 +16,7 @@ server = "http://api.wolframalpha.com/v2/query?"
class Module:
def __init__(self, bot):
self.appid = config.get('module/weather', 'api_key')
+ self.location = config.get('module/weather', 'location')
self.irc = bot
self.irc.register_keyword('!weather', self)
@@ -32,7 +33,7 @@ class Module:
def search(self, input):
- query = server + "appid=" + self.appid + "&input=weather%20" + input + "&format=plaintext"
+ query = server + "appid=" + self.appid + "&input=weather%20" + input + "&format=plaintext&location=" + self.location
try:
result = urllib2.urlopen(query)
result = result.read()
@@ -44,7 +45,6 @@ class Module:
def parseXml(self, result):
root = xml.XML(result)
- #root = tree.getroot()
data = []
for pod in root:
for subpod in pod:
@@ -58,7 +58,7 @@ class Module:
if __name__ == '__main__':
import sys
- m = Module()
+ m = Module(None)
search = ' '.join(sys.argv[1:])
result = m.search(search)
print(result.encode("utf-8"))