From 38efb5d827fec652c4c75cc7439b970b1b65b2cd Mon Sep 17 00:00:00 2001 From: topkecleon Date: Tue, 5 Apr 2016 06:43:11 -0400 Subject: [PATCH] administration.lua: 1.8.1 me.lua: Fix for potential future bug. README.md: Better links. config.lua: Added comments, links, removed unnecessary things. greetings.lua: Default configuration now built in so as to not crowd the config file. .gitignore: wew lad --- .gitignore | 2 +- README.md | 8 ++-- config.lua | 77 ++++++++++++++++++-------------------- plugins/administration.lua | 24 ++++++++---- plugins/eightball.lua | 2 +- plugins/greetings.lua | 31 +++++++++++++++ plugins/me.lua | 2 +- 7 files changed, 91 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index 526c2a4..6b78c58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ plugins/mokubot* plugins/qtbot* -plugins/weeabot* *.db lua-tg +drua-tg tg diff --git a/README.md b/README.md index ae59634..d9e96a4 100755 --- a/README.md +++ b/README.md @@ -32,13 +32,13 @@ When you are ready to start the bot, run `./launch.sh`. To stop the bot, send "/ Note that certain plugins, such as translate.lua and greetings.lua, will require privacy mode to be disabled. Additionally, some plugins may require or make use of various API keys: + - gImages.lua & youtube.lua: Google [API](http://console.developers.google.com) and [CSE](https://cse.google.com/cse) keys (`google_api_key`, `google_cse_key`) - weather.lua: [OpenWeatherMap](http://openweathermap.org) API key (`owm_api_key`) - - lastfm.lua: [last.fm](http://last.fm) API key (`lastfm_api_key`) - - bible.lua: [Biblia](http://biblia.com) API key (`biblia_api_key`) + - lastfm.lua: [last.fm](http://last.fm/api) API key (`lastfm_api_key`) + - bible.lua: [Biblia](http://api.biblia.com) API key (`biblia_api_key`) - cats.lua: [The Cat API](http://thecatapi.com) API key (optional) (`thecatapi_key`) - - gImages.lua: Google [API](http://console.developers.google.com) and [CSE](https://cse.google.com/cse) keys (`google_api_key`, `google_cse_key`) - apod.lua: [NASA](http://api.nasa.gov) API key (`nasa_api_key`) - - translate.lua: [Yandex](https://tech.yandex.com/keys/get/?service=trnsl) API key (`yandex_key`) + - translate.lua: [Yandex](http://tech.yandex.com/keys/get/?service=trnsl) API key (`yandex_key`) - chatter.lua: [SimSimi](http://developer.simsimi.com/signUp) API key (`simsimi_key`) * * * diff --git a/config.lua b/config.lua index 4a475ca..a3d6c06 100755 --- a/config.lua +++ b/config.lua @@ -1,26 +1,46 @@ return { + + -- Your authorization token from the botfather. bot_api_key = '', - google_api_key = '', - google_cse_key = '', - lastfm_api_key = '', - owm_api_key = '', - biblia_api_key = '', - thecatapi_key = '', - nasa_api_key = '', - yandex_key = '', - simsimi_key = '', - simsimi_trial = true, + -- Differences, in seconds, between your time and UTC. time_offset = 0, + -- Two-letter language code. lang = 'en', + -- Your Telegram ID. + admin = 00000000, + -- The channel, group, or user to send error reports to. + -- If this is not set, errors will be printed to the console. + log_chat = nil, + -- The port used to communicate with tg for administration.lua. -- If you change this, make sure you also modify launch-tg.sh. cli_port = 4567, - admin = 00000000, - log_chat = nil, + -- The block of text returned by /start. about_text = [[ -I am otouto, the plugin-wielding, multi-purpose Telegram bot. +I am otouto, the plugin-wielding, multipurpose Telegram bot. Send /help to get started. -]] , + ]], + + -- http://console.developers.google.com + google_api_key = '', + -- https://cse.google.com/cse + google_cse_key = '', + -- http://openweathermap.org/appid + owm_api_key = '', + -- http://last.fm/api + lastfm_api_key = '', + -- http://api.biblia.com + biblia_api_key = '', + -- http://thecatapi.com/docs.html + thecatapi_key = '', + -- http://api.nasa.gov + nasa_api_key = '', + -- http://tech.yandex.com/keys/get/?service=trnsl + yandex_key = '', + -- http://developer.simsimi.com/signUp + simsimi_key = '', + simsimi_trial = true, + errors = { connection = 'Connection error.', results = 'No results found.', @@ -29,37 +49,11 @@ Send /help to get started. chatter_connection = 'I don\'t feel like talking right now.', chatter_response = 'I don\'t know what to say to that.' }, - greetings = { - ['Hello, #NAME.'] = { - 'hello', - 'hey', - 'sup', - 'hi', - 'good morning', - 'good day', - 'good afternoon', - 'good evening' - }, - ['Goodbye, #NAME.'] = { - 'bye', - 'later', - 'see ya', - 'good night' - }, - ['Welcome back, #NAME.'] = { - 'i\'m home', - 'i\'m back' - }, - ['You\'re welcome, #NAME.'] = { - 'thanks', - 'thank you' - } - }, + plugins = { 'control.lua', 'blacklist.lua', 'about.lua', - 'floodcontrol.lua', 'ping.lua', 'whoami.lua', 'nick.lua', @@ -94,4 +88,5 @@ Send /help to get started. 'help.lua', 'greetings.lua' } + } diff --git a/plugins/administration.lua b/plugins/administration.lua index 5b7e7b2..a92bf9e 100644 --- a/plugins/administration.lua +++ b/plugins/administration.lua @@ -1,6 +1,6 @@ --[[ administration.lua - Version 1.8 + Version 1.8.1 Part of the otouto project. © 2016 topkecleon GNU General Public License, version 2 @@ -21,6 +21,8 @@ 1.8 - Group descriptions will be updated automatically. Fixed markdown stuff. Removed /kickme. + 1.8.1 - /rule will return that numbered rule, if it exists. + ]]-- -- Build the administration db if nonexistent. @@ -530,8 +532,8 @@ local commands = { { -- rules triggers = { - '^/rules$', - '^/rules@'..bot.username + '^/rules?', + '^/rules?@'..bot.username }, command = 'rules', @@ -539,12 +541,20 @@ local commands = { interior = true, action = function(msg, group) - local output = 'No rules have been set for ' .. msg.chat.title .. '.' + local output + local input = get_word(msg.text_lower, 2) + input = tonumber(input) if #group.rules > 0 then - output = '*Rules for* _' .. msg.chat.title .. '_ *:*\n' - for i,v in ipairs(group.rules) do - output = output .. '*' .. i .. '.* ' .. v .. '\n' + if input and group.rules[input] then + output = '*' .. input .. '.* ' .. group.rules[input] + else + output = '*Rules for* _' .. msg.chat.title .. '_ *:*\n' + for i,v in ipairs(group.rules) do + output = output .. '*' .. i .. '.* ' .. v .. '\n' + end end + else + output = 'No rules have been set for ' .. msg.chat.title .. '.' end sendMessage(msg.chat.id, output, true, nil, true) end diff --git a/plugins/eightball.lua b/plugins/eightball.lua index 54b8fb1..4c82ef6 100755 --- a/plugins/eightball.lua +++ b/plugins/eightball.lua @@ -45,7 +45,7 @@ local action = function(msg) local message - if msg.text:lower():match('y/n%p?$') then + if msg.text_lower:match('y/n%p?$') then message = yesno_answers[math.random(#yesno_answers)] else message = ball_answers[math.random(#ball_answers)] diff --git a/plugins/greetings.lua b/plugins/greetings.lua index 8964701..29753ae 100755 --- a/plugins/greetings.lua +++ b/plugins/greetings.lua @@ -1,4 +1,35 @@ -- Put this on the bottom of your plugin list, after help.lua. + -- If you want to configure your own greetings, copy the following table + -- (without the "config.") to your config.lua file. + +if not config.greetings then + config.greetings = { + ['Hello, #NAME.'] = { + 'hello', + 'hey', + 'sup', + 'hi', + 'good morning', + 'good day', + 'good afternoon', + 'good evening' + }, + ['Goodbye, #NAME.'] = { + 'bye', + 'later', + 'see ya', + 'good night' + }, + ['Welcome back, #NAME.'] = { + 'i\'m home', + 'i\'m back' + }, + ['You\'re welcome, #NAME.'] = { + 'thanks', + 'thank you' + } + } +end local triggers = { bot.first_name .. '%p*$' diff --git a/plugins/me.lua b/plugins/me.lua index e821fdb..68ece71 100644 --- a/plugins/me.lua +++ b/plugins/me.lua @@ -17,7 +17,7 @@ local action = function(msg) local output = '' for k,v in pairs(target) do - output = output .. '*' .. k .. ':* `' .. v .. '`\n' + output = output .. '*' .. k .. ':* `' .. tostring(v) .. '`\n' end sendMessage(msg.chat.id, output, true, nil, true)