diff --git a/src/Console/Console.php b/src/Console/Console.php index c56179ab..2d8b89c0 100644 --- a/src/Console/Console.php +++ b/src/Console/Console.php @@ -51,6 +51,7 @@ public static function isWin() */ public function log($str, $level = 'INFO', $log = false) { + $str = $this->vbot->lang->get($str); if ($this->isOutput()) { if ($log && in_array($level, array_keys(Logger::getLevels()))) { $this->vbot->log->log($level, $str); diff --git a/src/Core/Server.php b/src/Core/Server.php index 6975ba33..95a324b5 100644 --- a/src/Core/Server.php +++ b/src/Core/Server.php @@ -319,4 +319,11 @@ protected function generateSyncKey($result, $first) $this->vbot->config['server.syncKeyStr'] = implode('|', $syncKey); } + /** + * logout wechat + */ + protected function logout(){ + $url = 'https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxlogout?redirect=1&type=0&skey='.$this->vbot->config['server.skey']; + $this->vbot->http->post($url, ['sid'=>$this->vbot->config['server.sid'], 'uin'=>$this->vbot->config['server.uin']]); + } } diff --git a/src/Foundation/ServiceProviders/LangServiceProvider.php b/src/Foundation/ServiceProviders/LangServiceProvider.php new file mode 100644 index 00000000..edac3048 --- /dev/null +++ b/src/Foundation/ServiceProviders/LangServiceProvider.php @@ -0,0 +1,20 @@ +singleton('lang', function () use ($vbot) { + return new Lang($vbot); + }); + } +} diff --git a/src/Foundation/Vbot.php b/src/Foundation/Vbot.php index b9638865..a4f45877 100644 --- a/src/Foundation/Vbot.php +++ b/src/Foundation/Vbot.php @@ -67,6 +67,7 @@ class Vbot extends Container ServiceProviders\ContactServiceProvider::class, ServiceProviders\ApiServiceProvider::class, ServiceProviders\ExtensionServiceProvider::class, + ServiceProviders\LangServiceProvider::class ]; public function __construct(array $config) diff --git a/src/Languages/zh_CN.php b/src/Languages/zh_CN.php new file mode 100644 index 00000000..d0fa73c8 --- /dev/null +++ b/src/Languages/zh_CN.php @@ -0,0 +1,24 @@ + '下载到文件失败。', + 'checkSync no response' => 'checkSync接口无返回信息。', + 'cleaning useless cookies.' => '正在清理无用的Cookie信息。', + 'please scan the qrCode with wechat.' => '请使用手机微信扫描二维码。', + 'please confirm login in wechat.' => '请在手机微信上确认登录。', + 'login time out!' => '登录超时!', + 'current session:' => '当前Session ID:', + 'init begin.' => '开始初始化。', + 'init success.' => '初始化完成。', + 'init contacts begin.' => '开始初始化联系人列表。', + 'vbot exit normally.' => 'VBOT已正常退出。', + 'current user\'s nickname:' => '当前登录账户的昵称:', + 'current user\'s username:' => '当前登录账户的用户名:', + 'current user\'s uin:' => '当前登录账户的UIN:', + 'Argument pass error.' => '缺少必要参数。', + 'Ticket error.' => 'pass_ticket错误。', + 'Logout.' => '微信已退出。', + 'Cookies invalid.' => 'Cookie验证错误。', + 'Api frequency.' => 'API调用频繁。', + 'download file failed.' => '下载文件失败。', + 'emoticon path not set.' => '未设置表情库路径。' +]; diff --git a/src/Support/Lang.php b/src/Support/Lang.php new file mode 100644 index 00000000..15c4f8e0 --- /dev/null +++ b/src/Support/Lang.php @@ -0,0 +1,22 @@ +vbot = $vbot; + } + public function get($msg){ + if (empty($this->languages)){ + $langFilePath = dirname(__DIR__).'/Languages/'.$this->vbot->config['lang'].'.php'; + if(file_exists($langFilePath)){ + $this->languages = require_once $langFilePath; + } + } + return isset($this->languages[$msg])?$this->languages[$msg]:$msg; + } + public function setType($type){ + $this->type = $type; + } +}