From b7c81c464f08699f6b45692f93cf285e5ebcd1f1 Mon Sep 17 00:00:00 2001 From: topkecleon Date: Mon, 25 Jul 2016 05:03:35 -0400 Subject: [PATCH] otouto v3.12 Minor changes across the board. More planned. I also may have accidentally screwed with access permissions (so looks like every file is marked modified). Moved drua-tg.lua into the otouto/ directory. Added pokego-calculator.lua plugin (similar to pidgeycalc.com). --- .editorconfig | 0 .gitignore | 1 + LICENSE | 0 README.md | 0 config.lua | 0 otouto/bindings.lua | 0 otouto/bot.lua | 20 +---- drua-tg.lua => otouto/drua-tg.lua | 30 +++++++- otouto/plugins/about.lua | 2 +- otouto/plugins/administration.lua | 13 ++-- otouto/plugins/apod.lua | 13 ++-- otouto/plugins/bandersnatch.lua | 5 +- otouto/plugins/bible.lua | 6 +- otouto/plugins/bing.lua | 8 +- otouto/plugins/blacklist.lua | 4 +- otouto/plugins/calc.lua | 6 +- otouto/plugins/cats.lua | 2 +- otouto/plugins/channel.lua | 17 ++--- otouto/plugins/chatter.lua | 0 otouto/plugins/commit.lua | 2 +- otouto/plugins/control.lua | 1 + otouto/plugins/currency.lua | 8 +- otouto/plugins/dice.lua | 6 +- otouto/plugins/dilbert.lua | 6 +- otouto/plugins/echo.lua | 5 +- otouto/plugins/eightball.lua | 2 +- otouto/plugins/fortune.lua | 2 +- otouto/plugins/gImages.lua | 8 +- otouto/plugins/gMaps.lua | 6 +- otouto/plugins/gSearch.lua | 8 +- otouto/plugins/greetings.lua | 0 otouto/plugins/hackernews.lua | 6 +- otouto/plugins/hearthstone.lua | 6 +- otouto/plugins/help.lua | 41 ++++------ otouto/plugins/imdb.lua | 5 +- otouto/plugins/lastfm.lua | 8 +- otouto/plugins/me.lua | 2 +- otouto/plugins/nick.lua | 6 +- otouto/plugins/ping.lua | 0 otouto/plugins/pokedex.lua | 6 +- otouto/plugins/pokego-calculator.lua | 108 +++++++++++++++++++++++++++ otouto/plugins/pokemon-go.lua | 6 +- otouto/plugins/preview.lua | 5 +- otouto/plugins/pun.lua | 2 +- otouto/plugins/reactions.lua | 2 +- otouto/plugins/reddit.lua | 6 +- otouto/plugins/remind.lua | 5 +- otouto/plugins/setandget.lua | 10 +-- otouto/plugins/shout.lua | 5 +- otouto/plugins/slap.lua | 5 +- otouto/plugins/time.lua | 6 +- otouto/plugins/translate.lua | 6 +- otouto/plugins/urbandictionary.lua | 6 +- otouto/plugins/weather.lua | 6 +- otouto/plugins/whoami.lua | 5 +- otouto/plugins/wikipedia.lua | 6 +- otouto/plugins/xkcd.lua | 6 +- otouto/plugins/youtube.lua | 6 +- otouto/utilities.lua | 0 59 files changed, 250 insertions(+), 212 deletions(-) mode change 100644 => 100755 .editorconfig mode change 100644 => 100755 .gitignore mode change 100755 => 100644 LICENSE mode change 100755 => 100644 README.md mode change 100755 => 100644 config.lua mode change 100755 => 100644 otouto/bindings.lua mode change 100755 => 100644 otouto/bot.lua rename drua-tg.lua => otouto/drua-tg.lua (75%) mode change 100755 => 100644 otouto/plugins/about.lua mode change 100755 => 100644 otouto/plugins/apod.lua mode change 100755 => 100644 otouto/plugins/bandersnatch.lua mode change 100755 => 100644 otouto/plugins/bible.lua mode change 100755 => 100644 otouto/plugins/blacklist.lua mode change 100755 => 100644 otouto/plugins/calc.lua mode change 100755 => 100644 otouto/plugins/cats.lua mode change 100755 => 100644 otouto/plugins/chatter.lua mode change 100755 => 100644 otouto/plugins/commit.lua mode change 100755 => 100644 otouto/plugins/currency.lua mode change 100755 => 100644 otouto/plugins/dice.lua mode change 100755 => 100644 otouto/plugins/echo.lua mode change 100755 => 100644 otouto/plugins/eightball.lua mode change 100755 => 100644 otouto/plugins/fortune.lua mode change 100755 => 100644 otouto/plugins/gImages.lua mode change 100755 => 100644 otouto/plugins/gMaps.lua mode change 100755 => 100644 otouto/plugins/gSearch.lua mode change 100755 => 100644 otouto/plugins/greetings.lua mode change 100755 => 100644 otouto/plugins/hackernews.lua mode change 100755 => 100644 otouto/plugins/hearthstone.lua mode change 100755 => 100644 otouto/plugins/help.lua mode change 100755 => 100644 otouto/plugins/imdb.lua mode change 100755 => 100644 otouto/plugins/lastfm.lua mode change 100755 => 100644 otouto/plugins/nick.lua mode change 100755 => 100644 otouto/plugins/ping.lua mode change 100755 => 100644 otouto/plugins/pokedex.lua create mode 100644 otouto/plugins/pokego-calculator.lua mode change 100755 => 100644 otouto/plugins/pun.lua mode change 100755 => 100644 otouto/plugins/reactions.lua mode change 100755 => 100644 otouto/plugins/reddit.lua mode change 100755 => 100644 otouto/plugins/slap.lua mode change 100755 => 100644 otouto/plugins/time.lua mode change 100755 => 100644 otouto/plugins/translate.lua mode change 100755 => 100644 otouto/plugins/urbandictionary.lua mode change 100755 => 100644 otouto/plugins/weather.lua mode change 100755 => 100644 otouto/plugins/whoami.lua mode change 100755 => 100644 otouto/plugins/wikipedia.lua mode change 100755 => 100644 otouto/plugins/xkcd.lua mode change 100755 => 100644 otouto/plugins/youtube.lua mode change 100755 => 100644 otouto/utilities.lua diff --git a/.editorconfig b/.editorconfig old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 7e934bb..59de323 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ otouto/plugins/mokubot* +otouto/plugins/oubot* *.db tg diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/config.lua b/config.lua old mode 100755 new mode 100644 diff --git a/otouto/bindings.lua b/otouto/bindings.lua old mode 100755 new mode 100644 diff --git a/otouto/bot.lua b/otouto/bot.lua old mode 100755 new mode 100644 index 0756878..63660b7 --- a/otouto/bot.lua +++ b/otouto/bot.lua @@ -4,7 +4,7 @@ local bot = {} local bindings -- Load Telegram bindings. local utilities -- Load miscellaneous and cross-plugin functions. -bot.version = '3.11' +bot.version = '3.12' function bot:init(config) -- The function run when the bot is started or reloaded. @@ -12,7 +12,7 @@ function bot:init(config) -- The function run when the bot is started or reloade utilities = require('otouto.utilities') assert( - config.bot_api_key and config.bot_api_key ~= '', + config.bot_api_key ~= '', 'You did not set your bot token in the config!' ) self.BASE_URL = 'https://api.telegram.org/bot' .. config.bot_api_key .. '/' @@ -29,21 +29,6 @@ function bot:init(config) -- The function run when the bot is started or reloade self.database = utilities.load_data(self.info.username..'.db') end - -- MIGRATION CODE 3.10 -> 3.11 - if self.database.users and self.database.version ~= '3.11' then - self.database.userdata = {} - for id, user in pairs(self.database.users) do - self.database.userdata[id] = {} - self.database.userdata[id].nickname = user.nickname - self.database.userdata[id].lastfm = user.lastfm - user.nickname = nil - user.lastfm = nil - user.id_str = nil - user.name = nil - end - end - -- END MIGRATION CODE - -- Table to cache user info (usernames, IDs, etc). self.database.users = self.database.users or {} -- Table to store userdata (nicknames, lastfm usernames, etc). @@ -58,6 +43,7 @@ function bot:init(config) -- The function run when the bot is started or reloade local p = require('otouto.plugins.'..v) table.insert(self.plugins, p) if p.init then p.init(self, config) end + if p.doc then p.doc = '```\n'..p.doc..'\n```' end end print('@' .. self.info.username .. ', AKA ' .. self.info.first_name ..' ('..self.info.id..')') diff --git a/drua-tg.lua b/otouto/drua-tg.lua similarity index 75% rename from drua-tg.lua rename to otouto/drua-tg.lua index c0233b0..3e83286 100644 --- a/drua-tg.lua +++ b/otouto/drua-tg.lua @@ -1,14 +1,36 @@ --[[ drua-tg - A fork of JuanPotato's lua-tg (https://github.com/juanpotato/lua-tg), + Based on JuanPotato's lua-tg (https://github.com/juanpotato/lua-tg), modified to work more naturally from an API bot. Usage: drua = require('drua-tg') - drua.IP = 'localhost' - drua.PORT = 4567 + drua.IP = 'localhost' -- 'localhost' is default + drua.PORT = 4567 -- 4567 is default drua.message(chat_id, text) -]]-- + +The MIT License (MIT) + +Copyright (c) 2015-2016 Juan Potato + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] local SOCKET = require('socket') diff --git a/otouto/plugins/about.lua b/otouto/plugins/about.lua old mode 100755 new mode 100644 index 87b00ee..3be9a53 --- a/otouto/plugins/about.lua +++ b/otouto/plugins/about.lua @@ -4,7 +4,7 @@ local bot = require('otouto.bot') local utilities = require('otouto.utilities') about.command = 'about' -about.doc = '`Returns information about the bot.`' +about.doc = 'Returns information about the bot.' about.triggers = { '' diff --git a/otouto/plugins/administration.lua b/otouto/plugins/administration.lua index 88dccfb..faa5c6c 100644 --- a/otouto/plugins/administration.lua +++ b/otouto/plugins/administration.lua @@ -19,10 +19,11 @@ now support multiple arguments. Added get_targets function. No migration is necessary. -]]-- + 1.11.1 - Bugfixes. /hammer can now be used in PM. +]] local JSON = require('dkjson') -local drua = dofile('drua-tg.lua') +local drua = require('otouto.drua-tg') local bindings = require('otouto.bindings') local utilities = require('otouto.utilities') @@ -49,7 +50,7 @@ function administration:init(config) administration.flags = administration.init_flags(config.cmd_pat) administration.init_command(self, config) - administration.doc = '`Returns a list of administrated groups.\nUse '..config.cmd_pat..'ahelp for more administrative commands.`' + administration.doc = 'Returns a list of administrated groups.\nUse '..config.cmd_pat..'ahelp for more administrative commands.' administration.command = 'groups [query]' -- In the worst case, don't send errors in reply to random messages. @@ -1199,7 +1200,9 @@ function administration.init_command(self_, config_) elseif target.rank >= administration.get_rank(self, msg.from.id, msg.chat.id, config) then output = output .. target.name .. ' is too privileged to be globally banned.\n' else - administration.kick_user(self, msg.chat.id, target.id, 'hammered by ' .. utilities.build_name(msg.from.first_name, msg.from.last_name), config) + if group then + administration.kick_user(self, msg.chat.id, target.id, 'hammered by ' .. utilities.build_name(msg.from.first_name, msg.from.last_name), config) + end if #targets == 1 then for k,v in pairs(self.database.administration.groups) do if not v.flags[6] then @@ -1209,7 +1212,7 @@ function administration.init_command(self_, config_) end end self.database.blacklist[target.id_str] = true - if group.flags[6] == true then + if group and group.flags[6] == true then group.mods[target.id_str] = nil group.bans[target.id_str] = true output = output .. target.name .. ' has been globally and locally banned.\n' diff --git a/otouto/plugins/apod.lua b/otouto/plugins/apod.lua old mode 100755 new mode 100644 index d0d187f..886feda --- a/otouto/plugins/apod.lua +++ b/otouto/plugins/apod.lua @@ -12,16 +12,17 @@ apod.command = 'apod [date]' function apod:init(config) apod.triggers = utilities.triggers(self.info.username, config.cmd_pat) :t('apod', true):t('apodhd', true):t('apodtext', true).table - apod.doc = [[``` -]]..config.cmd_pat..[[apod [query] + apod.doc = config.cmd_pat .. [[apod [query] Returns the Astronomy Picture of the Day. If the query is a date, in the format YYYY-MM-DD, the APOD of that day is returned. -]]..config.cmd_pat..[[apodhd [query] +Examples: +]] .. config.cmd_pat .. [[apodhd [query] Returns the image in HD, if available. -]]..config.cmd_pat..[[apodtext [query] + +]] .. config.cmd_pat .. [[apodtext [query] Returns the explanation of the APOD. -Source: nasa.gov -```]] + +Source: nasa.gov]] end function apod:action(msg, config) diff --git a/otouto/plugins/bandersnatch.lua b/otouto/plugins/bandersnatch.lua old mode 100755 new mode 100644 index 1cdcc50..bda4c93 --- a/otouto/plugins/bandersnatch.lua +++ b/otouto/plugins/bandersnatch.lua @@ -6,10 +6,7 @@ bandersnatch.command = 'bandersnatch' function bandersnatch:init(config) bandersnatch.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('bandersnatch'):t('bc').table - bandersnatch.doc = [[``` -Shun the frumious Bandersnatch. -Alias: ]]..config.cmd_pat..[[bc -```]] + bandersnatch.doc = 'Shun the frumious Bandersnatch. \nAlias: ' .. config.cmd_pat .. 'bc' end local fullnames = { "Wimbledon Tennismatch", "Rinkydink Curdlesnoot", "Butawhiteboy Cantbekhan", "Benadryl Claritin", "Bombadil Rivendell", "Wanda's Crotchfruit", "Biblical Concubine", "Syphilis Cankersore", "Buckminster Fullerene", "Bourgeoisie Capitalist" } diff --git a/otouto/plugins/bible.lua b/otouto/plugins/bible.lua old mode 100755 new mode 100644 index 1daddc2..69c88ef --- a/otouto/plugins/bible.lua +++ b/otouto/plugins/bible.lua @@ -12,11 +12,9 @@ function bible:init(config) end bible.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('bible', true):t('b', true).table - bible.doc = [[``` -]]..config.cmd_pat..[[bible + bible.doc = config.cmd_pat .. [[bible Returns a verse from the American Standard Version of the Bible, or an apocryphal verse from the King James Version. Results from biblia.com. -Alias: ]]..config.cmd_pat..[[b -```]] +Alias: ]] .. config.cmd_pat .. 'b' end bible.command = 'bible ' diff --git a/otouto/plugins/bing.lua b/otouto/plugins/bing.lua index f362bc2..539fddd 100644 --- a/otouto/plugins/bing.lua +++ b/otouto/plugins/bing.lua @@ -11,11 +11,6 @@ local ltn12 = require('ltn12') local utilities = require('otouto.utilities') bing.command = 'bing ' -bing.doc = [[``` -/bing -Returns the top web search results from Bing. -Aliases: /g, /google -```]] bing.search_url = 'https://api.datamarket.azure.com/Data.ashx/Bing/Search/Web?Query=\'%s\'&$format=json' @@ -26,6 +21,9 @@ function bing:init(config) return end bing.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('bing', true):t('g', true):t('google', true).table + bing.doc = config.cmd_pat .. [[bing +Returns the top web search results from Bing. +Aliases: ]] .. config.cmd_pat .. 'g, ' .. config.cmd_pat .. 'google' end function bing:action(msg, config) diff --git a/otouto/plugins/blacklist.lua b/otouto/plugins/blacklist.lua old mode 100755 new mode 100644 index 4feab99..3412c39 --- a/otouto/plugins/blacklist.lua +++ b/otouto/plugins/blacklist.lua @@ -93,7 +93,7 @@ function blacklist:action(msg, config) self.database.blacklist[target.id_str] = true output = output .. target.name .. ' is now blacklisted.\n' if config.drua_block_on_blacklist and target.id > 0 then - require('drua-tg').block(target.id) + require('otouto.drua-tg').block(target.id) end end end @@ -107,7 +107,7 @@ function blacklist:action(msg, config) self.database.blacklist[target.id_str] = nil output = output .. target.name .. ' is no longer blacklisted.\n' if config.drua_block_on_blacklist and target.id > 0 then - require('drua-tg').unblock(target.id) + require('otouto.drua-tg').unblock(target.id) end end end diff --git a/otouto/plugins/calc.lua b/otouto/plugins/calc.lua old mode 100755 new mode 100644 index e9cfd99..a063aad --- a/otouto/plugins/calc.lua +++ b/otouto/plugins/calc.lua @@ -8,10 +8,8 @@ calc.command = 'calc ' function calc:init(config) calc.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('calc', true).table - calc.doc = [[``` -]]..config.cmd_pat..[[calc -Returns solutions to mathematical expressions and conversions between common units. Results provided by mathjs.org. -```]] + calc.doc = config.cmd_pat .. [[calc +Returns solutions to mathematical expressions and conversions between common units. Results provided by mathjs.org.]] end function calc:action(msg, config) diff --git a/otouto/plugins/cats.lua b/otouto/plugins/cats.lua old mode 100755 new mode 100644 index 99f6049..7e99bb5 --- a/otouto/plugins/cats.lua +++ b/otouto/plugins/cats.lua @@ -13,7 +13,7 @@ function cats:init(config) end cats.command = 'cat' -cats.doc = '`Returns a cat!`' +cats.doc = 'Returns a cat!' function cats:action(msg, config) diff --git a/otouto/plugins/channel.lua b/otouto/plugins/channel.lua index cf51e4b..4be994e 100644 --- a/otouto/plugins/channel.lua +++ b/otouto/plugins/channel.lua @@ -3,9 +3,10 @@ local channel = {} local bindings = require('otouto.bindings') local utilities = require('otouto.utilities') ---channel.command = 'ch \\n ' -channel.doc = [[``` -/ch +function channel:init(config) + channel.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('ch', true).table + channel.command = 'ch \\n ' + channel.doc = config.cmd_pat .. [[ch Sends a message to a channel. Channel may be specified via ID or username. Messages are markdown-enabled. Users may only send messages to channels for which they are the owner or an administrator. @@ -15,13 +16,7 @@ The following markdown syntax is supported: _italic text_ [text](URL) `inline fixed-width code` - `‌`‌`pre-formatted fixed-width code block`‌`‌` - -Due to the frequent dysfunction and incompletion of the API method used to determine the administrators of a channel, this command may not work for the owners of some channels. -```]] - -function channel:init(config) - channel.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('ch', true).table + `‌`‌`pre-formatted fixed-width code block`‌`‌`]] end function channel:action(msg, config) @@ -51,7 +46,7 @@ function channel:action(msg, config) output = 'Please enter a message to be sent. Markdown is supported.' end else - output = 'Sorry, you do not appear to be an administrator for that channel.\nThere is currently a known bug in the getChatAdministrators method, where administrator lists will often not show a channel\'s owner.' + output = 'Sorry, you do not appear to be an administrator for that channel.' end else output = 'Sorry, I was unable to retrieve a list of administrators for that channel.\n`' .. t.description .. '`' diff --git a/otouto/plugins/chatter.lua b/otouto/plugins/chatter.lua old mode 100755 new mode 100644 diff --git a/otouto/plugins/commit.lua b/otouto/plugins/commit.lua old mode 100755 new mode 100644 index 0701385..9de1d1e --- a/otouto/plugins/commit.lua +++ b/otouto/plugins/commit.lua @@ -5,7 +5,7 @@ local commit = {} local utilities = require('otouto.utilities') commit.command = 'commit' -commit.doc = '`Returns a commit message from whatthecommit.com.`' +commit.doc = 'Returns a commit message from whatthecommit.com.' function commit:init(config) commit.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('commit').table diff --git a/otouto/plugins/control.lua b/otouto/plugins/control.lua index 1599037..cc4f1e1 100644 --- a/otouto/plugins/control.lua +++ b/otouto/plugins/control.lua @@ -27,6 +27,7 @@ function control:action(msg, config) end package.loaded['otouto.bindings'] = nil package.loaded['otouto.utilities'] = nil + package.loaded['otouto.drua-tg'] = nil package.loaded['config'] = nil if not msg.text_lower:match('%-config') then for k, v in pairs(require('config')) do diff --git a/otouto/plugins/currency.lua b/otouto/plugins/currency.lua old mode 100755 new mode 100644 index 16160d2..163d041 --- a/otouto/plugins/currency.lua +++ b/otouto/plugins/currency.lua @@ -7,12 +7,10 @@ currency.command = 'cash [amount] to ' function currency:init(config) currency.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('cash', true).table - currency.doc = [[``` -]]..config.cmd_pat..[[cash [amount] to -Example: ]]..config.cmd_pat..[[cash 5 USD to EUR + currency.doc = config.cmd_pat .. [[cash [amount] to +Example: ]] .. config.cmd_pat .. [[cash 5 USD to EUR Returns exchange rates for various currencies. -Source: Google Finance. -```]] +Source: Google Finance.]] end function currency:action(msg, config) diff --git a/otouto/plugins/dice.lua b/otouto/plugins/dice.lua old mode 100755 new mode 100644 index 032d3bf..cdd4d29 --- a/otouto/plugins/dice.lua +++ b/otouto/plugins/dice.lua @@ -6,10 +6,8 @@ dice.command = 'roll ' function dice:init(config) dice.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('roll', true).table - dice.doc = [[``` -]]..config.cmd_pat..[[roll -Returns a set of dice rolls, where n is the number of rolls and r is the range. If only a range is given, returns only one roll. -```]] + dice.doc = config.cmd_pat .. [[roll +Returns a set of dice rolls, where n is the number of rolls and r is the range. If only a range is given, returns only one roll.]] end function dice:action(msg) diff --git a/otouto/plugins/dilbert.lua b/otouto/plugins/dilbert.lua index 63416a6..ff197d5 100644 --- a/otouto/plugins/dilbert.lua +++ b/otouto/plugins/dilbert.lua @@ -9,12 +9,10 @@ dilbert.command = 'dilbert [date]' function dilbert:init(config) dilbert.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('dilbert', true).table - dilbert.doc = [[``` -]]..config.cmd_pat..[[dilbert [YYYY-MM-DD] + dilbert.doc = config.cmd_pat .. [[dilbert [YYYY-MM-DD] Returns the latest Dilbert strip or that of the provided date. Dates before the first strip will return the first strip. Dates after the last trip will return the last strip. -Source: dilbert.com -```]] +Source: dilbert.com]] end function dilbert:action(msg, config) diff --git a/otouto/plugins/echo.lua b/otouto/plugins/echo.lua old mode 100755 new mode 100644 index 10228b4..cb8d758 --- a/otouto/plugins/echo.lua +++ b/otouto/plugins/echo.lua @@ -6,10 +6,7 @@ echo.command = 'echo ' function echo:init(config) echo.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('echo', true).table - echo.doc = [[``` -]]..config.cmd_pat..[[echo -Repeats a string of text. -```]] + echo.doc = config.cmd_pat .. 'echo \nRepeats a string of text.' end function echo:action(msg) diff --git a/otouto/plugins/eightball.lua b/otouto/plugins/eightball.lua old mode 100755 new mode 100644 index 5db3972..2e01cbd --- a/otouto/plugins/eightball.lua +++ b/otouto/plugins/eightball.lua @@ -3,7 +3,7 @@ local eightball = {} local utilities = require('otouto.utilities') eightball.command = '8ball' -eightball.doc = '`Returns an answer from a magic 8-ball!`' +eightball.doc = 'Returns an answer from a magic 8-ball!' function eightball:init(config) eightball.triggers = utilities.triggers(self.info.username, config.cmd_pat, diff --git a/otouto/plugins/fortune.lua b/otouto/plugins/fortune.lua old mode 100755 new mode 100644 index c47871e..7d26eec --- a/otouto/plugins/fortune.lua +++ b/otouto/plugins/fortune.lua @@ -16,7 +16,7 @@ function fortune:init(config) end fortune.command = 'fortune' -fortune.doc = '`Returns a UNIX fortune.`' +fortune.doc = 'Returns a UNIX fortune.' function fortune:action(msg) diff --git a/otouto/plugins/gImages.lua b/otouto/plugins/gImages.lua old mode 100755 new mode 100644 index 9730a1a..e17a9d0 --- a/otouto/plugins/gImages.lua +++ b/otouto/plugins/gImages.lua @@ -20,11 +20,9 @@ function gImages:init(config) end gImages.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('image', true):t('i', true):t('insfw', true).table - gImages.doc = [[``` -]]..config.cmd_pat..[[image -Returns a randomized top result from Google Images. Safe search is enabled by default; use "]]..config.cmd_pat..[[insfw" to disable it. NSFW results will not display an image preview. -Alias: ]]..config.cmd_pat..[[i -```]] + gImages.doc = config.cmd_pat .. [[image +Returns a randomized top result from Google Images. Safe search is enabled by default; use "]] .. config.cmd_pat .. [[insfw" to disable it. NSFW results will not display an image preview. +Alias: ]] .. config.cmd_pat .. 'i' end gImages.command = 'image ' diff --git a/otouto/plugins/gMaps.lua b/otouto/plugins/gMaps.lua old mode 100755 new mode 100644 index d3719e9..78f72a0 --- a/otouto/plugins/gMaps.lua +++ b/otouto/plugins/gMaps.lua @@ -7,11 +7,9 @@ gMaps.command = 'location ' function gMaps:init(config) gMaps.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('location', true):t('loc', true).table - gMaps.doc = [[``` -]]..config.cmd_pat..[[location + gMaps.doc = config.cmd_pat .. [[location Returns a location from Google Maps. -Alias: ]]..config.cmd_pat..[[loc -```]] +Alias: ]] .. config.cmd_pat .. 'loc' end function gMaps:action(msg, config) diff --git a/otouto/plugins/gSearch.lua b/otouto/plugins/gSearch.lua old mode 100755 new mode 100644 index d38fb97..851cc65 --- a/otouto/plugins/gSearch.lua +++ b/otouto/plugins/gSearch.lua @@ -9,11 +9,9 @@ gSearch.command = 'google ' function gSearch:init(config) gSearch.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('g', true):t('google', true):t('gnsfw', true).table - gSearch.doc = [[``` -]]..config.cmd_pat..[[google -Returns four (if group) or eight (if private message) results from Google. Safe search is enabled by default, use "]]..config.cmd_pat..[[gnsfw" to disable it. -Alias: ]]..config.cmd_pat..[[g -```]] + gSearch.doc = config.cmd_pat .. [[google +Returns four (if group) or eight (if private message) results from Google. Safe search is enabled by default, use "]] .. config.cmd_pat .. [[gnsfw" to disable it. +Alias: ]] .. config.cmd_pat .. 'g' end function gSearch:action(msg, config) diff --git a/otouto/plugins/greetings.lua b/otouto/plugins/greetings.lua old mode 100755 new mode 100644 diff --git a/otouto/plugins/hackernews.lua b/otouto/plugins/hackernews.lua old mode 100755 new mode 100644 index b0a9f69..2bc8f53 --- a/otouto/plugins/hackernews.lua +++ b/otouto/plugins/hackernews.lua @@ -9,10 +9,8 @@ hackernews.command = 'hackernews' function hackernews:init(config) hackernews.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('hackernews', true):t('hn', true).table - hackernews.doc = [[``` -Returns four (if group) or eight (if private message) top stories from Hacker News. -Alias: ]]..config.cmd_pat..[[hn -```]] + hackernews.doc = [[Returns four (if group) or eight (if private message) top stories from Hacker News. +Alias: ]] .. config.cmd_pat .. 'hn' end function hackernews:action(msg, config) diff --git a/otouto/plugins/hearthstone.lua b/otouto/plugins/hearthstone.lua old mode 100755 new mode 100644 index 6f8d075..0a29ecf --- a/otouto/plugins/hearthstone.lua +++ b/otouto/plugins/hearthstone.lua @@ -37,11 +37,9 @@ function hearthstone:init(config) end hearthstone.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('hearthstone', true):t('hs').table - hearthstone.doc = [[``` -]]..config.cmd_pat..[[hearthstone + hearthstone.doc = config.cmd_pat .. [[hearthstone Returns Hearthstone card info. -Alias: ]]..config.cmd_pat..[[hs -```]] +Alias: ]] .. config.cmd_pat .. 'hs' end hearthstone.command = 'hearthstone ' diff --git a/otouto/plugins/help.lua b/otouto/plugins/help.lua old mode 100755 new mode 100644 index 83d4f08..7a804b7 --- a/otouto/plugins/help.lua +++ b/otouto/plugins/help.lua @@ -8,54 +8,45 @@ local utilities = require('otouto.utilities') local help_text function help:init(config) - local commandlist = {} help_text = '*Available commands:*\n• '..config.cmd_pat - for _,plugin in ipairs(self.plugins) do if plugin.command then table.insert(commandlist, plugin.command) - --help_text = help_text .. '\n• '..config.cmd_pat .. plugin.command:gsub('%[', '\\[') + if plugin.doc then + plugin.help_word = utilities.get_word(plugin.command, 1) + end end end - table.insert(commandlist, 'help [command]') table.sort(commandlist) - help_text = help_text .. table.concat(commandlist, '\n• '..config.cmd_pat) .. '\nArguments: [optional]' - help_text = help_text:gsub('%[', '\\[') - help.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('help', true):t('h', true).table - + help.doc = config.cmd_pat .. 'help [command] \nReturns usage information for a given command.' end function help:action(msg) - local input = utilities.input(msg.text_lower) - - -- Attempts to send the help message via PM. - -- If msg is from a group, it tells the group whether the PM was successful. - if not input then + if input then + for _,plugin in ipairs(self.plugins) do + if plugin.help_word == input:gsub('^/', '') then + local output = '*Help for* _' .. plugin.help_word .. '_ *:*\n' .. plugin.doc + utilities.send_message(self, msg.chat.id, output, true, nil, true) + return + end + end + utilities.send_reply(self, msg, 'Sorry, there is no help for that command.') + else + -- Attempt to send the help message via PM. + -- If msg is from a group, tell the group whether the PM was successful. local res = utilities.send_message(self, msg.from.id, help_text, true, nil, true) if not res then utilities.send_reply(self, msg, 'Please [message me privately](http://telegram.me/' .. self.info.username .. '?start=help) for a list of commands.', true) elseif msg.chat.type ~= 'private' then utilities.send_reply(self, msg, 'I have sent you the requested information in a private message.') end - return end - - for _,plugin in ipairs(self.plugins) do - if plugin.command and utilities.get_word(plugin.command, 1) == input and plugin.doc then - local output = '*Help for* _' .. utilities.get_word(plugin.command, 1) .. '_ *:*\n' .. plugin.doc - utilities.send_message(self, msg.chat.id, output, true, nil, true) - return - end - end - - utilities.send_reply(self, msg, 'Sorry, there is no help for that command.') - end return help diff --git a/otouto/plugins/imdb.lua b/otouto/plugins/imdb.lua old mode 100755 new mode 100644 index 2e05eb8..1a4e5c4 --- a/otouto/plugins/imdb.lua +++ b/otouto/plugins/imdb.lua @@ -9,10 +9,7 @@ imdb.command = 'imdb ' function imdb:init(config) imdb.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('imdb', true).table - imdb.doc = [[``` -]]..config.cmd_pat..[[imdb -Returns an IMDb entry. -```]] + imdb.doc = config.cmd_pat .. 'imdb \nReturns an IMDb entry.' end function imdb:action(msg, config) diff --git a/otouto/plugins/lastfm.lua b/otouto/plugins/lastfm.lua old mode 100755 new mode 100644 index 0cc831f..ea5eab9 --- a/otouto/plugins/lastfm.lua +++ b/otouto/plugins/lastfm.lua @@ -16,13 +16,11 @@ function lastfm:init(config) end lastfm.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('lastfm', true):t('np', true):t('fmset', true).table - lastfm.doc = [[``` -]]..config.cmd_pat..[[np [username] + lastfm.doc = config.cmd_pat .. [[np [username] Returns what you are or were last listening to. If you specify a username, info will be returned for that username. -]]..config.cmd_pat..[[fmset -Sets your last.fm username. Otherwise, ]]..config.cmd_pat..[[np will use your Telegram username. Use "]]..config.cmd_pat..[[fmset --" to delete it. -```]] +]] .. config.cmd_pat .. [[fmset +Sets your last.fm username. Otherwise, ]] .. config.cmd_pat .. [[np will use your Telegram username. Use "]] .. config.cmd_pat .. [[fmset --" to delete it.]] end lastfm.command = 'lastfm' diff --git a/otouto/plugins/me.lua b/otouto/plugins/me.lua index 771ba80..e692782 100644 --- a/otouto/plugins/me.lua +++ b/otouto/plugins/me.lua @@ -5,7 +5,7 @@ local utilities = require('otouto.utilities') function me:init(config) me.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('me', true).table me.command = 'me' - me.doc = '`Returns userdata stored by the bot.`' + me.doc = 'Returns userdata stored by the bot.' end function me:action(msg, config) diff --git a/otouto/plugins/nick.lua b/otouto/plugins/nick.lua old mode 100755 new mode 100644 index 1819c5c..9812aa7 --- a/otouto/plugins/nick.lua +++ b/otouto/plugins/nick.lua @@ -6,10 +6,8 @@ nick.command = 'nick ' function nick:init(config) nick.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('nick', true).table - nick.doc = [[``` -]]..config.cmd_pat..[[nick -Set your nickname. Use "]]..config.cmd_pat..[[nick --" to delete it. -```]] + nick.doc = config.cmd_pat .. [[nick +Set your nickname. Use "]] .. config.cmd_pat .. 'nick --" to delete it.' end function nick:action(msg, config) diff --git a/otouto/plugins/ping.lua b/otouto/plugins/ping.lua old mode 100755 new mode 100644 diff --git a/otouto/plugins/pokedex.lua b/otouto/plugins/pokedex.lua old mode 100755 new mode 100644 index a38de1a..eb30c8e --- a/otouto/plugins/pokedex.lua +++ b/otouto/plugins/pokedex.lua @@ -9,11 +9,9 @@ pokedex.command = 'pokedex ' function pokedex:init(config) pokedex.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('pokedex', true):t('dex', true).table - pokedex.doc = [[``` -]]..config.cmd_pat..[[pokedex + pokedex.doc = config.cmd_pat .. [[pokedex Returns a Pokedex entry from pokeapi.co. -Alias: ]]..config.cmd_pat..[[dex -```]] +Alias: ]] .. config.cmd_pat .. 'dex' end function pokedex:action(msg, config) diff --git a/otouto/plugins/pokego-calculator.lua b/otouto/plugins/pokego-calculator.lua new file mode 100644 index 0000000..5c3e289 --- /dev/null +++ b/otouto/plugins/pokego-calculator.lua @@ -0,0 +1,108 @@ +local utilities = require('otouto.utilities') + +local pgc = {} + +function pgc:init(config) + pgc.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('gocalc', true).table + pgc.doc = config.cmd_pat .. [[gocalc +Calculates the number of Pokémon that must be transferred before evolving, how many evolutions the user is able to perform, and how many Pokémon and candy will be left over. +All arguments must be positive numbers. Batch jobs may be performed by separating valid sets of arguments by lines. +Example (forty pidgeys and three hundred pidgey candies): +]] .. config.cmd_pat .. 'gocalc 12 40 300' + pgc.command = 'gocalc <#pokemon> <#candy>' +end + + -- This function written by Juan Potato. MIT-licensed. +local pidgey_calc = function(candies_to_evolve, mons, candies) + local transferred = 0; + local evolved = 0; + + while true do + if math.floor(candies / candies_to_evolve) == 0 or mons == 0 then + break + else + mons = mons - 1 + candies = candies - candies_to_evolve + 1 + evolved = evolved + 1 + if mons == 0 then + break + end + end + end + + while true do + if (candies + mons) < (candies_to_evolve + 1) or mons == 0 then + break + end + while candies < candies_to_evolve do + transferred = transferred + 1 + mons = mons - 1 + candies = candies + 1 + end + mons = mons - 1 + candies = candies - candies_to_evolve + 1 + evolved = evolved + 1 + end + + return { + transfer = transferred, + evolve = evolved, + leftover_mons = mons, + leftover_candy = candies + } +end + +local single_job = function(input) + local req_candy, mons, candies = input:match('^(%d+) (%d+) (%d+)$') + req_candy = tonumber(req_candy) + mons = tonumber(mons) + candies = tonumber(candies) + if not (req_candy and mons and candies) then + return { err = 'Invalid input: Three numbers expected.' } + elseif req_candy > 400 then + return { err = 'Invalid required candy: Maximum is 400.' } + elseif mons > 1000 then + return { err = 'Invalid number of Pokémon: Maximum is 1000.' } + elseif candies > 10000 then + return { err = 'Invalid number of candies: Maximum is 10000.' } + else + return pidgey_calc(req_candy, mons, candies) + end +end + +function pgc:action(msg) + local input = utilities.input(msg.text) + if not input then + utilities.send_reply(self, msg, pgc.doc, true) + return + end + input = input .. '\n' + local output = '' + local total_evolutions = 0 + for line in input:gmatch('(.-)\n') do + local info = single_job(line) + output = output .. '`' .. line .. '`\n' + if info.err then + output = output .. info.err .. '\n\n' + else + total_evolutions = total_evolutions + info.evolve + local s = '*Transfer:* %s. \n*Evolve:* %s (%s XP, %s minutes). \n*Leftover:* %s mons, %s candy.\n\n' + s = s:format(info.transfer, info.evolve, info.evolve..'k', info.evolve*0.5, info.leftover_mons, info.leftover_candy) + output = output .. s + end + end + local s = '*Total evolutions:* %s. \n*Recommendation:* %s' + local recommendation + local egg_count = math.floor(total_evolutions/60) + if egg_count < 1 then + recommendation = 'Wait until you have atleast sixty Pokémon to evolve before using a lucky egg.' + else + recommendation = 'Use %s lucky egg(s) for %s evolutions.' + recommendation = recommendation:format(egg_count, egg_count*60) + end + s = s:format(total_evolutions, recommendation) + output = output .. s + utilities.send_reply(self, msg, output, true) +end + +return pgc diff --git a/otouto/plugins/pokemon-go.lua b/otouto/plugins/pokemon-go.lua index 9ded32b..a122a6d 100644 --- a/otouto/plugins/pokemon-go.lua +++ b/otouto/plugins/pokemon-go.lua @@ -9,10 +9,8 @@ function pokemon_go:init(config) pokemon_go.triggers = utilities.triggers(self.info.username, config.cmd_pat) :t('pokego', true):t('pokégo', true) :t('pokemongo', true):t('pokémongo', true).table - pokemon_go.doc = [[``` -]]..config.cmd_pat..[[pokego -Set your Pokémon Go team for statistical purposes. The team must be valid, and can be referred to by name or color (or the first letter of either). Giving no team name will show statistics. -```]] + pokemon_go.doc = config.cmd_pat .. [[pokego +Set your Pokémon Go team for statistical purposes. The team must be valid, and can be referred to by name or color (or the first letter of either). Giving no team name will show statistics.]] local db = self.database.pokemon_go if not db then self.database.pokemon_go = {} diff --git a/otouto/plugins/preview.lua b/otouto/plugins/preview.lua index 7b535d6..ecb7f66 100644 --- a/otouto/plugins/preview.lua +++ b/otouto/plugins/preview.lua @@ -7,10 +7,7 @@ preview.command = 'preview ' function preview:init(config) preview.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('preview', true).table - preview.doc = [[``` -]]..config.cmd_pat..[[preview -Returns a full-message, "unlinked" preview. -```]] + preview.doc = config.cmd_pat .. 'preview \nReturns a full-message, "unlinked" preview.' end function preview:action(msg) diff --git a/otouto/plugins/pun.lua b/otouto/plugins/pun.lua old mode 100755 new mode 100644 index fc84689..5063096 --- a/otouto/plugins/pun.lua +++ b/otouto/plugins/pun.lua @@ -3,7 +3,7 @@ local pun = {} local utilities = require('otouto.utilities') pun.command = 'pun' -pun.doc = '`Returns a pun.`' +pun.doc = 'Returns a pun.' function pun:init(config) pun.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('pun').table diff --git a/otouto/plugins/reactions.lua b/otouto/plugins/reactions.lua old mode 100755 new mode 100644 index d75a3c3..ed4ddd6 --- a/otouto/plugins/reactions.lua +++ b/otouto/plugins/reactions.lua @@ -11,7 +11,7 @@ local reactions = {} local utilities = require('otouto.utilities') reactions.command = 'reactions' -reactions.doc = '`Returns a list of "reaction" emoticon commands.`' +reactions.doc = 'Returns a list of "reaction" emoticon commands.' local mapping = { ['shrug'] = '¯\\_(ツ)_/¯', diff --git a/otouto/plugins/reddit.lua b/otouto/plugins/reddit.lua old mode 100755 new mode 100644 index 21bfb00..8bdcb05 --- a/otouto/plugins/reddit.lua +++ b/otouto/plugins/reddit.lua @@ -9,11 +9,9 @@ reddit.command = 'reddit [r/subreddit | query]' function reddit:init(config) reddit.triggers = utilities.triggers(self.info.username, config.cmd_pat, {'^/r/'}):t('reddit', true):t('r', true):t('r/', true).table - reddit.doc = [[``` -]]..config.cmd_pat..[[reddit [r/subreddit | query] + reddit.doc = config.cmd_pat .. [[reddit [r/subreddit | query] Returns the top posts or results for a given subreddit or query. If no argument is given, returns the top posts from r/all. Querying specific subreddits is not supported. -Aliases: ]]..config.cmd_pat..[[r, /r/subreddit -```]] +Aliases: ]] .. config.cmd_pat .. 'r, /r/subreddit' end local format_results = function(posts) diff --git a/otouto/plugins/remind.lua b/otouto/plugins/remind.lua index 8e55c50..7722e9c 100644 --- a/otouto/plugins/remind.lua +++ b/otouto/plugins/remind.lua @@ -8,10 +8,7 @@ function remind:init(config) self.database.reminders = self.database.reminders or {} remind.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('remind', true).table - remind.doc = [[``` - ]]..config.cmd_pat..[[remind - Repeats a message after a duration of time, in minutes. - ```]] + remind.doc = config.cmd_pat .. 'remind \nRepeats a message after a duration of time, in minutes.' end function remind:action(msg) diff --git a/otouto/plugins/setandget.lua b/otouto/plugins/setandget.lua index 913003c..122b942 100644 --- a/otouto/plugins/setandget.lua +++ b/otouto/plugins/setandget.lua @@ -5,12 +5,10 @@ local utilities = require('otouto.utilities') function setandget:init(config) self.database.setandget = self.database.setandget or {} setandget.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('set', true):t('get', true).table - setandget.doc = [[``` -]]..config.cmd_pat..[[set -Stores a value with the given name. Use "]]..config.cmd_pat..[[set --" to delete the stored value. -]]..config.cmd_pat..[[get [name] -Returns the stored value or a list of stored values. -```]] + setandget.doc = config.cmd_pat .. [[set +Stores a value with the given name. Use "]] .. config.cmd_pat .. [[set --" to delete the stored value. +]] .. config.cmd_pat .. [[get [name] +Returns the stored value or a list of stored values.]] end setandget.command = 'set ' diff --git a/otouto/plugins/shout.lua b/otouto/plugins/shout.lua index 3c1af21..105c166 100644 --- a/otouto/plugins/shout.lua +++ b/otouto/plugins/shout.lua @@ -6,10 +6,7 @@ shout.command = 'shout ' function shout:init(config) shout.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('shout', true).table - shout.doc = [[``` -]]..config.cmd_pat..[[shout -Shouts something. Input may be the replied-to message. -```]] + shout.doc = config.cmd_pat .. 'shout \nShouts something. Input may be the replied-to message.' end function shout:action(msg) diff --git a/otouto/plugins/slap.lua b/otouto/plugins/slap.lua old mode 100755 new mode 100644 index d115d12..33e0bbc --- a/otouto/plugins/slap.lua +++ b/otouto/plugins/slap.lua @@ -6,10 +6,7 @@ slap.command = 'slap [target]' function slap:init(config) slap.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('slap', true).table - slap.doc = [[``` -]]..config.cmd_pat..[[slap [target] -Slap somebody. -```]] + slap.doc = config.cmd_pat .. 'slap [target] \nSlap somebody.' end local slaps = { diff --git a/otouto/plugins/time.lua b/otouto/plugins/time.lua old mode 100755 new mode 100644 index 90aa68c..edc43a7 --- a/otouto/plugins/time.lua +++ b/otouto/plugins/time.lua @@ -8,10 +8,8 @@ time.command = 'time ' function time:init(config) time.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('time', true).table - time.doc = [[``` -]]..config.cmd_pat..[[time -Returns the time, date, and timezone for the given location. -```]] + time.doc = config.cmd_pat .. [[time +Returns the time, date, and timezone for the given location.]] end function time:action(msg, config) diff --git a/otouto/plugins/translate.lua b/otouto/plugins/translate.lua old mode 100755 new mode 100644 index bcff57e..2ab0ee0 --- a/otouto/plugins/translate.lua +++ b/otouto/plugins/translate.lua @@ -9,10 +9,8 @@ translate.command = 'translate [text]' function translate:init(config) translate.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('translate', true):t('tl', true).table - translate.doc = [[``` -]]..config.cmd_pat..[[translate [text] -Translates input or the replied-to message into the bot's language. -```]] + translate.doc = config.cmd_pat .. [[translate [text] +Translates input or the replied-to message into the bot's language.]] end function translate:action(msg, config) diff --git a/otouto/plugins/urbandictionary.lua b/otouto/plugins/urbandictionary.lua old mode 100755 new mode 100644 index c206057..06129e3 --- a/otouto/plugins/urbandictionary.lua +++ b/otouto/plugins/urbandictionary.lua @@ -10,11 +10,9 @@ urbandictionary.command = 'urbandictionary ' function urbandictionary:init(config) urbandictionary.triggers = utilities.triggers(self.info.username, config.cmd_pat) :t('urbandictionary', true):t('ud', true):t('urban', true).table - urbandictionary.doc = [[``` -]]..config.cmd_pat..[[urbandictionary + urbandictionary.doc = config.cmd_pat .. [[urbandictionary Returns a definition from Urban Dictionary. -Aliases: ]]..config.cmd_pat..[[ud, ]]..config.cmd_pat..[[urban -```]] +Aliases: ]] .. config.cmd_pat .. 'ud, ' .. config.cmd_pat .. 'urban' end function urbandictionary:action(msg, config) diff --git a/otouto/plugins/weather.lua b/otouto/plugins/weather.lua old mode 100755 new mode 100644 index ce9256d..06a1d31 --- a/otouto/plugins/weather.lua +++ b/otouto/plugins/weather.lua @@ -13,10 +13,8 @@ function weather:init(config) end weather.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('weather', true).table - weather.doc = [[``` -]]..config.cmd_pat..[[weather -Returns the current weather conditions for a given location. -```]] + weather.doc = config.cmd_pat .. [[weather +Returns the current weather conditions for a given location.]] end weather.command = 'weather ' diff --git a/otouto/plugins/whoami.lua b/otouto/plugins/whoami.lua old mode 100755 new mode 100644 index ce068ff..fa51b13 --- a/otouto/plugins/whoami.lua +++ b/otouto/plugins/whoami.lua @@ -6,10 +6,9 @@ whoami.command = 'whoami' function whoami:init(config) whoami.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('who', true):t('whoami').table - whoami.doc = [[``` + whoami.doc = [[ Returns user and chat info for you or the replied-to message. -Alias: ]]..config.cmd_pat..[[who -```]] +Alias: ]] .. config.cmd_pat .. 'who' end function whoami:action(msg) diff --git a/otouto/plugins/wikipedia.lua b/otouto/plugins/wikipedia.lua old mode 100755 new mode 100644 index 5f9fcae..598798e --- a/otouto/plugins/wikipedia.lua +++ b/otouto/plugins/wikipedia.lua @@ -9,11 +9,9 @@ wikipedia.command = 'wikipedia ' function wikipedia:init(config) wikipedia.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('wikipedia', true):t('wiki', true):t('w', true).table - wikipedia.doc = [[``` -]]..config.cmd_pat..[[wikipedia + wikipedia.doc = config.cmd_pat .. [[wikipedia Returns an article from Wikipedia. -Aliases: ]]..config.cmd_pat..[[w, ]]..config.cmd_pat..[[wiki -```]] +Aliases: ]] .. config.cmd_pat .. 'w, ' .. config.cmd_pat .. 'wiki' end local get_title = function(search) diff --git a/otouto/plugins/xkcd.lua b/otouto/plugins/xkcd.lua old mode 100755 new mode 100644 index bd16ef8..cc7c166 --- a/otouto/plugins/xkcd.lua +++ b/otouto/plugins/xkcd.lua @@ -8,10 +8,8 @@ xkcd.command = 'xkcd [i]' function xkcd:init(config) xkcd.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('xkcd', true).table - xkcd.doc = [[``` -]]..config.cmd_pat..[[xkcd [i] -Returns the latest xkcd strip and its alt text. If a number is given, returns that number strip. If "r" is passed in place of a number, returns a random strip. -```]] + xkcd.doc = config.cmd_pat .. [[xkcd [i] +Returns the latest xkcd strip and its alt text. If a number is given, returns that number strip. If "r" is passed in place of a number, returns a random strip.]] end function xkcd:action(msg, config) diff --git a/otouto/plugins/youtube.lua b/otouto/plugins/youtube.lua old mode 100755 new mode 100644 index 1c75537..5ff9108 --- a/otouto/plugins/youtube.lua +++ b/otouto/plugins/youtube.lua @@ -15,11 +15,9 @@ function youtube:init(config) end youtube.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('youtube', true):t('yt', true).table - youtube.doc = [[``` -]]..config.cmd_pat..[[youtube + youtube.doc = config.cmd_pat .. [[youtube Returns the top result from YouTube. -Alias: ]]..config.cmd_pat..[[yt -```]] +Alias: ]] .. config.cmd_pat .. 'yt' end youtube.command = 'youtube ' diff --git a/otouto/utilities.lua b/otouto/utilities.lua old mode 100755 new mode 100644