Skip to content

Commit

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


def cocoapods(q):
url = "http://search.cocoapods.org/api/pods?query={0}".format(q)
rawText = requests.get(url).text
data = json.loads(rawText)

docs = data.get("allocations")[0][5]
result = '```'

for x in docs:
result +='\'' + x + '\'\n'

result += '```'
return result


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

return cocoapods(match[0])

0 comments on commit 5aa60ef

Please sign in to comment.