| 1 |
# xmpp-admin.pl |
| 2 |
#copy into .irssi/scripts |
| 3 |
#load in irssi with: /script load xmpp-admin |
| 4 |
use Irssi; |
| 5 |
|
| 6 |
$::VERSION='0.0.1'; |
| 7 |
%::IRSSI = ( |
| 8 |
authors => 'Seth Difley', |
| 9 |
contact => '', |
| 10 |
name => 'xmpp-admin', |
| 11 |
description => 'Adds admin commands to irssi-xmpp', |
| 12 |
url => '', |
| 13 |
license => 'GNU General Public License', |
| 14 |
changed => '$Date$' |
| 15 |
); |
| 16 |
|
| 17 |
#/affiliate affiliation_level [jid] |
| 18 |
#If jid is absent, the affiliation list is returned (Raw xml messages must be active to see the list.) |
| 19 |
sub cmd_affiliate { |
| 20 |
my ($data,$server,$wid) = @_; |
| 21 |
@items = split(" ", $data); |
| 22 |
if ($items[0]) { |
| 23 |
if ($items[1]) { |
| 24 |
$affil = "QUOTE <iq type=\'set\' id=\'affiliate_set\' to=\'$wid->{name}\'> <query xmlns=\'http://jabber.org/protocol/muc#admin\'> <item jid=\'$items[1]\' affiliation=\'$items[0]\'/> </query> </iq>"; |
| 25 |
} |
| 26 |
else { |
| 27 |
$affil = "QUOTE <iq type=\'get\' id=\'affiliate_get\' to=\'$wid->{name}\'> <query xmlns=\'http://jabber.org/protocol/muc#admin\'> <item affiliation=\'$items[0]\'/> </query> </iq>"; |
| 28 |
} |
| 29 |
$server->command("$affil"); |
| 30 |
} |
| 31 |
else { |
| 32 |
Irssi::active_win()->print("/affiliate none|owner|admin|member|outcast [jid]"); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
#/role role_level nickname [reason] |
| 37 |
sub cmd_role { |
| 38 |
my ($data,$server,$wid) = @_; |
| 39 |
@items = split(" ", $data); |
| 40 |
if ($items[1]) { |
| 41 |
if ($items[2]) { |
| 42 |
$data =~ s/^.*?[\s]+.*?[\s]+//; |
| 43 |
$reason = "<reason>$data</reason>"; |
| 44 |
} |
| 45 |
else { |
| 46 |
$reason = ""; |
| 47 |
} |
| 48 |
$role = "QUOTE <iq type=\'set\' id=\'role_set\' to=\'$wid->{name}\'> <query xmlns=\'http://jabber.org/protocol/muc#admin\'> <item nick=\'$items[1]\' role=\'$items[0]\'> $reason </item> </query> </iq>"; |
| 49 |
$server->command("$role"); |
| 50 |
} |
| 51 |
else { |
| 52 |
Irssi::active_win()->print("/role none|moderator|participant|visitor nickname [reason]"); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
#/kick nickname [reason] |
| 57 |
sub cmd_kick { |
| 58 |
my ($data,$server,$wid) = @_; |
| 59 |
@items = split(" ", $data); |
| 60 |
if ($items[0]) { |
| 61 |
cmd_role("none " . $data,$server,$wid); |
| 62 |
} |
| 63 |
else { |
| 64 |
Irssi::active_win()->print("/kick nickname [reason]"); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
Irssi::command_bind('affiliate', \&cmd_affiliate); |
| 69 |
Irssi::command_bind('role', \&cmd_role); |
| 70 |
Irssi::command_bind('kick', \&cmd_kick); |