- my $mode = qq{
-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 ? AND c.name = ? AND (f.name = '$access' $where);
- };
- if ($c->check_user_roles(qw/irc_masterop/)){
- $mode = 1;
- }else{
- ($mode) = $c->model->selectrow_array($mode,undef,$c->host,$c->channel);
+command op => {
+ help => q(syntax: .op [nicks] | Gives op to the specified nicks, or yourself if no command is given),
+ type => q(channel),
+}, $access;
+
+command deop => {
+ help => q(syntax: .deop [nicks] | Removes op from the specified nicks, or yourself if no command is given),
+ type => q(channel),
+}, $access;
+
+command voice => {
+ help => q(syntax: .voice [nicks] | Gives voice to the specified nicks, or yourself if no command is given),
+ type => q(channel),
+}, $access;
+
+command devoice => {
+ help => q(syntax: .voice [nicks] | Removes voice from the specified nicks, or yourself if no command is given),
+ type => q(channel),
+}, $access;
+
+command invite => {
+ help => q(Syntax: invite [channel] | If no channel is specified it invites you to all channel you have auto invite access on),
+ type => q(pm)
+}, class extends NDIRC::Command {
+ method execute ($c,$msg) {
+ my ($channel) = $msg =~ /^\s*(\S+)?\s*$/ or die 'ARGS';
+
+ my @channels;
+ if ($channel && $c->check_user_roles('irc_masterinvite')){
+ push @channels,$channel;
+ }else{
+ my @access = ('i');
+ push @access, 'I' if $channel;
+ my $channels = $c->model->prepare(q{
+SELECT DISTINCT channel FROM users u
+ JOIN groupmembers g USING (uid)
+ JOIN channel_group_flags gf USING (gid)
+WHERE uid = $1 AND COALESCE(channel = $2,TRUE)
+ AND (flag = ANY($3) )
+ });
+ $channels->execute($c->uid,$channel,\@access);
+ while (my ($channel) = $channels->fetchrow()){
+ push @channels,$channel;
+ }
+ }
+ for (@channels){
+ $c->command(invite => $c->nick, $_);
+ }