From 7630b437c2612d3c98dcd3aac8d0600cbed60697 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 9 May 2009 18:23:29 +0200 Subject: [PATCH] Converted the invite command, turning it into a real command --- Commands/Channel.pm | 36 ++++++++++++++++++++++++++++++++++++ database/roles.sql | 3 +++ 2 files changed, 39 insertions(+) diff --git a/Commands/Channel.pm b/Commands/Channel.pm index c1a5f7b..117817e 100644 --- a/Commands/Channel.pm +++ b/Commands/Channel.pm @@ -61,4 +61,40 @@ WHERE u.hostmask ILIKE ? AND c.name = ? AND (f.name = '$access' $where); } } +sub invite + :Help(Syntax: invite [channel] | If no channel is specified it invites you to all channel you have auto invite access on) + : Type(pm) +{ + my ($self,$c,$msg) = @_; + + my ($channel) = $msg =~ /^\s*(\S+)?\s*$/ or die 'ARGS'; + + my @channels; + if ($channel && $c->check_user_roles('irc_masterinvite')){ + print "master $channel"; + push @channels,$channel; + }else{ + print "master $channel"; + my @access = ('auto_invite'); + push @access, 'invite' if $channel; + my $channels = $c->model->prepare(q{ +SELECT DISTINCT c.name FROM users u + JOIN groupmembers g ON g.uid = u.uid + JOIN channel_group_flags gf ON g.gid = gf.group + JOIN channels c ON gf.channel = c.id + JOIN channel_flags f ON f.id = gf.flag +WHERE u.hostmask ILIKE $1 AND COALESCE(c.name = $2,TRUE) + AND (f.name = ANY($3) ) + }); + $channels->execute($c->host,$channel,\@access); + while (my ($channel) = $channels->fetchrow()){ + push @channels,$channel; + } + } + for (@channels){ + print; + $c->server->command("invite ". $c->nick ." $_"); + } +} + 1; diff --git a/database/roles.sql b/database/roles.sql index 49de323..9a31ced 100644 --- a/database/roles.sql +++ b/database/roles.sql @@ -1,13 +1,16 @@ INSERT INTO roles VALUES('irc_p_nick'); INSERT INTO roles VALUES('irc_p_intel'); INSERT INTO roles VALUES('irc_masterop'); +INSERT INTO roles VALUES('irc_masterinvite'); INSERT INTO group_roles (gid,role) VALUES(1,'irc_p_nick'); INSERT INTO group_roles (gid,role) VALUES(1,'irc_p_intel'); INSERT INTO group_roles (gid,role) VALUES(1,'irc_masterop'); +INSERT INTO group_roles (gid,role) VALUES(1,'irc_masterinvite'); INSERT INTO group_roles (gid,role) VALUES(3,'irc_p_nick'); INSERT INTO group_roles (gid,role) VALUES(3,'irc_masterop'); +INSERT INTO group_roles (gid,role) VALUES(3,'irc_masterinvite'); INSERT INTO group_roles (gid,role) VALUES(5,'irc_p_nick'); INSERT INTO group_roles (gid,role) VALUES(5,'irc_p_intel'); -- 2.39.2