I guess there were more changes last commit.

utilities change should make them work.
This commit is contained in:
topkecleon 2016-05-20 03:38:43 -04:00
parent a786beada6
commit 64621a640e
3 changed files with 33 additions and 26 deletions

View File

@ -24,9 +24,9 @@ function echo:action(msg)
if msg.chat.type == 'supergroup' then if msg.chat.type == 'supergroup' then
output = '*Echo:*\n"' .. utilities.md_escape(input) .. '"' output = '*Echo:*\n"' .. utilities.md_escape(input) .. '"'
else else
output = utilities.md_escape(utilities.latcyr(input)) output = utilities.md_escape(utilities.char.zwnj..input)
end end
bindings.sendMessage(self, msg.chat.id, output, true) bindings.sendMessage(self, msg.chat.id, output, true, nil, true)
end end

View File

@ -96,37 +96,35 @@ local slaps = {
'Death is when the monsters get you. Death comes for VICTIM.', 'Death is when the monsters get you. Death comes for VICTIM.',
'Cowards die many times before their death. VICTIM never tasted death but once.', 'Cowards die many times before their death. VICTIM never tasted death but once.',
'VICTIM died of hospital gangrene.', 'VICTIM died of hospital gangrene.',
'VICTIM got a house call from Doctor VICTOR.' 'VICTIM got a house call from Doctor VICTOR.',
'VICTOR beheaded VICTIM.',
'VICTIM got stoned...by an angry mob.',
'VICTOR sued the pants off VICTIM.',
'VICTIM was impeached.',
'VICTIM was one-hit KO\'d by VICTOR.',
'VICTOR sent VICTIM to /dev/null.',
'VICTOR sent VICTIM down the memory hole.'
} }
function slap:action(msg) function slap:action(msg)
local victim = utilities.input(msg.text) local victor = self.database.users[msg.from.id_str]
if msg.reply_to_message then local victim = utilities.user_from_message(self, msg, true)
if self.database.users[tostring(msg.reply_to_message.from.id)].nickname then local input = utilities.input(msg.text)
victim = self.database.users[tostring(msg.reply_to_message.from.id)].nickname
else local victim_name = victim.nickname or victim.first_name or input
victim = msg.reply_to_message.from.first_name local victor_name = victor.nickname or victor.first_name
end if not victim_name or victim_name == victor_name then
victim_name = victor_name
victor_name = self.info.first_name
end end
local victor = msg.from.first_name local output = slaps[math.random(#slaps)]
if self.database.users[msg.from.id_str].nickname then output = output:gsub('VICTIM', victim_name)
victor = self.database.users[msg.from.id_str].nickname output = output:gsub('VICTOR', victor_name)
end output = utilities.char.zwnj .. output
if not victim then bindings.sendMessage(self, msg.chat.id, output)
victim = victor
victor = self.info.first_name
end
local message = slaps[math.random(#slaps)]
message = message:gsub('VICTIM', victim)
message = message:gsub('VICTOR', victor)
message = utilities.latcyr(message)
bindings.sendMessage(self, msg.chat.id, message)
end end

View File

@ -332,4 +332,13 @@ function utilities:create_user_entry(user)
end end
end end
-- This table will store unsavory characters that are not properly displayed,
-- or are just not fun to type.
utilities.char = {
zwnj = '',
arabic = '[\216-\219][\128-\191]',
rtl = '',
flush_right = ''
}
return utilities return utilities