Final fixes.

This commit is contained in:
Brayden Banks
2016-04-13 20:48:20 -07:00
parent 80930f389c
commit 1dc61d2c44
16 changed files with 105 additions and 92 deletions

View File

@ -324,7 +324,7 @@ function administration.init_command(self_)
if self.admin_temp.flood[msg.chat.id_str][msg.from.id_str] > 99 then
drua.kick_user(msg.chat.id, msg.from.id)
local output = administration.flags[5].kicked:gsub('GROUPNAME', msg.chat.title)
bindings.sendMessage(msg.from.id, output)
bindings.sendMessage(self, msg.from.id, output)
self.admin_temp.flood[msg.chat.id_str][msg.from.id_str] = nil
return
end
@ -372,7 +372,7 @@ function administration.init_command(self_)
else
group.name = msg.new_chat_title
if group.grouptype == 'supergroup' then
administration.update_desc(msg.chat.id)
administration.update_desc(self, msg.chat.id)
end
end
return
@ -799,7 +799,7 @@ function administration.init_command(self_)
local status = group.flags[i] or false
output = output .. '`[' .. i .. ']` *' .. v.name .. '*` = ' .. tostring(status) .. '`\n' .. v.desc .. '\n'
end
bindings.sendMessage(msg.chat.id, output, true, nil, true)
bindings.sendMessage(self, msg.chat.id, output, true, nil, true)
return
end
if group.flags[input] == true then
@ -987,7 +987,7 @@ function administration.init_command(self_)
action = function(self, msg)
if self.database.administration.groups[msg.chat.id_str] then
bindings.sendReply(msg, 'I am already administrating this group.')
bindings.sendReply(self, msg, 'I am already administrating this group.')
return
end
self.database.administration.groups[msg.chat.id_str] = {

View File

@ -10,7 +10,7 @@ Repeats a string of text.
```]]
function echo:init()
echo.triggers = utilities.triggers(self.info.username):t('echo').table
echo.triggers = utilities.triggers(self.info.username):t('echo', true).table
end
function echo:action(msg)

View File

@ -6,24 +6,27 @@ local help = {}
local bindings = require('bindings')
local utilities = require('utilities')
local help_text = '*Available commands:*'
local help_text
function help:init()
help_text = '*Available commands:*'
for _,plugin in ipairs(self.plugins) do
if plugin.command then
help_text = help_text .. '\n• /' .. plugin.command:gsub('%[', '\\[')
end
end
help.triggers = utilities.triggers(self.info.username):t('help', true):t('h', true).table
end
help_text = help_text .. [[
help_text = help_text .. [[
• /help <command>
Arguments: <required> \[optional]
]]
help.triggers = utilities.triggers(self.info.username):t('help', true):t('h', true).table
end
function help:action(msg)
local input = utilities.input(msg.text_lower)

View File

@ -19,7 +19,7 @@ function luarun:action(msg)
return
end
local output = loadstring(input)()
local output = loadstring('local utilities = require(\'utilities\'); return function (instance) '..input..' end')()(self)
if output == nil then
output = 'Done!'
elseif type(output) == 'table' then

View File

@ -268,12 +268,12 @@ function moderation:init()
moderation.triggers = {}
for trigger,_ in pairs(commands) do
if trigger[-1] == '$' then
moderation.triggers:insert(trigger:sub(1, -2)..'@'..self.info.username..'$')
tables.insert(moderation.triggers, trigger:sub(1, -2)..'@'..self.info.username..'$')
else
moderation.triggers:insert(trigger..'%s+[^%s]*')
moderation.triggers:insert(trigger..'@'..self.info.username..'%s+[^%s]*')
moderation.triggers:insert(trigger..'$')
moderation.triggers:insert(trigger..'@'..self.info.username..'$')
tables.insert(moderation.triggers, trigger..'%s+[^%s]*')
tables.insert(moderation.triggers, trigger..'@'..self.info.username..'%s+[^%s]*')
tables.insert(moderation.triggers, trigger..'$')
tables.insert(moderation.triggers, trigger..'@'..self.info.username..'$')
end
end
end

View File

@ -10,7 +10,7 @@ Set your nickname. Use "/nick --" to delete it.
```]]
function nick:init()
nick.triggers = utilities.triggers(self.info.nick):t('nick', true).table
nick.triggers = utilities.triggers(self.info.username):t('nick', true).table
end
function nick:action(msg)

View File

@ -28,8 +28,8 @@ function reactions:init()
reactions.triggers = utilities.triggers(self.info.username):t('reactions').table
for trigger,reaction in pairs(mapping) do
help = help .. '' .. trigger:gsub('.%?', '') .. ': ' .. reaction .. '\n'
reactions.triggers:insert(utilities.INVOCATION_PATTERN..trigger)
reactions.triggers:insert(utilities.INVOCATION_PATTERN..trigger..'@'..self.username)
table.insert(reactions.triggers, utilities.INVOCATION_PATTERN..trigger)
table.insert(reactions.triggers, utilities.INVOCATION_PATTERN..trigger..'@'..self.username)
end
end

View File

@ -4,7 +4,7 @@ local bindings = require('bindings')
local utilities = require('utilities')
function shell:init()
shell.triggers = utilities.bindings(self.info.username):t('run', true).table
shell.triggers = utilities.triggers(self.info.username):t('run', true).table
end
function shell:action(msg)

View File

@ -43,7 +43,9 @@ function time:action(msg)
local jdat = JSON.decode(jstr)
local timestamp = os.time() + jdat.rawOffset + jdat.dstOffset + self.config.time_offset
local now = os.time()
local time_offset = os.difftime(now, os.time(os.date("!*t", now)))
local timestamp = now + jdat.rawOffset + jdat.dstOffset + time_offset
local utcoff = (jdat.rawOffset + jdat.dstOffset) / 3600
if utcoff == math.abs(utcoff) then
utcoff = '+' .. utcoff

View File

@ -17,7 +17,7 @@ function whoami:action(msg)
if msg.reply_to_message then
msg = msg.reply_to_message
msg.from.name = utilities.build_name(self, msg.from.first_name, msg.from.last_name)
msg.from.name = utilities.build_name(msg.from.first_name, msg.from.last_name)
end
local chat_id = math.abs(msg.chat.id)