diff --git a/plugins/echo.lua b/plugins/echo.lua index 93f3ec2..5d5d1ca 100755 --- a/plugins/echo.lua +++ b/plugins/echo.lua @@ -24,9 +24,9 @@ function echo:action(msg) if msg.chat.type == 'supergroup' then output = '*Echo:*\n"' .. utilities.md_escape(input) .. '"' else - output = utilities.md_escape(utilities.latcyr(input)) + output = utilities.md_escape(utilities.char.zwnj..input) end - bindings.sendMessage(self, msg.chat.id, output, true) + bindings.sendMessage(self, msg.chat.id, output, true, nil, true) end diff --git a/plugins/slap.lua b/plugins/slap.lua index b677889..6a0af3f 100755 --- a/plugins/slap.lua +++ b/plugins/slap.lua @@ -96,37 +96,35 @@ local slaps = { 'Death is when the monsters get you. Death comes for VICTIM.', 'Cowards die many times before their death. VICTIM never tasted death but once.', '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) - local victim = utilities.input(msg.text) - if msg.reply_to_message then - if self.database.users[tostring(msg.reply_to_message.from.id)].nickname then - victim = self.database.users[tostring(msg.reply_to_message.from.id)].nickname - else - victim = msg.reply_to_message.from.first_name - end + local victor = self.database.users[msg.from.id_str] + local victim = utilities.user_from_message(self, msg, true) + local input = utilities.input(msg.text) + + local victim_name = victim.nickname or victim.first_name or input + local victor_name = victor.nickname or victor.first_name + if not victim_name or victim_name == victor_name then + victim_name = victor_name + victor_name = self.info.first_name end - local victor = msg.from.first_name - if self.database.users[msg.from.id_str].nickname then - victor = self.database.users[msg.from.id_str].nickname - end + local output = slaps[math.random(#slaps)] + output = output:gsub('VICTIM', victim_name) + output = output:gsub('VICTOR', victor_name) + output = utilities.char.zwnj .. output - if not victim then - 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) + bindings.sendMessage(self, msg.chat.id, output) end diff --git a/utilities.lua b/utilities.lua index 3a865d0..326b967 100755 --- a/utilities.lua +++ b/utilities.lua @@ -332,4 +332,13 @@ function utilities:create_user_entry(user) 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