Skip to content

Commit

Permalink
Add gradle search command for mavencentral
Browse files Browse the repository at this point in the history
  • Loading branch information
richardradics committed Feb 27, 2017
1 parent b2459c1 commit 37fa3e8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions limbo/plugins/gradleplease.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""!gradle <parameter> returns search results from mavencentral in gradle format"""
import re
import requests
import json


def gradleplease(q):
url = "http://gradleplease.appspot.com/search?q={0}".format(q)
rawText = requests.get(url).text
data = str(rawText[15:-1])
asd = json.loads(data)
docs = asd.get("response").get("docs")

result = '```'

for x in docs:
result +='compile \'' + x.get("id") + ':' + x.get("latestVersion") + '\'\n'

result += '```'
return result


def on_message(msg, server):
text = msg.get("text", "")
match = re.findall(r"!gradle (.*)", text)
if not match:
return

return gradleplease(match[0])

0 comments on commit 37fa3e8

Please sign in to comment.