Merge branch 'asdofindia-google' into develop
This commit is contained in:
commit
bc1a9dc9e2
@ -7,7 +7,7 @@ Multimedia
|
|||||||
----------
|
----------
|
||||||
- When user sends image (png, jpg, jpeg) URL download and send it to origin.
|
- When user sends image (png, jpg, jpeg) URL download and send it to origin.
|
||||||
- When user sends media (gif, mp4, pdf, etc.) URL download and send it to origin.
|
- When user sends media (gif, mp4, pdf, etc.) URL download and send it to origin.
|
||||||
- When user sends twitter URL, send text and images to origin. Requieres OAuth Key.
|
- When user sends twitter URL, send text and images to origin. Requires OAuth Key.
|
||||||
- When user sends youtube URL, send to origin video image.
|
- When user sends youtube URL, send to origin video image.
|
||||||
|
|
||||||
![http://i.imgur.com/0FGUvU0.png](http://i.imgur.com/0FGUvU0.png) ![http://i.imgur.com/zW7WWWt.png](http://i.imgur.com/zW7WWWt.png) ![http://i.imgur.com/zW7WWWt.png](http://i.imgur.com/kPK7paz.png)
|
![http://i.imgur.com/0FGUvU0.png](http://i.imgur.com/0FGUvU0.png) ![http://i.imgur.com/zW7WWWt.png](http://i.imgur.com/zW7WWWt.png) ![http://i.imgur.com/zW7WWWt.png](http://i.imgur.com/kPK7paz.png)
|
||||||
@ -60,13 +60,6 @@ $ sudo cp etc/telegram.conf /etc/init/
|
|||||||
$ ./launch.sh # Will ask you for a phone number & confirmation code.
|
$ ./launch.sh # Will ask you for a phone number & confirmation code.
|
||||||
```
|
```
|
||||||
|
|
||||||
TODO
|
|
||||||
------------
|
|
||||||
- [ ] Enable / Disable plugins
|
|
||||||
- [ ] Cron
|
|
||||||
- [ ] Regex
|
|
||||||
- [ ] Moar plugins
|
|
||||||
|
|
||||||
Contact me
|
Contact me
|
||||||
------------
|
------------
|
||||||
You can contact me [via Telegram](https://telegram.me/yago_perez) but if you have an issue please [open](https://github.com/yagop/telegram-bot/issues) one.
|
You can contact me [via Telegram](https://telegram.me/yago_perez) but if you have an issue please [open](https://github.com/yagop/telegram-bot/issues) one.
|
||||||
|
38
plugins/google.lua
Normal file
38
plugins/google.lua
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
function googlethat(query)
|
||||||
|
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
|
||||||
|
local parameters = "q=".. (URL.escape(query) or "")
|
||||||
|
|
||||||
|
-- Do the request
|
||||||
|
local res, code = https.request(api..parameters)
|
||||||
|
if code ~=200 then return nil end
|
||||||
|
local data = json:decode(res)
|
||||||
|
local results={}
|
||||||
|
for key,result in ipairs(data.responseData.results) do
|
||||||
|
table.insert(results,{result.titleNoFormatting, result.url})
|
||||||
|
end
|
||||||
|
return results
|
||||||
|
end
|
||||||
|
|
||||||
|
function stringlinks(results)
|
||||||
|
local stringresults=""
|
||||||
|
for key,val in ipairs(results) do
|
||||||
|
stringresults=stringresults..val[1].." - "..val[2].."\n"
|
||||||
|
end
|
||||||
|
return stringresults
|
||||||
|
end
|
||||||
|
|
||||||
|
function run(msg, matches)
|
||||||
|
vardump(matches)
|
||||||
|
local results = googlethat(matches[1])
|
||||||
|
return stringlinks(results)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
description = "Searches Google",
|
||||||
|
usage = "!google terms",
|
||||||
|
patterns = {
|
||||||
|
"^!google (.*)$",
|
||||||
|
"^%.[g|G]oogle (.*)$"
|
||||||
|
},
|
||||||
|
run = run
|
||||||
|
}
|
Reference in New Issue
Block a user