diff --git a/limbo/plugins/cocoapodplease.py b/limbo/plugins/cocoapodplease.py new file mode 100644 index 00000000..8ed25753 --- /dev/null +++ b/limbo/plugins/cocoapodplease.py @@ -0,0 +1,28 @@ +"""!cocoapod 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]) \ No newline at end of file