From fca76e00309049fb75ab4db5b982fccdabb6a982 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Fri, 27 Mar 2015 01:45:14 +0200 Subject: [PATCH 01/23] boobs plg updated --- plugins/boobs.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/boobs.lua b/plugins/boobs.lua index ba4edab7..a94b9908 100644 --- a/plugins/boobs.lua +++ b/plugins/boobs.lua @@ -1,5 +1,10 @@ do +local titRuPattern1 = "^Раб.*сис.*" +local titRuPattern2 = "^раб.*сис.*" +local butRuPattern1 = "^Раб.*поп.*" +local butRuPattern2 = "^раб.*поп.*" + function getRandomButts(attempt) attempt = attempt or 0 attempt = attempt + 1 @@ -39,11 +44,11 @@ end function run(msg, matches) local url = nil - if matches[1] == "!boobs" then + if matches[1] == "!boobs" or (string.match(matches[1], titRuPattern1) and is_sudo(msg)) or (string.match(matches[1], titRuPattern2) and is_sudo(msg)) then url = getRandomBoobs() end - if matches[1] == "!butts" then + if matches[1] == "!butts" or (string.match(matches[1], butRuPattern1) and is_sudo(msg)) or (string.match(matches[1], butRuPattern2) and is_sudo(msg)) then url = getRandomButts() end @@ -63,7 +68,11 @@ return { }, patterns = { "^!boobs$", - "^!butts$" + "^!butts$", + titRuPattern1, + titRuPattern2, + butRuPattern1, + butRuPattern2 }, run = run } From b1d2ef258891054440085ba4835820c602d008c3 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Fri, 27 Mar 2015 01:45:30 +0200 Subject: [PATCH 02/23] some slave plg added --- plugins/slave.lua | 33 +++++++++++++++++++++++++++++++++ plugins/slave_agr.lua | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 plugins/slave.lua create mode 100644 plugins/slave_agr.lua diff --git a/plugins/slave.lua b/plugins/slave.lua new file mode 100644 index 00000000..e66975ff --- /dev/null +++ b/plugins/slave.lua @@ -0,0 +1,33 @@ +require("./bot/utils") + +do + +function run(msg, matches) + local url = nil + + if is_sudo(msg) then + return 'Только не по ебалу, хозяин...' + end +end + +return { + description = "", + usage = { + }, + patterns = { + "^Раб.*завали.*", + "^раб.*завали.*", + + "^Раб.*ахуел.*", + "^раб.*ахуел.*", + + "^Раб.*мудила.*", + "^раб.*мудила.*", + + "^Раб.*уебок.*", + "^раб.*уебок.*", + }, + run = run +} + +end diff --git a/plugins/slave_agr.lua b/plugins/slave_agr.lua new file mode 100644 index 00000000..d0ade49a --- /dev/null +++ b/plugins/slave_agr.lua @@ -0,0 +1,36 @@ +require("./bot/utils") + +do + +function run(msg, matches) + local url = nil + + if is_sudo(msg) then + return "@vatobot больно пиздит" .. matches[1] .. " дрючком." + end +end + +return { + description = "", + usage = { + }, + patterns = { + "^Раб.*пиздани.*( .*)$", + "^раб.*пиздани.*( .*)$", + + "^Раб.*хуяни.*( .*)$", + "^раб.*хуяни.*( .*)$", + + "^Раб.*побей.*( .*)$", + "^раб.*побей.*( .*)$", + + "^Раб.*карай.*( .*)$", + "^раб.*карай.*( .*)$", + + "^Раб.*накажи.*( .*)$", + "^раб.*накажи.*( .*)$" + }, + run = run +} + +end From 8205d6de75fdf95d3efdc91da4a76e44fce8a8ce Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Fri, 27 Mar 2015 02:01:39 +0200 Subject: [PATCH 03/23] whoami plg added --- plugins/whoami.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 plugins/whoami.lua diff --git a/plugins/whoami.lua b/plugins/whoami.lua new file mode 100644 index 00000000..d8b97a72 --- /dev/null +++ b/plugins/whoami.lua @@ -0,0 +1,15 @@ + +function run(msg, matches) + + if is_sudo(msg) then + return get_receiver(msg) + end +end + +return { + description = "Returns sender's id", + usage = "!whoami", + patterns = {"^!whoami$"}, + run = run +} + From c7fec4b81e4b60880096e42b3179d744fa1c29e2 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Fri, 27 Mar 2015 11:49:45 +0200 Subject: [PATCH 04/23] small changes --- plugins/slave.lua | 4 ++++ plugins/whoami.lua | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/slave.lua b/plugins/slave.lua index e66975ff..0a12d9f6 100644 --- a/plugins/slave.lua +++ b/plugins/slave.lua @@ -15,6 +15,9 @@ return { usage = { }, patterns = { + "^Раб.*хуёвый.*", + "^раб.*хуёвый.*", + "^Раб.*завали.*", "^раб.*завали.*", @@ -26,6 +29,7 @@ return { "^Раб.*уебок.*", "^раб.*уебок.*", + "^[Рр]аб$" }, run = run } diff --git a/plugins/whoami.lua b/plugins/whoami.lua index d8b97a72..020644af 100644 --- a/plugins/whoami.lua +++ b/plugins/whoami.lua @@ -12,4 +12,3 @@ return { patterns = {"^!whoami$"}, run = run } - From a4b26fd687cdca969894a21cb45041c585e2a38f Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Sat, 28 Mar 2015 22:44:25 +0200 Subject: [PATCH 05/23] small updates --- plugins/whoami.lua | 4 +--- plugins/youtube.lua | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/whoami.lua b/plugins/whoami.lua index 020644af..1f7cc538 100644 --- a/plugins/whoami.lua +++ b/plugins/whoami.lua @@ -1,9 +1,7 @@ function run(msg, matches) - if is_sudo(msg) then - return get_receiver(msg) - end + return get_receiver(msg) end return { diff --git a/plugins/youtube.lua b/plugins/youtube.lua index 3c565136..06b58a24 100644 --- a/plugins/youtube.lua +++ b/plugins/youtube.lua @@ -14,10 +14,10 @@ function send_youtube_data(data, receiver) local title = data.title local description = data.description local uploader = data.uploader - local text = title..' ('..uploader..')\n'..description + local text = title..' (by '..uploader..')\n' local image_url = data.thumbnail.hqDefault local cb_extra = {receiver=receiver, url=image_url} - send_msg(receiver, text, send_photo_from_url_callback, cb_extra) + send_msg(receiver, text, nil, cb_extra) end function run(msg, matches) From 65c7515dd7dded8e4ebb35fd3ceb0b4b97db004b Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Sun, 29 Mar 2015 16:39:58 +0300 Subject: [PATCH 06/23] magic ball plg added --- plugins/magic_ball.lua | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 plugins/magic_ball.lua diff --git a/plugins/magic_ball.lua b/plugins/magic_ball.lua new file mode 100644 index 00000000..f334cd67 --- /dev/null +++ b/plugins/magic_ball.lua @@ -0,0 +1,38 @@ + +function run(msg, matches) + + local answers = { + "Ато", + "Предрешено", + "Хрест на пузе, так и будет", + "Определенно да!", + "Считай что это уже случилось ;)", + + "Мне кажется - да", + "Мб", + "У тебя хорошие перспективы", + "Звезды говорят - да", + "Походу да", + + "Будущее туманно...", + "Ахз", + "Лучше не рассказывать...", + "Звезды пока молчат...", + "Сконцентрируйся получше и переспроси", + + "Не в этой жизни", + "Nope", + "Звезды говорят - нет", + "Перспективы фиговые", + "Весьма сомнительно :\\" + } + + return string.format(">%s: %s \n%s", get_name(msg), matches[1], answers[math.random(0, #answers)]) +end + +return { + description = "Гадалко. Спроси у шарика вопрос предпологающий ответ да/нет.", + usage = "!ball <вопрос> - Задай шарику вопрос, предпологающий ответ да/нет", + patterns = {"^!ball (.*)$"}, + run = run +} From 6c9cc5c247139bf91301a356cce74751fa485192 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Sun, 29 Mar 2015 19:57:20 +0300 Subject: [PATCH 07/23] plg updates --- plugins/echo.lua | 16 +++++++++++++--- plugins/magic_ball.lua | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/echo.lua b/plugins/echo.lua index 58f77b3d..e9cabf9c 100644 --- a/plugins/echo.lua +++ b/plugins/echo.lua @@ -1,12 +1,22 @@ function run(msg, matches) - return matches[1] + + 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 (.*)$"}, + usage = "!echo [count] [whatever]: echoes the msg N times", + patterns = {"^!echo (%d) (.*)$"}, run = run } diff --git a/plugins/magic_ball.lua b/plugins/magic_ball.lua index f334cd67..8af56b3a 100644 --- a/plugins/magic_ball.lua +++ b/plugins/magic_ball.lua @@ -22,7 +22,7 @@ function run(msg, matches) "Не в этой жизни", "Nope", - "Звезды говорят - нет", + "Мои соболезнования...", "Перспективы фиговые", "Весьма сомнительно :\\" } From adee1063c378cdc4c6eaabd46c86687cda6f860d Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Mon, 30 Mar 2015 20:05:43 +0300 Subject: [PATCH 08/23] plg updates --- plugins/magic_ball.lua | 2 +- plugins/youtube.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/magic_ball.lua b/plugins/magic_ball.lua index 8af56b3a..ca2624a1 100644 --- a/plugins/magic_ball.lua +++ b/plugins/magic_ball.lua @@ -27,7 +27,7 @@ function run(msg, matches) "Весьма сомнительно :\\" } - return string.format(">%s: %s \n%s", get_name(msg), matches[1], answers[math.random(0, #answers)]) + return string.format(">%s: %s \n%s", get_name(msg), matches[1], answers[math.random(1, #answers)]) end return { diff --git a/plugins/youtube.lua b/plugins/youtube.lua index 06b58a24..b56e17d7 100644 --- a/plugins/youtube.lua +++ b/plugins/youtube.lua @@ -14,7 +14,7 @@ function send_youtube_data(data, receiver) local title = data.title local description = data.description local uploader = data.uploader - local text = title..' (by '..uploader..')\n' + local text = title..'\n(by '..uploader..')' local image_url = data.thumbnail.hqDefault local cb_extra = {receiver=receiver, url=image_url} send_msg(receiver, text, nil, cb_extra) From 63a1e49560b4bcec36128bd54a032cac0337f0ab Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Tue, 7 Apr 2015 02:26:39 +0300 Subject: [PATCH 09/23] fap plg created --- plugins/pornhub.lua | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 plugins/pornhub.lua diff --git a/plugins/pornhub.lua b/plugins/pornhub.lua new file mode 100644 index 00000000..8b7f6a1a --- /dev/null +++ b/plugins/pornhub.lua @@ -0,0 +1,47 @@ +function run(msg, matches) + + -- local g = require "./plugins/google" + -- local query = "site:pornhub.com+viewkey+" .. matches[1] + -- local new_matches = {query} + + -- return g.run(msg, new_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 +} From aac71299441e898c50432ef81000fec8ba825633 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Tue, 7 Apr 2015 02:27:20 +0300 Subject: [PATCH 10/23] small plg updates --- plugins/google.lua | 2 +- plugins/magic_ball.lua | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/google.lua b/plugins/google.lua index 5e3434b6..6e7c8493 100644 --- a/plugins/google.lua +++ b/plugins/google.lua @@ -16,7 +16,7 @@ end 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 diff --git a/plugins/magic_ball.lua b/plugins/magic_ball.lua index ca2624a1..c7da5ea0 100644 --- a/plugins/magic_ball.lua +++ b/plugins/magic_ball.lua @@ -27,7 +27,11 @@ function run(msg, matches) "Весьма сомнительно :\\" } - return string.format(">%s: %s \n%s", get_name(msg), matches[1], answers[math.random(1, #answers)]) + 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 { From b15833f856ef0f3a0d2822f564dc5604dc6063dc Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Tue, 7 Apr 2015 02:49:10 +0300 Subject: [PATCH 11/23] gitignore updated --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e150a821..b02633bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ res/ data/ -bot/config.lua \ No newline at end of file +bot/config.lua +/telegram-bot.sublime-workspace +*.sublime-project From 35607c5ddbbbe74b2dc7e86ab43361835d94d153 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Fri, 10 Apr 2015 01:23:34 +0300 Subject: [PATCH 12/23] plg fixes --- plugins/imdb.lua | 2 +- plugins/slave.lua | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/imdb.lua b/plugins/imdb.lua index 8de189ed..1ae0b332 100644 --- a/plugins/imdb.lua +++ b/plugins/imdb.lua @@ -16,7 +16,7 @@ function imdb(movie) local r = json:decode(response) r['Url'] = "http://imdb.com/title/" .. r.imdbID local t = "" - for k, v in pairs(r) do t = t .. k .. ": " .. v .. ", " end + for k, v in pairs(r) do t = t .. k .. ": " .. v .. ".\n" end return t:sub(1, -3) end return nil diff --git a/plugins/slave.lua b/plugins/slave.lua index 0a12d9f6..9a7ab21e 100644 --- a/plugins/slave.lua +++ b/plugins/slave.lua @@ -28,8 +28,7 @@ return { "^раб.*мудила.*", "^Раб.*уебок.*", - "^раб.*уебок.*", - "^[Рр]аб$" + "^раб.*уебок.*" }, run = run } From 814460244c9cdf76ee8be7f9e189492a8cf5c049 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Wed, 15 Apr 2015 23:32:10 +0300 Subject: [PATCH 13/23] curr plg added --- plugins/curr.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 plugins/curr.lua diff --git a/plugins/curr.lua b/plugins/curr.lua new file mode 100644 index 00000000..93bc0461 --- /dev/null +++ b/plugins/curr.lua @@ -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 +} From 38c681bba8ce5f6015453d44d24cedf7054467f6 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Thu, 16 Apr 2015 00:31:28 +0300 Subject: [PATCH 14/23] plg changes --- bot/bot.lua | 44 +++++++++++++++------------- plugins/{magic_ball.lua => ball.lua} | 0 plugins/gps.lua | 6 ++-- plugins/images.lua | 6 ++-- plugins/media.lua | 20 ++++++------- plugins/pornhub.lua | 10 +------ plugins/stats.lua | 16 ++++++---- plugins/whoami.lua | 3 +- 8 files changed, 51 insertions(+), 54 deletions(-) rename plugins/{magic_ball.lua => ball.lua} (100%) diff --git a/bot/bot.lua b/bot/bot.lua index 719c3911..138bb3f4 100644 --- a/bot/bot.lua +++ b/bot/bot.lua @@ -161,27 +161,29 @@ function create_config( ) -- A simple config with basic plugins and ourserves as priviled user config = { enabled_plugins = { - "9gag", - "eur", - "echo", - "btc", - "get", - "giphy", - "google", - "gps", - "help", - "images", - "img_google", - "location", - "media", - "plugins", - "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} } serialize_to_file(config, './data/config.lua') diff --git a/plugins/magic_ball.lua b/plugins/ball.lua similarity index 100% rename from plugins/magic_ball.lua rename to plugins/ball.lua diff --git a/plugins/gps.lua b/plugins/gps.lua index 1cc43477..faf88b98 100644 --- a/plugins/gps.lua +++ b/plugins/gps.lua @@ -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] @@ -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", + usage = "!gps latitude,longitude: generates a map showing the given GPS coordinates (example: !gps 50.449859,30.524089)", patterns = {"^!gps ([^,]*)[,%s]([^,]*)$"}, run = run } diff --git a/plugins/images.lua b/plugins/images.lua index 1b89ee24..983950ba 100644 --- a/plugins/images.lua +++ b/plugins/images.lua @@ -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 } diff --git a/plugins/media.lua b/plugins/media.lua index 37070b69..c0e3b533 100644 --- a/plugins/media.lua +++ b/plugins/media.lua @@ -9,16 +9,16 @@ 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-_%.%?%.:/%+=&]+%.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).*" }, run = run } diff --git a/plugins/pornhub.lua b/plugins/pornhub.lua index 8b7f6a1a..08c74c1e 100644 --- a/plugins/pornhub.lua +++ b/plugins/pornhub.lua @@ -1,16 +1,10 @@ function run(msg, matches) - - -- local g = require "./plugins/google" - -- local query = "site:pornhub.com+viewkey+" .. matches[1] - -- local new_matches = {query} - - -- return g.run(msg, new_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(" ", "+") + 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) @@ -19,8 +13,6 @@ function findPorn(query) local data = json:decode(res) local results = data.responseData.results - - math.randomseed( os.time() ) math.random(#results) math.random(#results) diff --git a/plugins/stats.lua b/plugins/stats.lua index e6d36b63..8ed7b0c6 100644 --- a/plugins/stats.lua +++ b/plugins/stats.lua @@ -90,12 +90,16 @@ local function get_stats_status( msg ) end local function run(msg, matches) - if matches[1] == "stats" then -- Hack - return get_stats_status(msg) - else - print ("update stats") - update_user_stats(msg) - save_stats() + if string.match(get_receiver(msg), "chat.*") or is_sudo(msg) then + if matches[1] == "stats" then -- Hack + return get_stats_status(msg) + else + print ("update stats") + update_user_stats(msg) + save_stats() + end + else + return nil end end diff --git a/plugins/whoami.lua b/plugins/whoami.lua index 1f7cc538..1f043f23 100644 --- a/plugins/whoami.lua +++ b/plugins/whoami.lua @@ -1,11 +1,10 @@ - function run(msg, matches) return get_receiver(msg) end return { - description = "Returns sender's id", + description = "Returns sender's or chat's id", usage = "!whoami", patterns = {"^!whoami$"}, run = run From aa10157406be558189f6742eef99ff9a50db5ece Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Thu, 16 Apr 2015 00:53:02 +0300 Subject: [PATCH 15/23] imdb plg fix --- plugins/imdb.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/imdb.lua b/plugins/imdb.lua index 1ae0b332..47ddf4a2 100644 --- a/plugins/imdb.lua +++ b/plugins/imdb.lua @@ -1,8 +1,8 @@ do -function imdb(movie) +function imdb(msg, movie) local http = require("socket.http") - http.TIMEOUT = 5 + http.TIMEOUT = 7 local movie = movie:gsub(' ', '+') local url = "http://www.imdbapi.com/?t=" .. movie @@ -16,14 +16,22 @@ function imdb(movie) local r = json:decode(response) r['Url'] = "http://imdb.com/title/" .. r.imdbID local t = "" - for k, v in pairs(r) do t = t .. k .. ": " .. v .. ".\n" end + for k, v in pairs(r) do + if not string.match(k, 'Poster') then + t = t .. k .. ": " .. v .. ".\n" + end + end + + local receiver = get_receiver(msg) + send_photo_from_url(receiver, r['Poster']) + return t:sub(1, -3) end return nil end function run(msg, matches) - return imdb(matches[1]) + return imdb(msg, matches[1]) end return { From dc8aa698152b5b2de0bb595d2278f7098307931a Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Thu, 16 Apr 2015 22:22:01 +0300 Subject: [PATCH 16/23] weather prints wind, default loc is Kyiv --- plugins/weather.lua | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/plugins/weather.lua b/plugins/weather.lua index 50b526b1..03e3e9c4 100644 --- a/plugins/weather.lua +++ b/plugins/weather.lua @@ -23,22 +23,42 @@ function get_weather(location) conditions = conditions .. ' ☔☔☔☔' end - return temp .. '\n' .. conditions + wind = "Wind are " .. weather.wind.speed .. "mps" + + + if weather.wind.deg > 326.25 and weather.wind.deg <= 348.75 then wind = wind .. ' NNW' + elseif weather.wind.deg > 303.75 and weather.wind.deg <= 326.25 then wind = wind .. ' NW' + elseif weather.wind.deg > 281.25 and weather.wind.deg <= 303.75 then wind = wind .. ' WNW' + elseif weather.wind.deg > 258.75 and weather.wind.deg <= 281.25 then wind = wind .. ' W' + elseif weather.wind.deg > 236.25 and weather.wind.deg <= 258.75 then wind = wind .. ' WSW' + elseif weather.wind.deg > 213.75 and weather.wind.deg <= 236.25 then wind = wind .. ' SW' + elseif weather.wind.deg > 191.25 and weather.wind.deg <= 213.75 then wind = wind .. ' SSW' + elseif weather.wind.deg > 168.75 and weather.wind.deg <= 191.25 then wind = wind .. ' S' + elseif weather.wind.deg > 146.25 and weather.wind.deg <= 168.75 then wind = wind .. ' SSE' + elseif weather.wind.deg > 101.25 and weather.wind.deg <= 123.75 then wind = wind .. ' ESE' + elseif weather.wind.deg > 78.75 and weather.wind.deg <= 101.25 then wind = wind .. ' E' + elseif weather.wind.deg > 56.25 and weather.wind.deg <= 78.75 then wind = wind .. ' ENE' + elseif weather.wind.deg > 33.75 and weather.wind.deg <= 56.25 then wind = wind .. ' NE' + elseif weather.wind.deg > 11.25 and weather.wind.deg <= 33.75 then wind = wind .. ' NNE' + elseif weather.wind.deg > 348.75 and weather.wind.deg <= 11.25 then wind = wind .. ' N' + end + + return temp .. '\n' .. conditions .. '\n' .. wind end function run(msg, matches) if string.len(matches[1]) > 2 then city = matches[1] else - city = "Madrid,ES" + city = "Kyiv" end return get_weather(city) end return { - description = "weather in that city (Madrid is default)", + description = "weather in that city (Kyiv is default)", usage = "!weather (city)", - patterns = {"^!weather(.*)$"}, + patterns = {"^!weather%s?(.*)$"}, run = run } From 0bf7071e27c4c0e271e5491e055afca63cceb029 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Fri, 17 Apr 2015 00:45:16 +0300 Subject: [PATCH 17/23] danbooru plg added --- plugins/dan.lua | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 plugins/dan.lua diff --git a/plugins/dan.lua b/plugins/dan.lua new file mode 100644 index 00000000..03a4ed9f --- /dev/null +++ b/plugins/dan.lua @@ -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 \ No newline at end of file From 48423fe967df22e720b4460853557c30d290e6b0 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Sat, 18 Apr 2015 03:56:00 +0300 Subject: [PATCH 18/23] gps update --- plugins/gps.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gps.lua b/plugins/gps.lua index faf88b98..60bd19b4 100644 --- a/plugins/gps.lua +++ b/plugins/gps.lua @@ -19,7 +19,7 @@ function run(msg, matches) end return { - description = "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 From e12fbff193ef1b0b212adbb8a97bced440107869 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Sat, 18 Apr 2015 05:18:12 +0300 Subject: [PATCH 19/23] weather plg upd --- plugins/weather.lua | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/plugins/weather.lua b/plugins/weather.lua index 03e3e9c4..21e5a4f1 100644 --- a/plugins/weather.lua +++ b/plugins/weather.lua @@ -9,9 +9,9 @@ function get_weather(location) print("Weather returns", weather) local city = weather.name local country = weather.sys.country - local temp = 'The temperature in ' .. city .. ' (' .. country .. ')' - temp = temp .. ' is ' .. weather.main.temp .. '°C' - conditions = 'Current conditions are: ' .. weather.weather[1].description + local temp = city .. ' (' .. country .. ') ' + temp = temp .. 'Temp: ' .. weather.main.temp .. '°C' + local conditions = 'Conditions: ' .. weather.weather[1].description if weather.weather[1].main == 'Clear' then conditions = conditions .. ' ☀' @@ -23,26 +23,28 @@ function get_weather(location) conditions = conditions .. ' ☔☔☔☔' end - wind = "Wind are " .. weather.wind.speed .. "mps" + local wind = "Wind: " - if weather.wind.deg > 326.25 and weather.wind.deg <= 348.75 then wind = wind .. ' NNW' - elseif weather.wind.deg > 303.75 and weather.wind.deg <= 326.25 then wind = wind .. ' NW' - elseif weather.wind.deg > 281.25 and weather.wind.deg <= 303.75 then wind = wind .. ' WNW' - elseif weather.wind.deg > 258.75 and weather.wind.deg <= 281.25 then wind = wind .. ' W' - elseif weather.wind.deg > 236.25 and weather.wind.deg <= 258.75 then wind = wind .. ' WSW' - elseif weather.wind.deg > 213.75 and weather.wind.deg <= 236.25 then wind = wind .. ' SW' - elseif weather.wind.deg > 191.25 and weather.wind.deg <= 213.75 then wind = wind .. ' SSW' - elseif weather.wind.deg > 168.75 and weather.wind.deg <= 191.25 then wind = wind .. ' S' - elseif weather.wind.deg > 146.25 and weather.wind.deg <= 168.75 then wind = wind .. ' SSE' - elseif weather.wind.deg > 101.25 and weather.wind.deg <= 123.75 then wind = wind .. ' ESE' - elseif weather.wind.deg > 78.75 and weather.wind.deg <= 101.25 then wind = wind .. ' E' - elseif weather.wind.deg > 56.25 and weather.wind.deg <= 78.75 then wind = wind .. ' ENE' - elseif weather.wind.deg > 33.75 and weather.wind.deg <= 56.25 then wind = wind .. ' NE' - elseif weather.wind.deg > 11.25 and weather.wind.deg <= 33.75 then wind = wind .. ' NNE' - elseif weather.wind.deg > 348.75 and weather.wind.deg <= 11.25 then wind = wind .. ' N' + if weather.wind.deg > 326.25 and weather.wind.deg <= 348.75 then wind = wind .. 'NNW' + elseif weather.wind.deg > 303.75 and weather.wind.deg <= 326.25 then wind = wind .. 'NW' + elseif weather.wind.deg > 281.25 and weather.wind.deg <= 303.75 then wind = wind .. 'WNW' + elseif weather.wind.deg > 258.75 and weather.wind.deg <= 281.25 then wind = wind .. 'W' + elseif weather.wind.deg > 236.25 and weather.wind.deg <= 258.75 then wind = wind .. 'WSW' + elseif weather.wind.deg > 213.75 and weather.wind.deg <= 236.25 then wind = wind .. 'SW' + elseif weather.wind.deg > 191.25 and weather.wind.deg <= 213.75 then wind = wind .. 'SSW' + elseif weather.wind.deg > 168.75 and weather.wind.deg <= 191.25 then wind = wind .. 'S' + elseif weather.wind.deg > 146.25 and weather.wind.deg <= 168.75 then wind = wind .. 'SSE' + elseif weather.wind.deg > 101.25 and weather.wind.deg <= 123.75 then wind = wind .. 'ESE' + elseif weather.wind.deg > 78.75 and weather.wind.deg <= 101.25 then wind = wind .. 'E' + elseif weather.wind.deg > 56.25 and weather.wind.deg <= 78.75 then wind = wind .. 'ENE' + elseif weather.wind.deg > 33.75 and weather.wind.deg <= 56.25 then wind = wind .. 'NE' + elseif weather.wind.deg > 11.25 and weather.wind.deg <= 33.75 then wind = wind .. 'NNE' + elseif weather.wind.deg > 348.75 and weather.wind.deg <= 11.25 then wind = wind .. 'N' end + wind = wind .. ' ' .. weather.wind.speed .. "m/s" + return temp .. '\n' .. conditions .. '\n' .. wind end From 1ae085a69f0815de35e7fea3201b2b809a64231e Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Sat, 18 Apr 2015 05:45:47 +0300 Subject: [PATCH 20/23] weather plg upd --- plugins/weather.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/weather.lua b/plugins/weather.lua index 21e5a4f1..a449d78c 100644 --- a/plugins/weather.lua +++ b/plugins/weather.lua @@ -9,7 +9,7 @@ function get_weather(location) print("Weather returns", weather) local city = weather.name local country = weather.sys.country - local temp = city .. ' (' .. country .. ') ' + local temp = city .. ' (' .. country .. ')\n' temp = temp .. 'Temp: ' .. weather.main.temp .. '°C' local conditions = 'Conditions: ' .. weather.weather[1].description @@ -43,7 +43,7 @@ function get_weather(location) elseif weather.wind.deg > 348.75 and weather.wind.deg <= 11.25 then wind = wind .. 'N' end - wind = wind .. ' ' .. weather.wind.speed .. "m/s" + wind = wind .. ' ' .. weather.wind.speed .. " m/s" return temp .. '\n' .. conditions .. '\n' .. wind end From b5039cd3f0375740e00de56682f9de87dd3eac67 Mon Sep 17 00:00:00 2001 From: Konstantin Belentsov Date: Mon, 18 May 2015 12:52:54 +0300 Subject: [PATCH 21/23] plg fix --- plugins/imdb.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/imdb.lua b/plugins/imdb.lua index eccd15e8..84be096c 100644 --- a/plugins/imdb.lua +++ b/plugins/imdb.lua @@ -29,7 +29,7 @@ function imdb(msg, movie) end local function run(msg, matches) - return imdb(matches[1]) + return imdb(msg, matches[1]) end return { @@ -39,4 +39,4 @@ return { run = run } -end \ No newline at end of file +end From b7b036f4bdf9ffaf6bf4ed65bdfad3d8a07b2054 Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Tue, 18 Aug 2015 13:52:44 +0300 Subject: [PATCH 22/23] weather rollback --- plugins/weather.lua | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/plugins/weather.lua b/plugins/weather.lua index ead8786c..b6dd912a 100644 --- a/plugins/weather.lua +++ b/plugins/weather.lua @@ -8,16 +8,17 @@ local function get_weather(location) url = url..'?q='..location url = url..'&units=metric' - local b, c, h = http.request(BASE_URL.."/weather?q=" .. location .. "&units=metric") + local b, c, h = http.request(url) if c ~= 200 then return nil end local weather = json:decode(b) - print("Weather returns", weather) local city = weather.name local country = weather.sys.country - local temp = city .. ' (' .. country .. ')\n' - temp = temp .. 'Temp: ' .. weather.main.temp .. '°C' - local conditions = 'Conditions: ' .. weather.weather[1].description + local temp = 'The temperature in '..city + ..' (' ..country..')' + ..' is '..weather.main.temp..'°C' + local conditions = 'Current conditions are: ' + .. weather.weather[1].description if weather.weather[1].main == 'Clear' then conditions = conditions .. ' ☀' @@ -29,40 +30,16 @@ local function get_weather(location) conditions = conditions .. ' ☔☔☔☔' end - local wind = "Wind: " - - - if weather.wind.deg > 326.25 and weather.wind.deg <= 348.75 then wind = wind .. 'NNW' - elseif weather.wind.deg > 303.75 and weather.wind.deg <= 326.25 then wind = wind .. 'NW' - elseif weather.wind.deg > 281.25 and weather.wind.deg <= 303.75 then wind = wind .. 'WNW' - elseif weather.wind.deg > 258.75 and weather.wind.deg <= 281.25 then wind = wind .. 'W' - elseif weather.wind.deg > 236.25 and weather.wind.deg <= 258.75 then wind = wind .. 'WSW' - elseif weather.wind.deg > 213.75 and weather.wind.deg <= 236.25 then wind = wind .. 'SW' - elseif weather.wind.deg > 191.25 and weather.wind.deg <= 213.75 then wind = wind .. 'SSW' - elseif weather.wind.deg > 168.75 and weather.wind.deg <= 191.25 then wind = wind .. 'S' - elseif weather.wind.deg > 146.25 and weather.wind.deg <= 168.75 then wind = wind .. 'SSE' - elseif weather.wind.deg > 101.25 and weather.wind.deg <= 123.75 then wind = wind .. 'ESE' - elseif weather.wind.deg > 78.75 and weather.wind.deg <= 101.25 then wind = wind .. 'E' - elseif weather.wind.deg > 56.25 and weather.wind.deg <= 78.75 then wind = wind .. 'ENE' - elseif weather.wind.deg > 33.75 and weather.wind.deg <= 56.25 then wind = wind .. 'NE' - elseif weather.wind.deg > 11.25 and weather.wind.deg <= 33.75 then wind = wind .. 'NNE' - elseif weather.wind.deg > 348.75 and weather.wind.deg <= 11.25 then wind = wind .. 'N' - end - - wind = wind .. ' ' .. weather.wind.speed .. " m/s" - - return temp .. '\n' .. conditions .. '\n' .. wind + return temp .. '\n' .. conditions end local function run(msg, matches) - local city = 'Madrid,ES' + local city = 'Kyiv' - if string.len(matches[1]) > 2 then + if matches[1] ~= '!weather' then city = matches[1] - else - city = "Kyiv" end - return get_weather(city) + local text = get_weather(city) if not text then text = 'Can\'t get weather from that city.' end @@ -70,7 +47,7 @@ local function run(msg, matches) end return { - description = "weather in that city (Kyiv is default)", + description = "weather in that city (Madrid is default)", usage = "!weather (city)", patterns = { "^!weather$", From 60557e4e6fef8f9321f0677f5b2ac768952be5de Mon Sep 17 00:00:00 2001 From: AckiyBolt Date: Tue, 18 Aug 2015 14:00:16 +0300 Subject: [PATCH 23/23] dan fix --- plugins/dan.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/dan.lua b/plugins/dan.lua index 03a4ed9f..a3a63a58 100644 --- a/plugins/dan.lua +++ b/plugins/dan.lua @@ -39,9 +39,9 @@ function run(msg, matches) local post = get_post(url) - local receiver = get_receiver(msg) - local img = URL .. post.large_file_url - send_photo_from_url(receiver, img) + -- 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'