Making WordPress.org

Changeset 1788


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.

Location:
sites/trunk/common/includes/slack
Files:
3 edited

Legend:

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

    r1766 r1788  
    8787    );
    8888}
     89
     90function get_committers() {
     91    return array(
     92        'dd32', 'nacin', 'mark', 'helen', 'azaozz', 'westi',
     93        'nb', 'sergey', 'ocean90', 'wonderboymusic', 'drew', 'johnbillion',
     94        'jorbin', 'boone', 'jeremyfelt', 'pento', 'obenland', 'iseulde',
     95        'westonruter',
     96    );
     97}
     98
  • 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';
  • sites/trunk/common/includes/slack/send.php

    r1121 r1788  
    7777            'username'    => $this->get_username(),
    7878            'attachments' => $this->get_attachments(),
     79            'link_names'  => 1,
    7980        );
    8081
Note: See TracChangeset for help on using the changeset viewer.