diff --git a/README.md b/README.md index 9948eaee..80719401 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ telegram-bot ============ -[![Join the chat at https://gitter.im/yagop/telegram-bot](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/yagop/telegram-bot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -[![](https://travis-ci.org/yagop/telegram-bot.svg?branch=master)](https://travis-ci.org/yagop/telegram-bot) -[![Donate button](https://img.shields.io/badge/nepal-donate-yellow.svg)](http://www.nrcs.org/donate-nrcs "Donate to Nepal Red Cross Society") +[![https://yago.me/tg-bot](https://img.shields.io/badge/💬_Telegram-Bot_Dev._Group-blue.svg)](https://yago.me/tg-bot) [![https://telegram.me/Yago_Perez](https://img.shields.io/badge/💬_Telegram-Yago__Perez-blue.svg)](https://telegram.me/Yago_Perez) [![https://gitter.im/yagop/telegram-bot](https://img.shields.io/badge/💬_Gitter-Join_Chat-green.svg)](https://gitter.im/yagop/telegram-bot) +[![Donate button](https://img.shields.io/badge/Red_Cross-donate-yellow.svg)](https://www.icrc.org/ "Donate to Red Cross Society") A Telegram Bot based on plugins using [tg](https://github.com/vysheng/tg). @@ -362,4 +360,4 @@ 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. -[Join](https://telegram.me/joinchat/ALJ3iwFAhOCh4WNUHAyzXQ) on the TelegramBot Discussion Group. +[Join](https://telegram.me/joinchat/ALJ3izwBCNXSswCHOKMwGw) on the TelegramBot Discussion Group. diff --git a/launch.sh b/launch.sh index 8b98ff69..530d88d6 100755 --- a/launch.sh +++ b/launch.sh @@ -33,6 +33,16 @@ install_luarocks() { } install_rocks() { + ./.luarocks/bin/luarocks install luasec + RET=$?; if [ $RET -ne 0 ]; + then echo "Error. Exiting."; exit $RET; + fi + + ./.luarocks/bin/luarocks install lbase64 20120807-3 + RET=$?; if [ $RET -ne 0 ]; + then echo "Error. Exiting."; exit $RET; + fi + ./.luarocks/bin/luarocks install luasocket RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; diff --git a/plugins/imdb.lua b/plugins/imdb.lua index 57691c66..37f62569 100644 --- a/plugins/imdb.lua +++ b/plugins/imdb.lua @@ -16,7 +16,7 @@ local function imdb(movie) if r.Error then return r.Error end - r['Url'] = "http://omdb.com/title/" .. r.imdbID + r['Url'] = "http://imdb.com/title/" .. r.imdbID local t = "" for k, v in pairs(r) do t = t..k..": "..v.. "\n" diff --git a/plugins/torrent_search.lua b/plugins/torrent_search.lua index 74fe194b..6038390e 100644 --- a/plugins/torrent_search.lua +++ b/plugins/torrent_search.lua @@ -1,36 +1,21 @@ ---[[ NOT USED DUE TO SSL ERROR --- See https://getstrike.net/api/ -local function strike_search(query) - local strike_base = 'http://getstrike.net/api/v2/torrents/' - local url = strike_base..'search/?phrase='..URL.escape(query) - print(url) - local b,c = http.request(url) - print(b,c) - local search = json:decode(b) - vardump(search) - - if c ~= 200 then - return search.message - end - - vardump(search) - local results = search.results - local text = 'Results: '..results - local results = math.min(results, 3) - for i=1,results do - local torrent = search.torrents[i] - text = text..torrent.torrent_title - ..'\n'..'Seeds: '..torrent.seeds - ..' '..'Leeches: '..torrent.seeds - ..'\n'..torrent.magnet_uri..'\n\n' - end - return text -end]]-- +local https = require ('ssl.https') +local ltn12 = require ("ltn12") local function search_kickass(query) - local url = 'http://kat.cr/json.php?q='..URL.escape(query) - local b,c = http.request(url) - local data = json:decode(b) + local url = 'https://kat.cr/json.php?q='..URL.escape(query) + + local resp = {} + + local b,c = https.request + { + url = url, + protocol = "tlsv1", + sink = ltn12.sink.table(resp) + } + + resp = table.concat(resp) + + local data = json:decode(resp) local text = 'Results: '..data.total_results..'\n\n' local results = math.min(#data.list, 5) diff --git a/plugins/tts.lua b/plugins/tts.lua new file mode 100644 index 00000000..98b94610 --- /dev/null +++ b/plugins/tts.lua @@ -0,0 +1,19 @@ +do +local function run(msg, matches) + local url = "http://tts.baidu.com/text2audio?lan=en&ie=UTF-8&text="..matches[1] + local receiver = get_receiver(msg) + local file = download_to_file(url,'telegram-bot.ogg') + send_audio('channel#id'..msg.to.id, file, ok_cb , false) +end +return { + description = "text to sound", + usage = { + "!tts [text]" + }, + patterns = { + "^!tts (.+)$" + }, + run = run +} + +end