Skip to content

Commit

Permalink
Add cocoapod search command for cocoapod.com
Browse files Browse the repository at this point in the history
  • Loading branch information
richardradics committed Feb 27, 2017
1 parent b2459c1 commit e69ddea
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"""
import re
import requests
import json


def google(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 google(match[0])

0 comments on commit e69ddea

Please sign in to comment.