Skip to content

Commit

Permalink
update config mode
Browse files Browse the repository at this point in the history
  • Loading branch information
baiyutang committed Jun 23, 2020
1 parent 14acfdc commit 6e755ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
> 2. `src/config.php` 文件中 `$groups` 数组中,修改钉钉群机器人为推送的目标群 token
> 3. 参照示例组装代码
## 配置钉钉群的两种方式
* 修改 `Config.php` 文件中数组,配置 array('group_name'=>'...your token...'),然后 `$client = new ChatBot('group_name')`;
* 支持直接指定token,当 `$client = new ChatBot('param')`,当构造函数接收到的参数不在 `Config.php``$groups` 数组种的键中,会被认定是一个 token

## 示例
```php
// text 类型
Expand Down
5 changes: 2 additions & 3 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
class Config
{
/**
* TODO: 这里要替换成自己的机器人token
* @var static array $groups token配置组
*/
public static $groups = array(
'default' => '9721a7444fbea2032eb316c9e40fe8c27df8ae3178ca514d0e9b47386d97f4c0',
'other' => '9721a7444fbea2032eb316c9e40fe8c27df8ae3178ca514d0e9b47386d97f4c0',
'default' => '***',
'other' => '***',
);
}
6 changes: 3 additions & 3 deletions src/GroupChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public function getToken()
}

/**
* @param string $name
* @param string $param
*/
private function setToken($name)
private function setToken($param)
{
$this->token = Config::$groups[$name];
$this->token = isset(Config::$groups[$param]) ? Config::$groups[$param] : $param;
}
}

0 comments on commit 6e755ea

Please sign in to comment.