Mercurial > prosody-modules
diff mod_roster_command/mod_roster_command.lua @ 1565:f9cb09d451c7
mod_roster_command: Add 'remove' command
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 10 Nov 2014 11:06:26 +0100 |
parents | 01e37ce7532e |
children | 1f263aaba83e |
line wrap: on
line diff
--- a/mod_roster_command/mod_roster_command.lua Sun Nov 09 20:19:36 2014 +0100 +++ b/mod_roster_command/mod_roster_command.lua Mon Nov 10 11:06:26 2014 +0100 @@ -117,6 +117,14 @@ end end +function remove(user_jid, contact_jid) + unsubscribe_both(user_jid, contact_jid); + local user_username, user_host = jid.split(user_jid); + local roster = rostermanager.load_roster(user_username, user_host); + roster[contact_jid] = nil; + rostermanager.save_roster(user_username, user_host, roster); +end + function module.command(arg) local command = arg[1]; if not command then @@ -136,6 +144,9 @@ elseif command == "unsubscribe_both" then unsubscribe_both(arg[1], arg[2]); return 0; + elseif command == "remove" then + remove(arg[1], arg[2]); + return 0; elseif command == "rename" then rename(arg[1], arg[2], arg[3], arg[4]); return 0;