From 63ce836326b5d8eb2bb829c0ae576f794dbfa0d9 Mon Sep 17 00:00:00 2001 From: Tiago Danin Date: Tue, 26 Apr 2016 23:37:55 +0000 Subject: [PATCH 1/2] Improvements and fix --- plugins/about.lua | 6 +++--- plugins/bandersnatch.lua | 12 ++++++------ plugins/bible.lua | 16 ++++++++-------- plugins/calc.lua | 2 +- plugins/chatter.lua | 16 ++++++++-------- plugins/commit.lua | 3 ++- plugins/currency.lua | 5 ++--- plugins/echo.lua | 2 +- plugins/eightball.lua | 8 ++++---- plugins/fortune.lua | 4 ++-- plugins/gImages.lua | 3 ++- plugins/gMaps.lua | 2 ++ plugins/hackernews.lua | 2 -- plugins/imdb.lua | 2 +- plugins/lastfm.lua | 18 +++++++++--------- plugins/librefm.lua | 28 ++++++++++++++-------------- plugins/nick.lua | 2 +- plugins/patterns.lua | 4 ++-- plugins/ping.lua | 2 +- plugins/remind.lua | 4 ++-- plugins/time.lua | 4 ++-- plugins/translate.lua | 4 ++-- plugins/weather.lua | 4 ++-- 23 files changed, 77 insertions(+), 76 deletions(-) diff --git a/plugins/about.lua b/plugins/about.lua index 030abf1..0c00ac9 100755 --- a/plugins/about.lua +++ b/plugins/about.lua @@ -8,15 +8,15 @@ local triggers = { local action = function(msg) -- Filthy hack, but here is where we'll stop forwarded messages from hitting - -- other plugins. + -- Other plugins. if msg.forward_from then return end - local message = config.about_text .. '\nBased on @otouto v'..version..' by topkecleon.' + local output = config.about_text .. '\nBased on @otouto v'..version..' by topkecleon.' if (msg.new_chat_participant and msg.new_chat_participant.id == bot.id) or msg.text_lower:match('^/about[@'..bot.username..']*') or msg.text_lower:match('^/start') then - sendMessage(msg.chat.id, message, true) + sendMessage(msg.chat.id, output, true) return end diff --git a/plugins/bandersnatch.lua b/plugins/bandersnatch.lua index 5950ebe..ae588ae 100755 --- a/plugins/bandersnatch.lua +++ b/plugins/bandersnatch.lua @@ -13,25 +13,25 @@ local fullnames = { "Wimbledon Tennismatch", "Rinkydink Curdlesnoot", "Butawhite local firstnames = { "Bumblebee", "Bandersnatch", "Broccoli", "Rinkydink", "Bombadil", "Boilerdang", "Bandicoot", "Fragglerock", "Muffintop", "Congleton", "Blubberdick", "Buffalo", "Benadryl", "Butterfree", "Burberry", "Whippersnatch", "Buttermilk", "Beezlebub", "Budapest", "Boilerdang", "Blubberwhale", "Bumberstump", "Bulbasaur", "Cogglesnatch", "Liverswort", "Bodybuild", "Johnnycash", "Bendydick", "Burgerking", "Bonaparte", "Bunsenburner", "Billiardball", "Bukkake", "Baseballmitt", "Blubberbutt", "Baseballbat", "Rumblesack", "Barister", "Danglerack", "Rinkydink", "Bombadil", "Honkytonk", "Billyray", "Bumbleshack", "Snorkeldink", "Anglerfish", "Beetlejuice", "Bedlington", "Bandicoot", "Boobytrap", "Blenderdick", "Bentobox", "Anallube", "Pallettown", "Wimbledon", "Buttercup", "Blasphemy", "Snorkeldink", "Brandenburg", "Barbituate", "Snozzlebert", "Tiddleywomp", "Bouillabaisse", "Wellington", "Benetton", "Bendandsnap", "Timothy", "Brewery", "Bentobox", "Brandybuck", "Benjamin", "Buckminster", "Bourgeoisie", "Bakery", "Oscarbait", "Buckyball", "Bourgeoisie", "Burlington", "Buckingham", "Barnoldswick" } -local lastnames = { "Coddleswort", "Crumplesack", "Curdlesnoot", "Calldispatch", "Humperdinck", "Rivendell", "Cuttlefish", "Lingerie", "Vegemite", "Ampersand", "Cumberbund", "Candycrush", "Clombyclomp", "Cragglethatch", "Nottinghill", "Cabbagepatch", "Camouflage","Creamsicle", "Curdlemilk", "Upperclass", "Frumblesnatch", "Crumplehorn", "Talisman", "Candlestick", "Chesterfield", "Bumbersplat", "Scratchnsniff", "Snugglesnatch", "Charizard", "Carrotstick", "Cumbercooch", "Crackerjack", "Crucifix", "Cuckatoo", "Cockletit", "Collywog", "Capncrunch", "Covergirl", "Cumbersnatch", "Countryside","Coggleswort", "Splishnsplash", "Copperwire", "Animorph", "Curdledmilk", "Cheddarcheese", "Cottagecheese", "Crumplehorn", "Snickersbar", "Banglesnatch", "Stinkyrash", "Cameltoe", "Chickenbroth", "Concubine", "Candygram", "Moldyspore", "Chuckecheese", "Cankersore", "Crimpysnitch", "Wafflesmack", "Chowderpants", "Toodlesnoot", "Clavichord", "Cuckooclock", "Oxfordshire", "Cumbersome", "Chickenstrips", "Battleship", "Commonwealth", "Cunningsnatch", "Custardbath", "Kryptonite", "Curdlesnoot", "Cummerbund", "Coochyrash", "Crackerdong", "Crackerdong", "Curdledong", "Crackersprout", "Crumplebutt", "Colonist", "Coochierash", "Thundersnatch" } +local lastnames = { "Coddleswort", "Crumplesack", "Curdlesnoot", "Calldispatch", "Humperdinck", "Rivendell", "Cuttlefish", "Lingerie", "Vegemite", "Ampersand", "Cumberbund", "Candycrush", "Clombyclomp", "Cragglethatch", "Nottinghill", "Cabbagepatch", "Camouflage", "Creamsicle", "Curdlemilk", "Upperclass", "Frumblesnatch", "Crumplehorn", "Talisman", "Candlestick", "Chesterfield", "Bumbersplat", "Scratchnsniff", "Snugglesnatch", "Charizard", "Carrotstick", "Cumbercooch", "Crackerjack", "Crucifix", "Cuckatoo", "Cockletit", "Collywog", "Capncrunch", "Covergirl", "Cumbersnatch", "Countryside", "Coggleswort", "Splishnsplash", "Copperwire", "Animorph", "Curdledmilk", "Cheddarcheese", "Cottagecheese", "Crumplehorn", "Snickersbar", "Banglesnatch", "Stinkyrash", "Cameltoe", "Chickenbroth", "Concubine", "Candygram", "Moldyspore", "Chuckecheese", "Cankersore", "Crimpysnitch", "Wafflesmack", "Chowderpants", "Toodlesnoot", "Clavichord", "Cuckooclock", "Oxfordshire", "Cumbersome", "Chickenstrips", "Battleship", "Commonwealth", "Cunningsnatch", "Custardbath", "Kryptonite", "Curdlesnoot", "Cummerbund", "Coochyrash", "Crackerdong", "Crackerdong", "Curdledong", "Crackersprout", "Crumplebutt", "Colonist", "Coochierash", "Thundersnatch" } local action = function(msg) local message if math.random(10) == 10 then - message = fullnames[math.random(#fullnames)] + output = fullnames[math.random(#fullnames)] else - message = firstnames[math.random(#firstnames)] .. ' ' .. lastnames[math.random(#lastnames)] + output = firstnames[math.random(#firstnames)] .. ' ' .. lastnames[math.random(#lastnames)] end - sendReply(msg, message) + sendMessage(msg.chat.id, output, true, nil, true) end return { action = action, triggers = triggers, - command = command, - desc = desc + doc = doc, + command = command } diff --git a/plugins/bible.lua b/plugins/bible.lua index 03aca67..d84ec5d 100755 --- a/plugins/bible.lua +++ b/plugins/bible.lua @@ -27,22 +27,22 @@ local action = function(msg) local url = 'http://api.biblia.com/v1/bible/content/ASV.txt?key=' .. config.biblia_api_key .. '&passage=' .. URL.escape(input) - local message, res = HTTP.request(url) + local output, res = HTTP.request(url) - if not message or res ~= 200 or message:len() == 0 then + if not output or res ~= 200 or output:len() == 0 then url = 'http://api.biblia.com/v1/bible/content/KJVAPOC.txt?key=' .. config.biblia_api_key .. '&passage=' .. URL.escape(input) - message, res = HTTP.request(url) + output, res = HTTP.request(url) end - if not message or res ~= 200 or message:len() == 0 then - message = config.errors.results + if not output or res ~= 200 or output:len() == 0 then + output = config.errors.results end - if message:len() > 4000 then - message = 'The text is too long to post here. Try being more specific.' + if output:len() > 4000 then + output = 'The text is too long to post here. Try being more specific.' end - sendReply(msg, message) + sendMessage(msg.chat.id, output, true, msg.message_id, true) end diff --git a/plugins/calc.lua b/plugins/calc.lua index 0d854d1..e6995c7 100755 --- a/plugins/calc.lua +++ b/plugins/calc.lua @@ -28,7 +28,7 @@ local action = function(msg) return end - output = '`' .. output .. '`' + output = '*Result:* `' .. output .. '`' sendMessage(msg.chat.id, output, true, msg.message_id, true) diff --git a/plugins/chatter.lua b/plugins/chatter.lua index 6f532d9..80447f4 100755 --- a/plugins/chatter.lua +++ b/plugins/chatter.lua @@ -33,7 +33,7 @@ local action = function(msg) local input = msg.text_lower input = input:gsub(bot.first_name, 'simsimi') input = input:gsub('@'..bot.username, 'simsimi') - + if config.simsimi_trial then sandbox = 'sandbox.' else @@ -53,10 +53,10 @@ local action = function(msg) sendMessage(msg.chat.id, config.errors.chatter_response) return end - local message = jdat.response + local output = jdat.response - if message:match('^I HAVE NO RESPONSE.') then - message = config.errors.chatter_response + if output:match('^I HAVE NO RESPONSE.') then + output = config.errors.chatter_response end -- Let's clean up the response a little. Capitalization & punctuation. @@ -68,14 +68,14 @@ local action = function(msg) } for k,v in pairs(filter) do - message = string.gsub(message, k, v) + output = string.gsub(output, k, v) end - if not string.match(message, '%p$') then - message = message .. '.' + if not string.match(output, '%p$') then + output = output .. '.' end - sendMessage(msg.chat.id, message) + sendMessage(msg.chat.id, output) end diff --git a/plugins/commit.lua b/plugins/commit.lua index e0e73f4..d69bf71 100755 --- a/plugins/commit.lua +++ b/plugins/commit.lua @@ -418,7 +418,8 @@ local commits = { local action = function(msg) - sendMessage(msg.chat.id, '`'..commits[math.random(#commits)]..'`', true, nil, true) + local output = '*Commit:* '..commits[math.random(#commits)] + sendMessage(msg.chat.id, output, true, nil, true) end diff --git a/plugins/currency.lua b/plugins/currency.lua index aea0fa6..ebcd834 100755 --- a/plugins/currency.lua +++ b/plugins/currency.lua @@ -45,9 +45,8 @@ local action = function(msg) end - local output = amount .. ' ' .. from .. ' = ' .. result .. ' ' .. to .. '\n\n' - output = output .. os.date('!%F %T UTC') .. '\nSource: Google Finance' - output = '`' .. output .. '`' + local output = '*' .. amount .. ' ' .. from .. ' = ' .. result .. ' ' .. to .. '*\n\n' + output = output .. '`' .. os.date('!%F %T UTC') .. '\nSource: Google Finance`' sendMessage(msg.chat.id, output, true, nil, true) diff --git a/plugins/echo.lua b/plugins/echo.lua index c52d78b..a50639a 100755 --- a/plugins/echo.lua +++ b/plugins/echo.lua @@ -17,7 +17,7 @@ local action = function(msg) else local output if msg.chat.type == 'supergroup' then - output = 'Echo:\n"' .. input .. '"' + output = 'Echo:\n"' .. markdown_escape(input) .. '"' else output = latcyr(input) end diff --git a/plugins/eightball.lua b/plugins/eightball.lua index b6c163b..7d1b2f1 100755 --- a/plugins/eightball.lua +++ b/plugins/eightball.lua @@ -39,15 +39,15 @@ local yesno_answers = { local action = function(msg) - local message + local output if msg.text_lower:match('y/n%p?$') then - message = yesno_answers[math.random(#yesno_answers)] + output = yesno_answers[math.random(#yesno_answers)] else - message = ball_answers[math.random(#ball_answers)] + output = ball_answers[math.random(#ball_answers)] end - sendReply(msg, message) + sendReply(msg, output) end diff --git a/plugins/fortune.lua b/plugins/fortune.lua index a340b1a..860be08 100755 --- a/plugins/fortune.lua +++ b/plugins/fortune.lua @@ -16,8 +16,8 @@ local triggers = { local action = function(msg) - local message = io.popen('fortune'):read('*all') - sendMessage(msg.chat.id, message) + local output = io.popen('fortune'):read('*all') + sendMessage(msg.chat.id, output) end diff --git a/plugins/gImages.lua b/plugins/gImages.lua index f01c233..170e29e 100755 --- a/plugins/gImages.lua +++ b/plugins/gImages.lua @@ -64,7 +64,8 @@ local action = function(msg) if msg.text:match('nsfw') then - sendReply(msg, result) + output = 'NSFW Image ' .. output + sendMessage(msg.chat.id, output, true, nil, true) else sendMessage(msg.chat.id, output, false, nil, true) end diff --git a/plugins/gMaps.lua b/plugins/gMaps.lua index b2acc34..e830e28 100755 --- a/plugins/gMaps.lua +++ b/plugins/gMaps.lua @@ -13,6 +13,8 @@ local triggers = { local action = function(msg) + sendChatAction(msg.chat.id, "find_location") + local input = msg.text:input() if not input then if msg.reply_to_message and msg.reply_to_message.text then diff --git a/plugins/hackernews.lua b/plugins/hackernews.lua index 1747bc8..342be1e 100755 --- a/plugins/hackernews.lua +++ b/plugins/hackernews.lua @@ -11,8 +11,6 @@ local triggers = { local action = function(msg) - sendChatAction(msg.chat.id, 'typing') - local jstr, res = HTTPS.request('https://hacker-news.firebaseio.com/v0/topstories.json') if res ~= 200 then sendReply(msg, config.errors.connection) diff --git a/plugins/imdb.lua b/plugins/imdb.lua index 45cb543..b59d216 100755 --- a/plugins/imdb.lua +++ b/plugins/imdb.lua @@ -38,7 +38,7 @@ local action = function(msg) local output = '[' .. jdat.Title .. '](http://imdb.com/title/' output = output .. jdat.imdbID .. ') ('.. jdat.Year ..')\n' output = output .. jdat.imdbRating ..'/10 | '.. jdat.Runtime ..' | '.. jdat.Genre ..'\n' - output = output .. jdat.Plot + output = output .. '`' .. jdat.Plot .. '`' sendMessage(msg.chat.id, output, true, nil, true) diff --git a/plugins/lastfm.lua b/plugins/lastfm.lua index ee07874..d1630d1 100755 --- a/plugins/lastfm.lua +++ b/plugins/lastfm.lua @@ -45,14 +45,14 @@ local action = function(msg) local url = 'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&format=json&limit=1&api_key=' .. config.lastfm_api_key .. '&user=' local username - local output = '' + local alert = '' if input then username = input elseif database.users[msg.from.id_str].lastfm then username = database.users[msg.from.id_str].lastfm elseif msg.from.username then username = msg.from.username - output = '\n\nYour username has been set to ' .. username .. '.\nTo change it, use /fmset .' + alert = '\n\nYour username has been set to ' .. username .. '.\nTo change it, use /fmset .' database.users[msg.from.id_str].lastfm = username else sendReply(msg, 'Please specify your last.fm username or set it with /fmset.') @@ -75,17 +75,17 @@ local action = function(msg) local jdat = jdat.recenttracks.track[1] or jdat.recenttracks.track if not jdat then - sendReply(msg, 'No history for this user.' .. output) + sendReply(msg, 'No history for this user.' .. alert) return end - local message = input or msg.from.first_name - message = '🎵 ' .. message + local output = input or msg.from.first_name + output = '🎵 ' .. output if jdat['@attr'] and jdat['@attr'].nowplaying then - message = message .. ' is currently listening to:\n' + output = output .. ' is currently listening to:\n' else - message = message .. ' last listened to:\n' + output = output .. ' last listened to:\n' end local title = jdat.name or 'Unknown' @@ -94,8 +94,8 @@ local action = function(msg) artist = jdat.artist['#text'] end - message = message .. title .. ' - ' .. artist .. output - sendMessage(msg.chat.id, message) + output = output .. title .. ' - ' .. artist .. alert + sendMessage(msg.chat.id, output) end diff --git a/plugins/librefm.lua b/plugins/librefm.lua index 32e0b97..c2958b5 100644 --- a/plugins/librefm.lua +++ b/plugins/librefm.lua @@ -28,10 +28,10 @@ local action = function(msg) if not input then sendMessage(msg.chat.id, doc, true, msg.message_id, true) elseif input == '-' then - database.lastfm[msg.from.id_str] = nil + database.librefm[msg.from.id_str] = nil sendReply(msg, 'Your libre.fm username has been forgotten.') else - database.lastfm[msg.from.id_str] = input + database.librefm[msg.from.id_str] = input sendReply(msg, 'Your libre.fm username has been set to "' .. input .. '".') end return @@ -40,15 +40,15 @@ local action = function(msg) local url = 'http://alpha.libre.fm/2.0/?method=user.getrecenttracks&format=json&limit=1&api_key=0&user=' local username - local output = '' + local alert = '' if input then username = input - elseif database.lastfm[msg.from.id_str] then - username = database.lastfm[msg.from.id_str] + elseif database.librefm[msg.from.id_str] then + username = database.librefm[msg.from.id_str] elseif msg.from.username then username = msg.from.username - output = '\n\nYour username has been set to ' .. username .. '.\nTo change it, use /lfmset .' - database.lastfm[msg.from.id_str] = username + alert = '\n\nYour username has been set to ' .. username .. '.\nTo change it, use /lfmset .' + database.librefm[msg.from.id_str] = username else sendReply(msg, 'Please specify your libre.fm username or set it with /lfmset.') return @@ -70,17 +70,17 @@ local action = function(msg) local jdat = jdat.recenttracks.track[1] or jdat.recenttracks.track if not jdat then - sendReply(msg, 'No history for this user.' .. output) + sendReply(msg, 'No history for this user.' .. alert) return end - local message = input or msg.from.first_name - message = '🎵 ' .. message + local output = input or msg.from.first_name + output = '🎵 ' .. output if jdat['@attr'] and jdat['@attr'].nowplaying then - message = message .. ' is currently listening to:\n' + output = output .. ' is currently listening to:\n' else - message = message .. ' last listened to:\n' + output = output .. ' last listened to:\n' end local title = jdat.name or 'Unknown' @@ -89,8 +89,8 @@ local action = function(msg) artist = jdat.artist['#text'] end - message = message .. title .. ' - ' .. artist .. output - sendMessage(msg.chat.id, message) + output = output .. title .. ' - ' .. artist .. alert + sendMessage(msg.chat.id, output) end diff --git a/plugins/nick.lua b/plugins/nick.lua index d8b97a1..5756bfd 100755 --- a/plugins/nick.lua +++ b/plugins/nick.lua @@ -39,7 +39,7 @@ local action = function(msg) output = target.name .. '\'s nickname has been set to "' .. input .. '".' end - sendReply(msg, output) + sendMessage(msg.chat.id, output, true, nil, true) end diff --git a/plugins/patterns.lua b/plugins/patterns.lua index 74c024c..bbe298a 100644 --- a/plugins/patterns.lua +++ b/plugins/patterns.lua @@ -12,8 +12,8 @@ local action = function(msg) local m1, m2 = msg.text:match('^/?s/(.-)/(.-)/?$') if not m2 then return true end output = output:gsub(m1, m2) - output = 'Did you mean:\n"' .. output:sub(1, 4000) .. '"' - sendReply(msg.reply_to_message, output) + output = '*Did you mean:*\n"' .. output:sub(1, 4000) .. '"' + sendMessage(msg.chat.id, output, true, msg.message_id, true) end diff --git a/plugins/ping.lua b/plugins/ping.lua index d39e961..323f87c 100755 --- a/plugins/ping.lua +++ b/plugins/ping.lua @@ -6,7 +6,7 @@ local triggers = { } local action = function(msg) - sendMessage(msg.chat.id, msg.text_lower:match('^/ping') and 'Pong!' or 'Annyong.') + sendMessage(msg.chat.id, msg.text_lower:match('^/ping') and '*Pong!*' or '*Annyong.*', true, nil, true) end return { diff --git a/plugins/remind.lua b/plugins/remind.lua index 9618dfb..e4ead0c 100644 --- a/plugins/remind.lua +++ b/plugins/remind.lua @@ -71,8 +71,8 @@ local cron = function() -- If the reminder is past-due, send it and nullify it. -- Otherwise, add it to the replacement table. if time > reminder.time then - local output = 'Reminder:\n"' .. reminder.message .. '"' - local res = sendMessage(chat_id, output, true) + local output = '*Reminder:*\n"' .. markdown_escape(reminder.message) .. '"' + local res = sendMessage(chat_id, output, true, nil, true) -- If the message fails to send, save it for later. if res then reminder = nil diff --git a/plugins/time.lua b/plugins/time.lua index 1accc2e..fc78658 100755 --- a/plugins/time.lua +++ b/plugins/time.lua @@ -41,9 +41,9 @@ local action = function(msg) if utcoff == math.abs(utcoff) then utcoff = '+' .. utcoff end - local message = os.date('%I:%M %p\n', timestamp) .. os.date('%A, %B %d, %Y\n', timestamp) .. jdat.timeZoneName .. ' (UTC' .. utcoff .. ')' + local output = '`' .. os.date('%I:%M %p\n', timestamp) .. os.date('%A, %B %d, %Y\n', timestamp) .. jdat.timeZoneName .. ' (UTC' .. utcoff .. ')' .. '`' - sendReply(msg, message) + sendMessage(msg.chat.id, output, true, nil, true) end diff --git a/plugins/translate.lua b/plugins/translate.lua index b955be6..95c59b8 100755 --- a/plugins/translate.lua +++ b/plugins/translate.lua @@ -36,9 +36,9 @@ local action = function(msg) end local output = jdat.text[1] - output = 'Translation:\n"' .. output .. '"' + output = '*Translation:*\n"' .. output .. '"' - sendReply(msg.reply_to_message or msg, output) + sendMessage(msg.chat.id, output, true, msg.message_id, true) end diff --git a/plugins/weather.lua b/plugins/weather.lua index 3f42618..1c25957 100755 --- a/plugins/weather.lua +++ b/plugins/weather.lua @@ -48,9 +48,9 @@ local action = function(msg) local celsius = string.format('%.2f', jdat.main.temp - 273.15) local fahrenheit = string.format('%.2f', celsius * (9/5) + 32) - local message = celsius .. '°C | ' .. fahrenheit .. '°F, ' .. jdat.weather[1].description .. '.' + local output = celsius .. '°C | ' .. fahrenheit .. '°F, ' .. jdat.weather[1].description .. '.' - sendReply(msg, message) + sendMessage(msg.chat.id, output, true, msg.message_id, true) end From f52b255ebaf8105df71566421ef59a30eec14c2b Mon Sep 17 00:00:00 2001 From: topkecleon Date: Thu, 28 Apr 2016 14:27:22 -0400 Subject: [PATCH 2/2] Sorry, Tiago. This is why you should use multiple commits. --- plugins/about.lua | 2 +- plugins/bandersnatch.lua | 2 ++ plugins/calc.lua | 2 +- plugins/commit.lua | 2 +- plugins/echo.lua | 5 +++-- plugins/gImages.lua | 2 +- plugins/gMaps.lua | 2 -- plugins/hackernews.lua | 2 ++ plugins/imdb.lua | 6 +++--- plugins/nick.lua | 2 +- plugins/patterns.lua | 4 ++-- plugins/ping.lua | 3 ++- plugins/time.lua | 2 +- plugins/translate.lua | 2 +- plugins/weather.lua | 2 +- 15 files changed, 22 insertions(+), 18 deletions(-) diff --git a/plugins/about.lua b/plugins/about.lua index 0c00ac9..047e071 100755 --- a/plugins/about.lua +++ b/plugins/about.lua @@ -8,7 +8,7 @@ local triggers = { local action = function(msg) -- Filthy hack, but here is where we'll stop forwarded messages from hitting - -- Other plugins. + -- other plugins. if msg.forward_from then return end local output = config.about_text .. '\nBased on @otouto v'..version..' by topkecleon.' diff --git a/plugins/bandersnatch.lua b/plugins/bandersnatch.lua index ae588ae..10fe04b 100755 --- a/plugins/bandersnatch.lua +++ b/plugins/bandersnatch.lua @@ -25,6 +25,8 @@ local action = function(msg) output = firstnames[math.random(#firstnames)] .. ' ' .. lastnames[math.random(#lastnames)] end + output = '_' .. output .. '_' + sendMessage(msg.chat.id, output, true, nil, true) end diff --git a/plugins/calc.lua b/plugins/calc.lua index e6995c7..0d854d1 100755 --- a/plugins/calc.lua +++ b/plugins/calc.lua @@ -28,7 +28,7 @@ local action = function(msg) return end - output = '*Result:* `' .. output .. '`' + output = '`' .. output .. '`' sendMessage(msg.chat.id, output, true, msg.message_id, true) diff --git a/plugins/commit.lua b/plugins/commit.lua index d69bf71..fde1466 100755 --- a/plugins/commit.lua +++ b/plugins/commit.lua @@ -418,7 +418,7 @@ local commits = { local action = function(msg) - local output = '*Commit:* '..commits[math.random(#commits)] + local output = '`'..commits[math.random(#commits)]..'`' sendMessage(msg.chat.id, output, true, nil, true) end diff --git a/plugins/echo.lua b/plugins/echo.lua index a50639a..fcb1ceb 100755 --- a/plugins/echo.lua +++ b/plugins/echo.lua @@ -15,13 +15,14 @@ local action = function(msg) if not input then sendMessage(msg.chat.id, doc, true, msg.message_id, true) else + input = markdown_escape(input) local output if msg.chat.type == 'supergroup' then - output = 'Echo:\n"' .. markdown_escape(input) .. '"' + output = '*Echo:*\n"' .. input .. '"' else output = latcyr(input) end - sendMessage(msg.chat.id, output, true) + sendMessage(msg.chat.id, output, true, nil, true) end diff --git a/plugins/gImages.lua b/plugins/gImages.lua index 170e29e..7ca7da5 100755 --- a/plugins/gImages.lua +++ b/plugins/gImages.lua @@ -64,7 +64,7 @@ local action = function(msg) if msg.text:match('nsfw') then - output = 'NSFW Image ' .. output + output = '*NSFW*\n' .. output sendMessage(msg.chat.id, output, true, nil, true) else sendMessage(msg.chat.id, output, false, nil, true) diff --git a/plugins/gMaps.lua b/plugins/gMaps.lua index e830e28..b2acc34 100755 --- a/plugins/gMaps.lua +++ b/plugins/gMaps.lua @@ -13,8 +13,6 @@ local triggers = { local action = function(msg) - sendChatAction(msg.chat.id, "find_location") - local input = msg.text:input() if not input then if msg.reply_to_message and msg.reply_to_message.text then diff --git a/plugins/hackernews.lua b/plugins/hackernews.lua index 342be1e..1747bc8 100755 --- a/plugins/hackernews.lua +++ b/plugins/hackernews.lua @@ -11,6 +11,8 @@ local triggers = { local action = function(msg) + sendChatAction(msg.chat.id, 'typing') + local jstr, res = HTTPS.request('https://hacker-news.firebaseio.com/v0/topstories.json') if res ~= 200 then sendReply(msg, config.errors.connection) diff --git a/plugins/imdb.lua b/plugins/imdb.lua index b59d216..f1bd830 100755 --- a/plugins/imdb.lua +++ b/plugins/imdb.lua @@ -35,10 +35,10 @@ local action = function(msg) return end - local output = '[' .. jdat.Title .. '](http://imdb.com/title/' - output = output .. jdat.imdbID .. ') ('.. jdat.Year ..')\n' + local output = '*' .. jdat.Title .. ' ('.. jdat.Year ..')*\n' output = output .. jdat.imdbRating ..'/10 | '.. jdat.Runtime ..' | '.. jdat.Genre ..'\n' - output = output .. '`' .. jdat.Plot .. '`' + output = output .. '_' .. jdat.Plot .. '_\n' + output = output .. '[Read more.](http://imdb.com/title/' .. jdat.imdbID .. ')' sendMessage(msg.chat.id, output, true, nil, true) diff --git a/plugins/nick.lua b/plugins/nick.lua index 5756bfd..d8b97a1 100755 --- a/plugins/nick.lua +++ b/plugins/nick.lua @@ -39,7 +39,7 @@ local action = function(msg) output = target.name .. '\'s nickname has been set to "' .. input .. '".' end - sendMessage(msg.chat.id, output, true, nil, true) + sendReply(msg, output) end diff --git a/plugins/patterns.lua b/plugins/patterns.lua index bbe298a..74c024c 100644 --- a/plugins/patterns.lua +++ b/plugins/patterns.lua @@ -12,8 +12,8 @@ local action = function(msg) local m1, m2 = msg.text:match('^/?s/(.-)/(.-)/?$') if not m2 then return true end output = output:gsub(m1, m2) - output = '*Did you mean:*\n"' .. output:sub(1, 4000) .. '"' - sendMessage(msg.chat.id, output, true, msg.message_id, true) + output = 'Did you mean:\n"' .. output:sub(1, 4000) .. '"' + sendReply(msg.reply_to_message, output) end diff --git a/plugins/ping.lua b/plugins/ping.lua index 323f87c..e6bdee1 100755 --- a/plugins/ping.lua +++ b/plugins/ping.lua @@ -6,7 +6,8 @@ local triggers = { } local action = function(msg) - sendMessage(msg.chat.id, msg.text_lower:match('^/ping') and '*Pong!*' or '*Annyong.*', true, nil, true) + local output = msg.text_lower:match('^/ping') and 'Pong!' or 'Annyong.' + sendMessage(msg.chat.id, output) end return { diff --git a/plugins/time.lua b/plugins/time.lua index fc78658..94f1b33 100755 --- a/plugins/time.lua +++ b/plugins/time.lua @@ -43,7 +43,7 @@ local action = function(msg) end local output = '`' .. os.date('%I:%M %p\n', timestamp) .. os.date('%A, %B %d, %Y\n', timestamp) .. jdat.timeZoneName .. ' (UTC' .. utcoff .. ')' .. '`' - sendMessage(msg.chat.id, output, true, nil, true) + sendMessage(msg.chat.id, output, true, msg.message_id, true) end diff --git a/plugins/translate.lua b/plugins/translate.lua index 95c59b8..1200a49 100755 --- a/plugins/translate.lua +++ b/plugins/translate.lua @@ -36,7 +36,7 @@ local action = function(msg) end local output = jdat.text[1] - output = '*Translation:*\n"' .. output .. '"' + output = '*Translation:*\n"' .. markdown_escape(output) .. '"' sendMessage(msg.chat.id, output, true, msg.message_id, true) diff --git a/plugins/weather.lua b/plugins/weather.lua index 1c25957..beacdde 100755 --- a/plugins/weather.lua +++ b/plugins/weather.lua @@ -48,7 +48,7 @@ local action = function(msg) local celsius = string.format('%.2f', jdat.main.temp - 273.15) local fahrenheit = string.format('%.2f', celsius * (9/5) + 32) - local output = celsius .. '°C | ' .. fahrenheit .. '°F, ' .. jdat.weather[1].description .. '.' + local output = '`' .. celsius .. '°C | ' .. fahrenheit .. '°F, ' .. jdat.weather[1].description .. '.`' sendMessage(msg.chat.id, output, true, msg.message_id, true)