Skip to content
This repository has been archived by the owner on Oct 14, 2018. It is now read-only.

Patch 1 #382

Open
wants to merge 13 commits into
base: supergroups
Choose a base branch
from
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down Expand Up @@ -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.
10 changes: 10 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion plugins/imdb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
47 changes: 16 additions & 31 deletions plugins/torrent_search.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
19 changes: 19 additions & 0 deletions plugins/tts.lua
Original file line number Diff line number Diff line change
@@ -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