Page MenuHomePhabricator (Chris)

addrule.lua
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

addrule.lua

--[[
Copyright 2020 Matthew Hesketh <matthew@matthewhesketh.com>
This code is licensed under the MIT. See LICENSE for details.
]]
local addrule = {}
local mattata = require('mattata')
function addrule:init()
addrule.commands = mattata.commands(self.info.username):command('addrule').table
addrule.help = '/addrule <text> - Allows you to add another group rule!'
end
function addrule.on_message(_, message, _, language)
if message.chat.type == 'private' then return false end
if not mattata.is_group_admin(message.chat.id, message.from.id) then
return mattata.send_reply(message, language.errors.admin)
end
local input = mattata.input(message.text)
if not input then
return mattata.send_reply(message, language['addrule']['1'])
end
local rules = mattata.get_value(message.chat.id, 'rules')
if not rules then
return mattata.send_reply(message, language['addrule']['2'])
end
local new_rules = rules .. '\n' .. input
local success = mattata.send_message(message.chat.id, new_rules, 'markdown')
if not success and utf8.len(new_rules) > 4096 then
return mattata.send_reply(message, language['addrule']['3'])
elseif not success then
return mattata.send_reply(message, language['addrule']['4'])
end
mattata.set_value(message.chat.id, 'rules', new_rules)
return mattata.edit_message_text(message.chat.id, success.result.message_id, language['addrule']['5'])
end
return addrule

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 15, 5:26 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
129135
Default Alt Text
addrule.lua (1 KB)

Event Timeline