Username cachine and various fixes.
Usernames seen by the bot are now cached in the $usernames table. To get the ID associated with a username, use the resolve_username() function from utilities.lua. The table_size() function in utilities.lua will tell you the number of items in a key/pair table. about.lua no longer displays a link preview in the about message. currency.lua now accepts decimal arguments for the amount. luarun.lua now correctly displays "false" return values. moderation.lua will no longer send "I do not administrate this group".
This commit is contained in:
@ -10,10 +10,10 @@ local action = function(msg)
|
||||
local message = config.about_text .. '\nBased on otouto v'..version..' by topkecleon.\notouto v3 is licensed under the GPLv2.\ntopkecleon.github.io/otouto'
|
||||
|
||||
if msg.new_chat_participant and msg.new_chat_participant.id == bot.id then
|
||||
sendMessage(msg.chat.id, message)
|
||||
sendMessage(msg.chat.id, message, true)
|
||||
return
|
||||
elseif string.match(msg.text_lower, '^/about[@'..bot.username..']*') then
|
||||
sendMessage(msg.chat.id, message)
|
||||
sendMessage(msg.chat.id, message, true)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -3,6 +3,7 @@ local doc = [[```
|
||||
/cash [amount] <from> to <to>
|
||||
Example: /cash 5 USD to EUR
|
||||
Returns exchange rates for various currencies.
|
||||
Source: Google Finance.
|
||||
```]]
|
||||
|
||||
local triggers = {
|
||||
@ -19,7 +20,8 @@ local action = function(msg)
|
||||
|
||||
local from = input:match('(%a%a%a) TO')
|
||||
local to = input:match('TO (%a%a%a)')
|
||||
local amount = input:match('([%d]+) %a%a%a TO %a%a%a') or 1
|
||||
local amount = get_word(input, 2)
|
||||
amount = tonumber(amount) or 1
|
||||
local result = 1
|
||||
|
||||
local url = 'https://www.google.com/finance/converter'
|
||||
@ -39,12 +41,12 @@ local action = function(msg)
|
||||
return
|
||||
end
|
||||
|
||||
result = str:format('%.2f')
|
||||
result = string.format('%.2f', str)
|
||||
|
||||
end
|
||||
|
||||
local output = amount .. ' ' .. from .. ' = ' .. result .. ' ' .. to .. '\n'
|
||||
output = output .. os.date('!%F %T UTC')
|
||||
local output = amount .. ' ' .. from .. ' = ' .. result .. ' ' .. to .. '\n\n'
|
||||
output = output .. os.date('!%F %T UTC') .. '\nSource: Google Finance'
|
||||
output = '`' .. output .. '`'
|
||||
|
||||
sendMessage(msg.chat.id, output, true, nil, true)
|
||||
|
@ -54,7 +54,7 @@ local action = function(msg)
|
||||
return
|
||||
end
|
||||
|
||||
local output = '*Google: Results for* _' .. input .. '_ *:*\n'
|
||||
local output = '*Google results for* _' .. input .. '_ *:*\n'
|
||||
for i,v in ipairs(jdat.responseData.results) do
|
||||
local title = jdat.responseData.results[i].titleNoFormatting:gsub('%[.+%]', ''):gsub('&', '&')
|
||||
if title:len() > 48 then
|
||||
|
@ -9,7 +9,8 @@ for i,v in ipairs(plugins) do
|
||||
end
|
||||
end
|
||||
|
||||
help_text = help_text .. [[\n
|
||||
help_text = help_text .. [[
|
||||
|
||||
/help <command>
|
||||
Arguments: <required> \[optional]
|
||||
]]
|
||||
|
@ -15,10 +15,12 @@ local action = function(msg)
|
||||
end
|
||||
|
||||
local output = loadstring(input)()
|
||||
if not output then
|
||||
if output == nil then
|
||||
output = 'Done!'
|
||||
elseif type(output) == 'table' then
|
||||
output = 'Done! Table returned.'
|
||||
else
|
||||
output = '```\n' .. output .. '\n```'
|
||||
output = '```\n' .. tostring(output) .. '\n```'
|
||||
end
|
||||
sendMessage(msg.chat.id, output, true, msg.message_id, true)
|
||||
|
||||
|
@ -10,9 +10,7 @@ local commands = {
|
||||
|
||||
['^/modhelp[@'..bot.username..']*$'] = function(msg)
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
if not moddat[msg.chat.id_str] then return end
|
||||
|
||||
local message = [[
|
||||
/modlist - List the moderators and administrators of this group.
|
||||
@ -33,9 +31,7 @@ local commands = {
|
||||
|
||||
['^/modlist[@'..bot.username..']*$'] = function(msg)
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
if not moddat[msg.chat.id_str] then return end
|
||||
|
||||
local message = ''
|
||||
|
||||
@ -113,9 +109,7 @@ local commands = {
|
||||
|
||||
['^/modprom[@'..bot.username..']*$'] = function(msg)
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
if not moddat[msg.chat.id_str] then return end
|
||||
|
||||
if not config.moderation.admins[msg.from.id_str] then
|
||||
return config.errors.not_admin
|
||||
@ -145,9 +139,7 @@ local commands = {
|
||||
|
||||
['^/moddem[@'..bot.username..']*'] = function(msg)
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
if not moddat[msg.chat.id_str] then return end
|
||||
|
||||
if not config.moderation.admins[msg.from.id_str] then
|
||||
return config.errors.not_admin
|
||||
@ -181,9 +173,7 @@ local commands = {
|
||||
|
||||
['/modkick[@'..bot.username..']*'] = function(msg)
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
if not moddat[msg.chat.id_str] then return end
|
||||
|
||||
if not moddat[msg.chat.id_str][msg.from.id_str] then
|
||||
if not config.moderation.admins[msg.from.id_str] then
|
||||
@ -215,9 +205,7 @@ local commands = {
|
||||
|
||||
['^/modban[@'..bot.username..']*'] = function(msg)
|
||||
|
||||
if not moddat[msg.chat.id_str] then
|
||||
return config.errors.moderation
|
||||
end
|
||||
if not moddat[msg.chat.id_str] then return end
|
||||
|
||||
if not moddat[msg.chat.id_str][msg.from.id_str] then
|
||||
if not config.moderation.admins[msg.from.id_str] then
|
||||
|
@ -30,7 +30,7 @@ local action = function(msg)
|
||||
source = '*/r/' .. input:match('^r/(.+)') .. '*\n'
|
||||
else
|
||||
url = 'http://www.reddit.com/search.json?q=' .. input .. '&limit=' .. limit
|
||||
source = '*reddit: Results for* _' .. input .. '_ *:*\n'
|
||||
source = '*reddit results for* _' .. input .. '_ *:*\n'
|
||||
end
|
||||
else
|
||||
url = 'http://www.reddit.com/.json?limit=' .. limit
|
||||
|
Reference in New Issue
Block a user