help.lua and about.lua: /start now triggers about.lua

blacklist.lua: Added username support.
This commit is contained in:
topkecleon 2016-03-04 17:08:21 -05:00
parent ec64f18138
commit f529bc9ad8
11 changed files with 71 additions and 38 deletions

10
.gitignore vendored
View File

@ -1,4 +1,6 @@
plugins/CUSTOM.lua
*.json
lua-tg/*
tg/*
plugins/mokubot.lua
plugins/qtbot.lua
plugins/weeabot.lua
*.db
lua-tg
tg

View File

@ -217,10 +217,20 @@ There are a a few ways to contribute if you are not a programmer. For one, your
Contributions are appreciated in any form. Monetary contributions will go toward server costs. Both programmers and donators will be eternally honored (at their discretion) on this page.
| Developers | Donators |
|:-----------|:---------|
| [Juan Potato](http://github.com/JuanPotato) | [n8](http://telegram.me/n8_c00) |
| [Tiago Danin](http://github.com/TiagoDanin) | [Alex](http://telegram.me/sandu) |
| [Ender](http://github.com/luksireiku) | [Brayden Banks](http://telegram.me/bb010g) |
| Contributors |
|:-----------|
| [Juan Potato](http://github.com/JuanPotato) |
| [Tiago Danin](http://github.com/TiagoDanin) |
| [bb010g](http://github.com/bb010g) |
| [Ender](http://github.com/luksireiku) |
| [Iman Daneshi](http://github.com/Imandaneshi) |
| [HeitorPB](https://github.com/heitorPB) |
| [HeitorPB](http://github.com/heitorPB) |
| [Akronix](http://github.com/Akronix) |
| [Ville](http://github.com/cwxda) |
| [dogtopus](http://github.com/dogtopus) |
| Donators |
|:---------|
| [n8](http://telegram.me/n8_c00) |
| [Alex](http://telegram.me/sandu) |
| [Brayden Banks](http://telegram.me/bb010g) |

View File

@ -114,6 +114,8 @@ forwardMessage = function(chat_id, from_chat_id, message_id, disable_notificatio
end
-- TODO: More of this.
sendPhotoID = function(chat_id, file_id, caption, reply_to_message_id, disable_notification)
local url = BASE_URL .. '/sendPhoto?chat_id=' .. chat_id .. '&photo=' .. file_id
@ -134,8 +136,6 @@ sendPhotoID = function(chat_id, file_id, caption, reply_to_message_id, disable_n
end
-- TODO: More of this.
curlRequest = function(curl_command)
-- Use at your own risk. Will not check for success.

View File

@ -2,5 +2,6 @@
while true; do
lua bot.lua
echo 'otouto has stopped. ^C to exit.'
sleep 5s
done

View File

@ -11,12 +11,15 @@ local action = function(msg)
-- other plugins.
if msg.forward_from then return end
local message = config.about_text .. '\nBased on otouto v'..version..' by topkecleon.\notouto is licensed under the GPLv2.\ngithub.com/topkecleon/otouto'
local message = config.about_text .. '\nBased on @otouto v'..version..' by topkecleon.'
if msg.new_chat_participant and msg.new_chat_participant.id == bot.id then
sendMessage(msg.chat.id, message, true)
return
elseif string.match(msg.text_lower, '^/about[@'..bot.username..']*') then
elseif msg.text_lower:match('^/about[@'..bot.username..']*') then
sendMessage(msg.chat.id, message, true)
return
elseif msg.text_lower:match('^/start') then
sendMessage(msg.chat.id, message, true)
return
end

View File

@ -1,6 +1,6 @@
--[[
administration.lua
Version 1.3
Version 1.4
Part of the otouto project.
© 2016 topkecleon <drew@otou.to>
GNU General Public License, version 2
@ -9,9 +9,10 @@
It requires tg (http://github.com/vysheng/tg) with supergroup support.
For more documentation, view the readme or the manual (otou.to/rtfm).
Important notices about updates will be here!
Remember to load this before blacklist.lua.
Important notices about updates will be here!
The global banlist has been merged with the blacklist. This merge will occur
automatically on versions 1.1 and 1.2.
@ -53,8 +54,7 @@ for k,v in pairs(database.administration) do
end
local sender = dofile('lua-tg/sender.lua')
local tg = sender(localhost, config.cli_port)
local last_admin_cron = os.date('%M', os.time())
tg = sender('localhost', config.cli_port)
local flags = {
[1] = {
@ -208,13 +208,13 @@ local get_desc = function(chat_id)
output = output .. '\n\n*Message of the Day:*\n' .. group.motd
end
if group.rules then
output = output .. '\n\n*Rules:*\n'
output = output .. '\n\n*Rules:*'
for i,v in ipairs(group.rules) do
output = output .. '*' .. i .. '.* ' .. v .. '\n'
output = output .. '\n*' .. i .. '.* ' .. v
end
end
if group.flags then
output = output .. '\n*Flags:*\n'
output = output .. '\n\n*Flags:*\n'
for i = 1, #flags do
if group.flags[i] then
output = output .. '' .. flags[i].short .. '\n'
@ -872,7 +872,7 @@ local commands = {
end
},
{ --degov
{ -- degov
triggers = {
'^/degov[@'..bot.username..']*'
},
@ -1096,13 +1096,13 @@ local commands = {
-- Generate trigger table.
local triggers = {}
for i,v in ipairs(commands) do
for key,val in pairs(v.triggers) do
for ind, val in ipairs(v.triggers) do
table.insert(triggers, val)
end
end
database.administration.global.help = {}
for i,v in pairs(ranks) do
for i,v in ipairs(ranks) do
database.administration.global.help[i] = {}
end
for i,v in ipairs(commands) do
@ -1133,7 +1133,7 @@ local action = function(msg)
end
local cron = function()
tg = sender(localhost, config.cli_port)
tg = sender(localhost, config.cldgmi_port)
end
local command = 'groups'

View File

@ -23,21 +23,38 @@ local triggers = {
return -- End if the user isn't admin.
end
local input = msg.text:input()
if not input then
if msg.reply_to_message then
input = tostring(msg.reply_to_message.from.id)
local target, input
if msg.reply_to_message then
target = msg.reply_to_message.from.id
else
input = msg.text:input()
if input then
input = get_word(input, 1)
if tonumber(input) then
target = input
else
target = resolve_username(input)
if target == nil then
sendReply(msg, 'Sorry, I do not recognize that username.')
return
elseif target == false then
sendReply(msg, 'Invalid ID or username.')
return
end
end
else
sendReply(msg, 'You must use this command via reply or by specifying a user\'s ID.')
sendReply(msg, 'You must use this command via reply or by specifying an ID or username.')
return
end
end
if database.blacklist[input] then
database.blacklist[input] = nil
target = tostring(target)
if database.blacklist[target] then
database.blacklist[target] = nil
sendReply(msg, input .. ' has been removed from the blacklist.')
else
database.blacklist[input] = true
database.blacklist[target] = true
sendReply(msg, input .. ' has been added to the blacklist.')
end

View File

@ -23,7 +23,7 @@ local action = function(msg)
return
end
str = str:match('<img src="(.*)">')
str = str:match('<img src="(.-)">')
local output = '[Cat!]('..str..')'
sendMessage(msg.chat.id, output, false, nil, true)

View File

@ -22,7 +22,7 @@ if not database.hearthstone or os.time() > database.hearthstone.expiration then
database.hearthstone.expiration = os.time() + 600000
print('Download complete! It will be permanently stored.')
print('Download complete! It will be stored for a week.')
end

View File

@ -17,8 +17,7 @@ Arguments: <required> \[optional]
local triggers = {
'^/help[@'..bot.username..']*',
'^/h[@'..bot.username..']*$',
'^/start[@'..bot.username..']*'
'^/h[@'..bot.username..']*$'
}
local action = function(msg)

View File

@ -6,5 +6,6 @@
while true; do
tg/bin/telegram-cli -P 4567 -E
rm ~/.telegram-cli/state
sleep 2s
echo 'tg has stopped. ^C to exit.'
sleep 5s
done