Making WordPress.org


Ignore:
Timestamp:
07/26/2015 07:07:47 PM (9 years ago)
Author:
nacin
Message:

Slack: Add a /committers command to replace @committers by merging it with /announce.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/slack/announce/lib.php

    r1738 r1788  
    6767    }
    6868
    69     if ( ! is_user_whitelisted( $user, $channel ) ) {
    70         return;
     69    if ( $data['command'] === '/committers' ) {
     70        $committers = get_committers();
     71        if ( ! in_array( $user, $committers, true ) ) {
     72            return;
     73        }
     74
     75        $text = sprintf( "*@committers:* %s\n_(cc: %s)_", $data['text'], '@' . implode( ', @', $committers ) );
     76    } else {
     77        if ( ! is_user_whitelisted( $user, $channel ) ) {
     78            return;
     79        }
     80
     81        $command = 'channel';
     82        if ( $data['command'] === '/here' ) {
     83            $command = 'here';
     84        } elseif ( $channel === 'privategroup' ) {
     85            // @channel and @group are interchangeable, but still.
     86            $command = 'group';
     87        }
     88
     89        $text = sprintf( "<!%s> %s", $command, $data['text'] );
    7190    }
    7291
    7392    $send = new Send( \Dotorg\Slack\Send\WEBHOOK );
    7493    $send->set_username( $user );
    75 
    76     $command = 'channel';
    77     if ( $data['command'] === '/here' ) {
    78         $command = 'here';
    79     } elseif ( $channel === 'privategroup' ) {
    80         // @channel and @group are interchangeable, but still.
    81         $command = 'group';
    82     }
    83 
    84     $send->set_text( sprintf( "<!%s> %s", $command, $data['text'] ) );
     94    $send->set_text( $text );
    8595
    8696    $get_avatar = __NAMESPACE__ . '\\' . 'get_avatar';
Note: See TracChangeset for help on using the changeset viewer.