cmd_idgames.py

changeset 65
20bd76353eb5
parent 64
384167adad2b
child 66
74d8ca04ff01
--- a/cmd_idgames.py	Wed Nov 05 01:38:08 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-from commandhandler import command_error
-import hgapi
-import urllib
-import urllib2
-import json
-
-ModuleData = {
-	'commands':
-	[
-		{
-			'name': 'idgames',
-			'description': 'Searches doomworld.com/idgames for wads',
-			'args': '<wad...>',
-			'level': 'normal',
-		},
-	]
-}
-
-g_idgamesSearchURL = 'http://www.doomworld.com/idgames/api/api.php?action=search&query=%s&type=title&sort=date&out=json'
-
-def cmd_idgames (bot, args, replyto, **rest):
-	try:
-		url = g_idgamesSearchURL % urllib.quote (args['wad'])
-		response = urllib2.urlopen (url).read()
-		data = json.loads (response)
-
-		if 'content' in data and 'file' in data['content']:
-			if type (data['content']['file']) is list:
-				files = data['content']['file']
-			else:
-				files = [data['content']['file']]
-
-			i = 0
-
-			for filedata in files:
-				if i >= 5:
-					break
-
-				bot.privmsg (replyto, '- %s: \'%s\' by \'%s\', rating: %s: %s' % \
-					(filedata['filename'], filedata['title'], filedata['author'], filedata['rating'], filedata['url']))
-
-				i += 1
-			#done
-			bot.privmsg (replyto, "(%d / %d results posted)" % (i, len(files)))
-		elif 'warning' in data and 'message' in data['warning']:
-			command_error (data['warning']['message'])
-		elif 'error' in data and 'message' in data['error']:
-			command_error (data['error']['message'])
-		else:
-			command_error ("Incomplete JSON response from doomworld.com/idgames")
-	except Exception as e:
-		command_error ('search failed: %s' % str (e))
-	#tried
-#enddef
\ No newline at end of file

mercurial