2016-07-17 13:22:27 +02:00
|
|
|
local entergroup = {}
|
|
|
|
|
|
|
|
entergroup.triggers = {
|
2016-08-03 19:05:05 +02:00
|
|
|
'^//tgservice (new_chat_member)$',
|
|
|
|
'^//tgservice (left_chat_member)$'
|
2016-07-17 13:22:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function entergroup:chat_new_user(msg, self)
|
|
|
|
local user_name = msg.new_chat_member.first_name
|
|
|
|
local chat_title = msg.chat.title
|
|
|
|
if msg.from.username then
|
|
|
|
at_name = ' (@'..msg.from.username..')'
|
|
|
|
else
|
|
|
|
at_name = ''
|
|
|
|
end
|
|
|
|
if msg.from.id == msg.new_chat_member.id then -- entered through link
|
|
|
|
added_by = ''
|
|
|
|
else
|
|
|
|
added_by = '\n'..msg.from.name..at_name..' hat dich hinzugefügt!'
|
|
|
|
end
|
|
|
|
if msg.new_chat_member.id == self.info.id then -- don't say hello to ourselves
|
|
|
|
return
|
|
|
|
end
|
2016-08-04 13:44:56 +02:00
|
|
|
local text = 'Hallo '..user_name..', willkommen bei <b>'..chat_title..'</b>!'..added_by
|
|
|
|
utilities.send_reply(self, msg, text, 'HTML')
|
2016-07-17 13:22:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function entergroup:chat_del_user(msg, self)
|
|
|
|
if msg.left_chat_member.id == msg.from.id then -- silent ignore, if user wasn't kicked
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local user_name = msg.left_chat_member.first_name
|
|
|
|
if msg.from.username then
|
|
|
|
at_name = ' (@'..msg.from.username..')'
|
|
|
|
else
|
|
|
|
at_name = ''
|
|
|
|
end
|
2016-08-04 13:44:56 +02:00
|
|
|
local text = '<b>'..user_name..'</b> wurde von <b>'..msg.from.first_name..'</b>'..at_name..' aus der Gruppe gekickt.'
|
|
|
|
utilities.send_reply(self, msg, text, 'HTML')
|
2016-07-17 13:22:27 +02:00
|
|
|
end
|
|
|
|
|
2016-08-03 19:05:05 +02:00
|
|
|
function entergroup:action(msg, config, matches)
|
|
|
|
if not is_service_msg(msg) then return end -- Bad attempt at trolling!
|
|
|
|
|
|
|
|
if matches[1] == 'new_chat_member' then
|
2016-07-17 13:22:27 +02:00
|
|
|
entergroup:chat_new_user(msg, self)
|
2016-08-03 19:05:05 +02:00
|
|
|
elseif matches[1] == 'left_chat_member'then
|
2016-07-17 13:22:27 +02:00
|
|
|
entergroup:chat_del_user(msg, self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-03 19:05:05 +02:00
|
|
|
return entergroup
|