Conditions | 2 |
Total Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | import urllib2 |
||
17 | def handle(self, event): |
||
18 | try: |
||
19 | url = "https://icanhazdadjoke.com/" |
||
20 | req = urllib2.Request(url, headers={'Accept' : "application/json", 'User-Agent' : "Magic Browser"}) |
||
21 | resp = urllib2.urlopen(req) |
||
22 | j = json.loads(resp.read()) |
||
23 | self.say(event.channel, j['joke']) |
||
24 | except: |
||
25 | pass |
||
26 |