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

mer #370

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

mer #370

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fca76e0
boobs plg updated
AckiyBolt Mar 26, 2015
b1d2ef2
some slave plg added
AckiyBolt Mar 26, 2015
8205d6d
whoami plg added
AckiyBolt Mar 27, 2015
c7fec4b
small changes
AckiyBolt Mar 27, 2015
a4b26fd
small updates
AckiyBolt Mar 28, 2015
65c7515
magic ball plg added
AckiyBolt Mar 29, 2015
6c9cc5c
plg updates
AckiyBolt Mar 29, 2015
adee106
plg updates
AckiyBolt Mar 30, 2015
63a1e49
fap plg created
AckiyBolt Apr 6, 2015
aac7129
small plg updates
AckiyBolt Apr 6, 2015
b15833f
gitignore updated
AckiyBolt Apr 6, 2015
aa422b2
Merge remote-tracking branch 'upstream/master'
AckiyBolt Apr 6, 2015
35607c5
plg fixes
AckiyBolt Apr 9, 2015
8144602
curr plg added
AckiyBolt Apr 15, 2015
38c681b
plg changes
AckiyBolt Apr 15, 2015
aa10157
imdb plg fix
AckiyBolt Apr 15, 2015
dc8aa69
weather prints wind, default loc is Kyiv
AckiyBolt Apr 16, 2015
0bf7071
danbooru plg added
AckiyBolt Apr 16, 2015
48423fe
gps update
AckiyBolt Apr 18, 2015
15e6d86
Merge remote-tracking branch 'upstream/master'
AckiyBolt Apr 18, 2015
e12fbff
weather plg upd
AckiyBolt Apr 18, 2015
1ae085a
weather plg upd
AckiyBolt Apr 18, 2015
1d5e76e
Merge commit 'b85de2d346bb53a766b07e05f65beca314fb0f9d'
AckiyBolt May 16, 2015
7141f04
Merge remote-tracking branch 'upstream/master'
AckiyBolt May 16, 2015
b5039cd
plg fix
May 18, 2015
f40fb42
Merge branch 'yagop'
AckiyBolt Aug 18, 2015
b7b036f
weather rollback
AckiyBolt Aug 18, 2015
60557e4
dan fix
AckiyBolt Aug 18, 2015
909686b
Merge remote-tracking branch 'yagop/master'
AckiyBolt Aug 27, 2015
d391c3c
Merge branch 'master-upstream'
AckiyBolt Jan 11, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
res/
data/
bot/config.lua
/telegram-bot.sublime-workspace
*.sublime-project
.luarocks
46 changes: 23 additions & 23 deletions bot/bot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,29 +205,29 @@ function create_config( )
-- A simple config with basic plugins and ourselves as privileged user
config = {
enabled_plugins = {
"9gag",
"eur",
"echo",
"btc",
"get",
"giphy",
"google",
"gps",
"help",
"id",
"images",
"img_google",
"location",
"media",
"plugins",
"channels",
"set",
"stats",
"time",
"version",
"weather",
"xkcd",
"youtube" },
"plugins",
"9gag",
"boobs",
"echo",
"giphy",
"google",
"gps",
"help",
"images",
"img_google",
"location",
"media",
"stats",
"weather",
"xkcd",
"vote",
"whoami",
"ball",
"youtube",
"slave",
"slave_agr",
"pornhub",
"hackernews" },
sudo_users = {our_id},
disabled_channels = {}
}
Expand Down
42 changes: 42 additions & 0 deletions plugins/ball.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

function run(msg, matches)

local answers = {
"Ато",
"Предрешено",
"Хрест на пузе, так и будет",
"Определенно да!",
"Считай что это уже случилось ;)",

"Мне кажется - да",
"Мб",
"У тебя хорошие перспективы",
"Звезды говорят - да",
"Походу да",

"Будущее туманно...",
"Ахз",
"Лучше не рассказывать...",
"Звезды пока молчат...",
"Сконцентрируйся получше и переспроси",

"Не в этой жизни",
"Nope",
"Мои соболезнования...",
"Перспективы фиговые",
"Весьма сомнительно :\\"
}

math.randomseed( os.time() )
print(math.random(#answers))
print(math.random(#answers))

return string.format(">%s: %s \n%s", get_name(msg), matches[1], answers[math.random(#answers)])
end

return {
description = "Гадалко. Спроси у шарика вопрос предпологающий ответ да/нет.",
usage = "!ball <вопрос> - Задай шарику вопрос, предпологающий ответ да/нет",
patterns = {"^!ball (.*)$"},
run = run
}
26 changes: 26 additions & 0 deletions plugins/curr.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function run(msg, matches)

local file = '/home/curr-bot/print'
fh = io.open(file, "r")

local content = ''

while true do
local line = fh.read(fh)
if not line then break end
content = content .. line .. "\n"
end

io.close(fh)

return content
end

return {
description = "Prints current UAH currencies.",
usage = "!curr: prints current UAH currencies.",
patterns = {
"^!curr$"
},
run = run
}
67 changes: 67 additions & 0 deletions plugins/dan.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
do
local URL = "http://danbooru.donmai.us"
local URL_NEW = "/posts.json"
local URL_POP = "/explore/posts/popular.json"

local scale_day = "?scale=day"
local scale_week = "?scale=week"
local scale_month = "?scale=month"

function get_post(url)
local b, c, h = http.request(url)
local posts = json:decode(b)

-- bad random - bad magic...
math.randomseed( os.time() )
math.random(#posts)
math.random(#posts)

return posts[math.random(#posts)]
end

function run(msg, matches)

local url = URL

if matches[1] == "!dan" then
url = url .. URL_NEW
else
url = url .. URL_POP

if matches[1] == "!dand" then
url = url .. scale_day
elseif matches[1] == "!danw" then
url = url .. scale_week
elseif matches[1] == "!danm" then
url = url .. scale_month
end
end

local post = get_post(url)

-- local receiver = get_receiver(msg)
-- local img = URL .. post.large_file_url
-- send_photo_from_url(receiver, img)

local txt = 'Artist: ' .. post.tag_string_artist .. '\n'
txt = txt .. 'Character: ' .. post.tag_string_character .. '\n'
txt = txt .. '[' .. math.ceil(post.file_size/1000) .. 'kb] ' .. URL .. post.file_url
return txt
end

return {
description = "Get random fresh or popular image from Danbooru",
usage = {
"!dan - get random fresh image from Danbooru",
"!dand - random daily popular image",
"!danw - random weekly popular image",
"!danm - random monthly popular image"},
patterns = {
"^!dan$",
"^!dand$",
"^!danw$",
"^!danm$"},
run = run
}

end
29 changes: 15 additions & 14 deletions plugins/echo.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@

local function run(msg, matches)
local text = matches[1]
local b = 1
function run(msg, matches)

while b ~= 0 do
text = text:trim()
text,b = text:gsub('^!+','')
end
return text
local count = tonumber(matches[1])
local result = ""

while (count > 0 ) do
result = result .. matches[2] .. "\n"
count = count - 1
print (result)
end

return result
end

return {
description = "Simplest plugin ever!",
usage = "!echo [whatever]: echoes the msg",
patterns = {
"^!echo +(.+)$"
},
run = run
description = "Simplest plugin ever!",
usage = "!echo [count] [whatever]: echoes the msg N times",
patterns = {"^!echo (%d) (.*)$"},
run = run
}
2 changes: 1 addition & 1 deletion plugins/google.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
local function stringlinks(results)
local stringresults=""
for key,val in ipairs(results) do
stringresults=stringresults..val[1].." - "..val[2].."\n"
stringresults=stringresults..val[1].."\n"..val[2].."\n"
end
return stringresults
end
Expand Down
8 changes: 4 additions & 4 deletions plugins/gps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function run(msg, matches)
local lon = matches[2]
local receiver = get_receiver(msg)

local zooms = {16, 18}
local zooms = {15}
local urls = {}
for i = 1, #zooms do
local zoom = zooms[i]
Expand All @@ -15,12 +15,12 @@ function run(msg, matches)

send_photos_from_url(receiver, urls)

return "www.google.es/maps/place/@" .. lat .. "," .. lon
return "www.google.com/maps/place/@" .. lat .. "," .. lon .. ",17z"
end

return {
description = "generates a map showing the given GPS coordinates",
usage = "!gps latitude,longitude: generates a map showing the given GPS coordinates",
description = "generates a map showing the given GPS coordinates",
usage = "!gps latitude,longitude: generates a map showing the given GPS coordinates (example: !gps 50.449859,30.524089)",
patterns = {"^!gps ([^,]*)[,%s]([^,]*)$"},
run = run
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/images.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ return {
description = "When user sends image URL (ends with png, jpg, jpeg) download and send it to origin.",
usage = "",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+%.png)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.jpg)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.jpeg)$",
".*(https?://[%w-_%.%?%.:/%+=&]+%.png).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.jpg).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.jpeg).*",
},
run = run
}
Expand Down
14 changes: 10 additions & 4 deletions plugins/imdb.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
do

local function imdb(movie)
function imdb(msg, movie)
local http = require("socket.http")
local movie = movie:gsub(' ', '+')
local url = "http://www.omdbapi.com/?t=" .. movie
Expand All @@ -19,15 +19,21 @@ local function imdb(movie)
r['Url'] = "http://omdb.com/title/" .. r.imdbID
local t = ""
for k, v in pairs(r) do
t = t..k..": "..v.. "\n"
if not string.match(k, 'Poster') then
t = t .. k .. ": " .. v .. ".\n"
end
end
return t

local receiver = get_receiver(msg)
send_photo_from_url(receiver, r['Poster'])

return t:sub(1, -3)
end
return nil
end

local function run(msg, matches)
return imdb(matches[1])
return imdb(msg, matches[1])
end

return {
Expand Down
22 changes: 11 additions & 11 deletions plugins/media.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ return {
description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
usage = "",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+%.(gif))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp4))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(pdf))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(ogg))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(zip))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp3))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(rar))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(wmv))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(doc))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(avi))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(webp))$"
".*(https?://[%w-_%.%?%.:/%+=&]+%.gif).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.mp4).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.pdf).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.ogg).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.zip).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.mp3).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.rar).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.wmv).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.doc).*",
".*(https?://[%w-_%.%?%.:/%+=&]+%.avi).*"
".*(https?://[%w-_%.%?%.:/%+=&]+%.(webp)).*"
},
run = run
}
Expand Down
39 changes: 39 additions & 0 deletions plugins/pornhub.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function run(msg, matches)
local results = findPorn(matches[1])
return results-- build_result(results)
end

function findPorn(query)
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:pornhub.com+viewkey+" .. query:gsub(" ", "+")

-- Do the request
local res, code = https.request(api)

if code ~=200 then return nil end
local data = json:decode(res)
local results = data.responseData.results

math.randomseed( os.time() )
math.random(#results)
math.random(#results)
local index = math.random(#results)

local result = results[index].titleNoFormatting .. "\n".. results[index].unescapedUrl .."\n"

return result
end

function build_result(query)
local stringresults=""
for key,val in ipairs(results) do
stringresults=stringresults..val[1].."\n"..val[2].."\n\n"
end
return stringresults
end

return {
description = "It's time to fap :)",
usage = "!fap [on something]",
patterns = {"^!fap (.*)$"},
run = run
}
Loading