Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Console/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/Core/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']]);
}
}
20 changes: 20 additions & 0 deletions src/Foundation/ServiceProviders/LangServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Hanson\Vbot\Foundation\ServiceProviders;

use Hanson\Vbot\Foundation\ServiceProviderInterface;
use Hanson\Vbot\Foundation\Vbot;
use Hanson\Vbot\Support\Lang;

class LangServiceProvider implements ServiceProviderInterface
{
/**
* @param \Hanson\Vbot\Foundation\Vbot $vbot
*/
public function register(Vbot $vbot)
{
$vbot->singleton('lang', function () use ($vbot) {
return new Lang($vbot);
});
}
}
1 change: 1 addition & 0 deletions src/Foundation/Vbot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions src/Languages/zh_CN.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
return [
'dump file success.' => '下载到文件失败。',
'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.' => '未设置表情库路径。'
];
22 changes: 22 additions & 0 deletions src/Support/Lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace Hanson\Vbot\Support;
use Hanson\Vbot\Foundation\Vbot;
class Lang{
private $languages;
protected $vbot;
public function __construct(Vbot $vbot){
$this->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;
}
}