X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FChannel.pm;h=117817e09bc4792b55ecb238fb62ee60e5503ac4;hb=5f3e2c69d303e9196a76dd10607b595cac6658a8;hp=c1a5f7b5f405a864f0acb1d961f5faae22d14590;hpb=7091b004eee879d36792d6da3b8fd4fb1b5f71bf;p=NDIRC.git 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;