Commit df696b4f by HanSon

修改命名空间

1 parent c77778a2
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
"src/Support/helpers.php" "src/Support/helpers.php"
], ],
"psr-4": { "psr-4": {
"Hanson\\Robot\\": "src/" "Hanson\\Vbot\\": "src/"
} }
}, },
"require-dev": { "require-dev": {
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Text; use Hanson\Vbot\Message\Entity\Text;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Message; use Hanson\Vbot\Message\Message;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Message; use Hanson\Vbot\Message\Message;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Text; use Hanson\Vbot\Message\Entity\Text;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Message; use Hanson\Vbot\Message\Message;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Message; use Hanson\Vbot\Message\Message;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Message; use Hanson\Vbot\Message\Message;
use Hanson\Robot\Message\Image; use Hanson\Vbot\Message\Image;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -8,21 +8,21 @@ ...@@ -8,21 +8,21 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Entity\Message; use Hanson\Vbot\Message\Entity\Message;
use Hanson\Robot\Message\Entity\Image; use Hanson\Vbot\Message\Entity\Image;
use Hanson\Robot\Message\Entity\Text; use Hanson\Vbot\Message\Entity\Text;
use Hanson\Robot\Message\Entity\Emoticon; use Hanson\Vbot\Message\Entity\Emoticon;
use Hanson\Robot\Message\Entity\Location; use Hanson\Vbot\Message\Entity\Location;
use Hanson\Robot\Message\Entity\Video; use Hanson\Vbot\Message\Entity\Video;
use Hanson\Robot\Message\Entity\Voice; use Hanson\Vbot\Message\Entity\Voice;
use Hanson\Robot\Message\Entity\Recall; use Hanson\Vbot\Message\Entity\Recall;
use Hanson\Robot\Message\Entity\RedPacket; use Hanson\Vbot\Message\Entity\RedPacket;
use Hanson\Robot\Message\Entity\Transfer; use Hanson\Vbot\Message\Entity\Transfer;
use Hanson\Robot\Message\Entity\Recommend; use Hanson\Vbot\Message\Entity\Recommend;
use Hanson\Robot\Message\Entity\Share; use Hanson\Vbot\Message\Entity\Share;
use Hanson\Robot\Message\Entity\Touch; use Hanson\Vbot\Message\Entity\Touch;
use Hanson\Robot\Message\Entity\RequestFriend; use Hanson\Vbot\Message\Entity\RequestFriend;
$path = __DIR__ . '/./../tmp/'; $path = __DIR__ . '/./../tmp/';
$robot = new Robot([ $robot = new Robot([
...@@ -41,6 +41,7 @@ $robot->server->setMessageHandler(function ($message) use ($path) { ...@@ -41,6 +41,7 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
// 文字信息 // 文字信息
if ($message instanceof Text) { if ($message instanceof Text) {
// 联系人自动回复 // 联系人自动回复
print_r($message);
if ($message->fromType === 'Contact') { if ($message->fromType === 'Contact') {
return http()->post('http://www.tuling123.com/openapi/api', [ return http()->post('http://www.tuling123.com/openapi/api', [
...@@ -148,9 +149,12 @@ $robot->server->setMessageHandler(function ($message) use ($path) { ...@@ -148,9 +149,12 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
// 手机点击聊天事件 // 手机点击聊天事件
if($message instanceof Touch){ if($message instanceof Touch){
print_r($message);
Text::send($message->to['UserName'], "我点击了此群"); Text::send($message->to['UserName'], "我点击了此群");
} }
return false;
}); });
$robot->server->run(); $robot->server->run();
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Message; use Hanson\Vbot\Message\Message;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Message; use Hanson\Vbot\Message\Message;
use Hanson\Robot\Message\Image; use Hanson\Vbot\Message\Image;
use Hanson\Robot\Message\Text; use Hanson\Vbot\Message\Entity\Text;
use Hanson\Robot\Message\Emoticon; use Hanson\Vbot\Message\Emoticon;
use Hanson\Robot\Message\Video; use Hanson\Vbot\Message\Video;
$path = __DIR__ . '/./../tmp/'; $path = __DIR__ . '/./../tmp/';
$robot = new Robot([ $robot = new Robot([
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
require_once __DIR__ . './../vendor/autoload.php'; require_once __DIR__ . './../vendor/autoload.php';
use Hanson\Robot\Foundation\Robot; use Hanson\Vbot\Foundation\Robot;
use Hanson\Robot\Message\Message; use Hanson\Vbot\Message\Message;
$robot = new Robot([ $robot = new Robot([
'tmp' => __DIR__ . '/./../tmp/', 'tmp' => __DIR__ . '/./../tmp/',
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 20:56 * Time: 20:56
*/ */
namespace Hanson\Robot\Collections; namespace Hanson\Vbot\Collections;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 20:56 * Time: 20:56
*/ */
namespace Hanson\Robot\Collections; namespace Hanson\Vbot\Collections;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
* Time: 20:41 * Time: 20:41
*/ */
namespace Hanson\Robot\Collections; namespace Hanson\Vbot\Collections;
use Hanson\Robot\Core\Server; use Hanson\Vbot\Core\Server;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
class ContactFactory class ContactFactory
{ {
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
* Time: 20:56 * Time: 20:56
*/ */
namespace Hanson\Robot\Collections; namespace Hanson\Vbot\Collections;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
class Group extends Collection class Group extends Collection
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 20:56 * Time: 20:56
*/ */
namespace Hanson\Robot\Collections; namespace Hanson\Vbot\Collections;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
* Time: 20:56 * Time: 20:56
*/ */
namespace Hanson\Robot\Collections; namespace Hanson\Vbot\Collections;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
class Message extends Collection class Message extends Collection
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 20:56 * Time: 20:56
*/ */
namespace Hanson\Robot\Collections; namespace Hanson\Vbot\Collections;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 20:56 * Time: 20:56
*/ */
namespace Hanson\Robot\Collections; namespace Hanson\Vbot\Collections;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
* Time: 21:13 * Time: 21:13
*/ */
namespace Hanson\Robot\Core; namespace Hanson\Vbot\Core;
use GuzzleHttp\Client as HttpClient; use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Cookie\CookieJar; use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Cookie\FileCookieJar; use GuzzleHttp\Cookie\FileCookieJar;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
class Http class Http
{ {
......
...@@ -6,34 +6,30 @@ ...@@ -6,34 +6,30 @@
* Time: 11:54 * Time: 11:54
*/ */
namespace Hanson\Robot\Core; namespace Hanson\Vbot\Core;
use Hanson\Robot\Message\Entity\Emoticon; use Hanson\Vbot\Message\Entity\Emoticon;
use Hanson\Robot\Message\Entity\Image; use Hanson\Vbot\Message\Entity\Image;
use Hanson\Robot\Message\Entity\Location; use Hanson\Vbot\Message\Entity\Location;
use Hanson\Robot\Message\Entity\Recall; use Hanson\Vbot\Message\Entity\Recall;
use Hanson\Robot\Message\Entity\Recommend; use Hanson\Vbot\Message\Entity\Recommend;
use Hanson\Robot\Message\Entity\RedPacket; use Hanson\Vbot\Message\Entity\RedPacket;
use Hanson\Robot\Message\Entity\RequestFriend; use Hanson\Vbot\Message\Entity\RequestFriend;
use Hanson\Robot\Message\Entity\Share; use Hanson\Vbot\Message\Entity\Share;
use Hanson\Robot\Message\Entity\Text; use Hanson\Vbot\Message\Entity\Text;
use Hanson\Robot\Message\Entity\Touch; use Hanson\Vbot\Message\Entity\Touch;
use Hanson\Robot\Message\Entity\Transfer; use Hanson\Vbot\Message\Entity\Transfer;
use Hanson\Robot\Message\Entity\Video; use Hanson\Vbot\Message\Entity\Video;
use Hanson\Robot\Message\Entity\Voice; use Hanson\Vbot\Message\Entity\Voice;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
class MessageFactory class MessageFactory
{ {
public $msg;
public function make($selector, $msg) public function make($selector, $msg)
{ {
$this->msg = $msg; return $this->handleMessageByType($msg);
return $this->handleMessageByType();
} }
...@@ -41,55 +37,55 @@ class MessageFactory ...@@ -41,55 +37,55 @@ class MessageFactory
* 处理消息类型 * 处理消息类型
* *
*/ */
private function handleMessageByType() private function handleMessageByType($msg)
{ {
Console::log($this->msg['MsgType']); Console::log($msg['MsgType']);
switch($this->msg['MsgType']){ switch($msg['MsgType']){
case 1: //文本消息 case 1: //文本消息
if(Location::isLocation($this->msg)){ if(Location::isLocation($msg)){
return new Location($this->msg); return new Location($msg);
}else{ }else{
return new Text($this->msg); return new Text($msg);
} }
case 3: // 图片消息 case 3: // 图片消息
return new Image($this->msg); return new Image($msg);
case 34: // 语音消息 case 34: // 语音消息
return new Voice($this->msg); return new Voice($msg);
case 43: // 视频 case 43: // 视频
return new Video($this->msg); return new Video($msg);
case 47: // 动画表情 case 47: // 动画表情
return new Emoticon($this->msg); return new Emoticon($msg);
case 10002: case 10002:
return new Recall($this->msg); return new Recall($msg);
case 10000: case 10000:
if($this->msg['Status'] == 4){ if($msg['Status'] == 4){
return new RedPacket($this->msg); return new RedPacket($msg);
}else{ }else{
} }
break; break;
case 49: case 49:
if($this->msg['Status'] == 3 && $this->msg['FileName'] === '微信转账'){ if($msg['Status'] == 3 && $msg['FileName'] === '微信转账'){
return new Transfer($this->msg); return new Transfer($msg);
}else{ }else{
return new Share($this->msg); return new Share($msg);
} }
case 37: // 好友验证 case 37: // 好友验证
return new RequestFriend($this->msg); return new RequestFriend($msg);
case 42: //共享名片 case 42: //共享名片
return new Recommend($this->msg); return new Recommend($msg);
case 62: case 62:
$this->type = 'Video'; //Video
break; break;
case 51: case 51:
if($this->msg['ToUserName'] === $this->msg['StatusNotifyUserName']){ if($msg['ToUserName'] === $msg['StatusNotifyUserName']){
return new Touch($this->msg); return new Touch($msg);
} }
break; break;
case 53: case 53:
$this->type = 'VideoCall'; //VideoCall
break; break;
default: default:
$this->type = 'Unknown'; //Unknown
break; break;
} }
} }
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
* Time: 23:08 * Time: 23:08
*/ */
namespace Hanson\Robot\Core; namespace Hanson\Vbot\Core;
use Closure; use Closure;
use Hanson\Robot\Collections\Account; use Hanson\Vbot\Collections\Account;
use Hanson\Robot\Message\Entity\Emoticon; use Hanson\Vbot\Message\Entity\Emoticon;
use Hanson\Robot\Message\Entity\Image; use Hanson\Vbot\Message\Entity\Image;
use Hanson\Robot\Message\Entity\Message; use Hanson\Vbot\Message\Entity\Message;
use Hanson\Robot\Message\Entity\Text; use Hanson\Vbot\Message\Entity\Text;
use Hanson\Robot\Message\Entity\Video; use Hanson\Vbot\Message\Entity\Video;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
class MessageHandler class MessageHandler
{ {
...@@ -88,7 +88,6 @@ class MessageHandler ...@@ -88,7 +88,6 @@ class MessageHandler
public function listen() public function listen()
{ {
while (true){ while (true){
if($this->customHandler instanceof Closure){ if($this->customHandler instanceof Closure){
call_user_func_array($this->customHandler, []); call_user_func_array($this->customHandler, []);
} }
...@@ -123,7 +122,6 @@ class MessageHandler ...@@ -123,7 +122,6 @@ class MessageHandler
if($message['AddMsgList']){ if($message['AddMsgList']){
foreach ($message['AddMsgList'] as $msg) { foreach ($message['AddMsgList'] as $msg) {
// $content = (new Message)->make($selector, $msg);
$content = $this->messageFactory->make($selector, $msg); $content = $this->messageFactory->make($selector, $msg);
if($content){ if($content){
$this->addToMessageCollection($content); $this->addToMessageCollection($content);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 21:54 * Time: 21:54
*/ */
namespace Hanson\Robot\Core; namespace Hanson\Vbot\Core;
class Myself class Myself
......
...@@ -6,17 +6,16 @@ ...@@ -6,17 +6,16 @@
* Time: 21:10 * Time: 21:10
*/ */
namespace Hanson\Robot\Core; namespace Hanson\Vbot\Core;
use Endroid\QrCode\QrCode; use Endroid\QrCode\QrCode;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Hanson\Robot\Collections\Account; use Hanson\Vbot\Collections\Account;
use Hanson\Robot\Collections\ContactFactory; use Hanson\Vbot\Collections\ContactFactory;
use Hanson\Robot\Collections\Group; use Hanson\Vbot\Collections\Group;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
use Hanson\Robot\Support\ObjectAble; use Hanson\Vbot\Support\ObjectAble;
use QueryPath\Exception;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
class Server class Server
...@@ -56,7 +55,7 @@ class Server ...@@ -56,7 +55,7 @@ class Server
public $pushUri; public $pushUri;
const BASE_HOST = 'wx2.qq.com'; public $domain = 'wx2.qq.com';
public function __construct($config = []) public function __construct($config = [])
{ {
...@@ -177,8 +176,9 @@ class Server ...@@ -177,8 +176,9 @@ class Server
Console::log('登录URL:'.$this->redirectUri); Console::log('登录URL:'.$this->redirectUri);
$domainList = [ $domainList = [
'wx2.qq.com' => ['file.wx2.qq.com', 'webpush.wx2.qq.com'], 'wx2.qq.com' => ['file.wx2.qq.com', 'webpush.wx2.qq.com'],
'wx.qq.com' => ['file.wx.qq.com', 'webpush.wx.qq.com'],
'wx8.qq.com' => ['file.wx8.qq.com', 'webpush.wx8.qq.com'], 'wx8.qq.com' => ['file.wx8.qq.com', 'webpush.wx8.qq.com'],
'qq.com' => ['file.wx.qq.com', 'webpush.wx.qq.com'], // 'qq.com' => ['file.wx.qq.com', 'webpush.wx.qq.com'],
'web2.wechat.com' => ['file.web2.wechat.com', 'webpushweb2.wechat.com'], 'web2.wechat.com' => ['file.web2.wechat.com', 'webpushweb2.wechat.com'],
'wechat.com' => ['file.web.wechat.com', 'webpushweb.web.wechat.com'], 'wechat.com' => ['file.web.wechat.com', 'webpushweb.web.wechat.com'],
]; ];
...@@ -188,10 +188,8 @@ class Server ...@@ -188,10 +188,8 @@ class Server
$this->fileUri = sprintf($url, $list[0]); $this->fileUri = sprintf($url, $list[0]);
$this->pushUri = sprintf($url, $list[1]); $this->pushUri = sprintf($url, $list[1]);
$this->baseUri = sprintf($url, $domain); $this->baseUri = sprintf($url, $domain);
$this->domain = $domain;
break; break;
}else{
// $this->fileUri = $this->pushUri = $
throw new \Exception('I can\'t believe it will be here');
} }
} }
Console::log('url is:'. $this->baseUri); Console::log('url is:'. $this->baseUri);
...@@ -265,7 +263,7 @@ class Server ...@@ -265,7 +263,7 @@ class Server
// print_r($this->baseRequest); // print_r($this->baseRequest);
Console::log('init URL:'. $url); Console::log('init URL:'. $url);
throw new Exception('[ERROR] init fail!'); throw new \Exception('[ERROR] init fail!');
} }
} }
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
* Time: 11:21 * Time: 11:21
*/ */
namespace Hanson\Robot\Core; namespace Hanson\Vbot\Core;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
class Sync class Sync
{ {
...@@ -21,7 +21,7 @@ class Sync ...@@ -21,7 +21,7 @@ class Sync
*/ */
public function checkSync() public function checkSync()
{ {
$url = 'https://webpush.' . Server::BASE_HOST . '/cgi-bin/mmwebwx-bin/synccheck?' . http_build_query([ $url = 'https://webpush.' . server()->domain . '/cgi-bin/mmwebwx-bin/synccheck?' . http_build_query([
'r' => time(), 'r' => time(),
'sid' => server()->sid, 'sid' => server()->sid,
'uin' => server()->uin, 'uin' => server()->uin,
......
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
* Time: 21:22 * Time: 21:22
*/ */
namespace Hanson\Robot\Foundation; namespace Hanson\Vbot\Foundation;
use Hanson\Robot\Core\Http; use Hanson\Vbot\Core\Http;
use Hanson\Robot\Core\Server; use Hanson\Vbot\Core\Server;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Pimple\Container; use Pimple\Container;
/** /**
* Class Robot * Class Robot
* @package Hanson\Robot\Foundation * @package Hanson\Vbot\Foundation
* @property Server $server * @property Server $server
*/ */
class Robot extends Container class Robot extends Container
......
<?php <?php
namespace Hanson\Robot\Foundation\ServiceProviders; namespace Hanson\Vbot\Foundation\ServiceProviders;
use Hanson\Robot\Core\Server; use Hanson\Vbot\Core\Server;
use Pimple\Container; use Pimple\Container;
use Pimple\ServiceProviderInterface; use Pimple\ServiceProviderInterface;
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
* Time: 16:51 * Time: 16:51
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Core\Server; use Hanson\Vbot\Core\Server;
use Hanson\Robot\Message\MediaInterface; use Hanson\Vbot\Message\MediaInterface;
use Hanson\Robot\Message\MediaTrait; use Hanson\Vbot\Message\MediaTrait;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
use Hanson\Robot\Message\UploadAble; use Hanson\Vbot\Message\UploadAble;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
use Hanson\Robot\Support\FileManager; use Hanson\Vbot\Support\FileManager;
class Emoticon extends Message implements MediaInterface, MessageInterface class Emoticon extends Message implements MediaInterface, MessageInterface
{ {
......
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
* Time: 16:51 * Time: 16:51
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
use Hanson\Robot\Support\FileManager; use Hanson\Vbot\Support\FileManager;
use Hanson\Robot\Message\MediaInterface; use Hanson\Vbot\Message\MediaInterface;
use Hanson\Robot\Message\MediaTrait; use Hanson\Vbot\Message\MediaTrait;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
use Hanson\Robot\Message\UploadAble; use Hanson\Vbot\Message\UploadAble;
class Image extends Message implements MessageInterface, MediaInterface class Image extends Message implements MessageInterface, MediaInterface
{ {
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
* Time: 21:13 * Time: 21:13
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
class Location extends Message implements MessageInterface class Location extends Message implements MessageInterface
{ {
......
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
* Time: 0:12 * Time: 0:12
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Carbon\Carbon; use Carbon\Carbon;
use Hanson\Robot\Core\Server; use Hanson\Vbot\Core\Server;
use Hanson\Robot\Collections\Contact; use Hanson\Vbot\Collections\Contact;
use Hanson\Robot\Collections\Official; use Hanson\Vbot\Collections\Official;
use Hanson\Robot\Collections\SpecialAccount; use Hanson\Vbot\Collections\SpecialAccount;
use Hanson\Robot\Support\FileManager; use Hanson\Vbot\Support\FileManager;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
use Hanson\Robot\Support\ObjectAble; use Hanson\Vbot\Support\ObjectAble;
class Message class Message
{ {
...@@ -51,19 +51,6 @@ class Message ...@@ -51,19 +51,6 @@ class Message
*/ */
public $fromType; public $fromType;
public $isAt = false;
const USER_TYPE = [
0 => 'Init',
1 => 'Self',
2 => 'FileHelper',
3 => 'Group',
4 => 'Contact',
5 => 'Public',
6 => 'Special',
99 => 'UnKnown',
];
public $msg; public $msg;
static $mediaCount = -1; static $mediaCount = -1;
...@@ -134,7 +121,6 @@ class Message ...@@ -134,7 +121,6 @@ class Message
$this->sender = account()->getAccount($uid); $this->sender = account()->getAccount($uid);
$this->msg['Content'] = $this->formatContent($content); $this->msg['Content'] = $this->formatContent($content);
$this->isAt = str_contains($this->msg['Content'], '@'.myself()->nickname);
} }
protected function formatContent($content) protected function formatContent($content)
...@@ -142,22 +128,6 @@ class Message ...@@ -142,22 +128,6 @@ class Message
return str_replace('<br/>', "\n", $content); return str_replace('<br/>', "\n", $content);
} }
/**
* 存储消息到 Message 集合
*/
public function addMessageCollection()
{
message()->put($this->msg['MsgId'], [
'content' => $this->content,
'username' => $this->username,
'sender' => $this->sender,
'msg_type' => $this->msg['MsgType'],
'type' => $this->type,
'created_at' => $this->msg['CreateTime'],
'from_type' => $this->fromType
]);
}
public function __toString() public function __toString()
{ {
return $this->content; return $this->content;
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
* Time: 15:48 * Time: 15:48
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MediaTrait; use Hanson\Vbot\Message\MediaTrait;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
class Recall extends Message implements MessageInterface class Recall extends Message implements MessageInterface
{ {
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* Time: 12:29 * Time: 12:29
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
class Recommend extends Message implements MessageInterface class Recommend extends Message implements MessageInterface
{ {
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* Time: 12:29 * Time: 12:29
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
class RedPacket extends Message implements MessageInterface class RedPacket extends Message implements MessageInterface
{ {
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* Time: 12:29 * Time: 12:29
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
class RequestFriend extends Message implements MessageInterface class RequestFriend extends Message implements MessageInterface
{ {
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* Time: 12:29 * Time: 12:29
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
class Share extends Message implements MessageInterface class Share extends Message implements MessageInterface
{ {
......
...@@ -6,15 +6,17 @@ ...@@ -6,15 +6,17 @@
* Time: 18:33 * Time: 18:33
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
class Text extends Message implements MessageInterface class Text extends Message implements MessageInterface
{ {
public $isAt;
public function __construct($msg) public function __construct($msg)
{ {
parent::__construct($msg); parent::__construct($msg);
...@@ -64,5 +66,7 @@ class Text extends Message implements MessageInterface ...@@ -64,5 +66,7 @@ class Text extends Message implements MessageInterface
public function make() public function make()
{ {
$this->content = $this->msg['Content']; $this->content = $this->msg['Content'];
$this->isAt = str_contains($this->content, '@'.myself()->nickname);
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* Time: 12:29 * Time: 12:29
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
class Touch extends Message implements MessageInterface class Touch extends Message implements MessageInterface
{ {
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* Time: 12:29 * Time: 12:29
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
class Transfer extends Message implements MessageInterface class Transfer extends Message implements MessageInterface
{ {
......
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
* Time: 22:08 * Time: 22:08
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MediaInterface; use Hanson\Vbot\Message\MediaInterface;
use Hanson\Robot\Message\MediaTrait; use Hanson\Vbot\Message\MediaTrait;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
use Hanson\Robot\Message\UploadAble; use Hanson\Vbot\Message\UploadAble;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
use Hanson\Robot\Support\FileManager; use Hanson\Vbot\Support\FileManager;
class Video extends Message implements MessageInterface, MediaInterface class Video extends Message implements MessageInterface, MediaInterface
{ {
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
* Time: 22:08 * Time: 22:08
*/ */
namespace Hanson\Robot\Message\Entity; namespace Hanson\Vbot\Message\Entity;
use Hanson\Robot\Message\MediaInterface; use Hanson\Vbot\Message\MediaInterface;
use Hanson\Robot\Message\MediaTrait; use Hanson\Vbot\Message\MediaTrait;
use Hanson\Robot\Message\MessageInterface; use Hanson\Vbot\Message\MessageInterface;
use Hanson\Robot\Message\UploadAble; use Hanson\Vbot\Message\UploadAble;
use Hanson\Robot\Support\FileManager; use Hanson\Vbot\Support\FileManager;
class Voice extends Message implements MessageInterface, MediaInterface class Voice extends Message implements MessageInterface, MediaInterface
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 2:53 * Time: 2:53
*/ */
namespace Hanson\Robot\Message; namespace Hanson\Vbot\Message;
interface MediaInterface interface MediaInterface
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
* Time: 3:20 * Time: 3:20
*/ */
namespace Hanson\Robot\Message; namespace Hanson\Vbot\Message;
/** /**
* Class MediaTrait * Class MediaTrait
* @property string $folder * @property string $folder
* @package Hanson\Robot\Message * @package Hanson\Vbot\Message
*/ */
trait MediaTrait trait MediaTrait
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 16:03 * Time: 16:03
*/ */
namespace Hanson\Robot\Message; namespace Hanson\Vbot\Message;
interface MessageInterface interface MessageInterface
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
* Time: 16:18 * Time: 16:18
*/ */
namespace Hanson\Robot\Message; namespace Hanson\Vbot\Message;
use Hanson\Robot\Core\Server; use Hanson\Vbot\Core\Server;
use Hanson\Robot\Support\Console; use Hanson\Vbot\Support\Console;
/** /**
* Class UploadAble * Class UploadAble
* @package Hanson\Robot\Message\ * @package Hanson\Vbot\Message\
* *
* @property string static $mediaCount * @property string static $mediaCount
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 16:12 * Time: 16:12
*/ */
namespace Hanson\Robot; namespace Hanson\Vbot;
use Endroid\QrCode\QrCode; use Endroid\QrCode\QrCode;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 22:51 * Time: 22:51
*/ */
namespace Hanson\Robot\Support; namespace Hanson\Vbot\Support;
class Console class Console
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 22:21 * Time: 22:21
*/ */
namespace Hanson\Robot\Support; namespace Hanson\Vbot\Support;
class FileManager class FileManager
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 17:23 * Time: 17:23
*/ */
namespace Hanson\Robot\Support; namespace Hanson\Vbot\Support;
trait ObjectAble trait ObjectAble
......
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
* Time: 0:10 * Time: 0:10
*/ */
use Hanson\Robot\Core\Server; use Hanson\Vbot\Core\Server;
use Hanson\Robot\Core\Myself; use Hanson\Vbot\Core\Myself;
use Hanson\Robot\Core\Http; use Hanson\Vbot\Core\Http;
use Hanson\Robot\Collections\Account; use Hanson\Vbot\Collections\Account;
use Hanson\Robot\Collections\Member; use Hanson\Vbot\Collections\Member;
use Hanson\Robot\Collections\Contact; use Hanson\Vbot\Collections\Contact;
use Hanson\Robot\Collections\Message; use Hanson\Vbot\Collections\Message;
use Hanson\Robot\Collections\Group; use Hanson\Vbot\Collections\Group;
use Hanson\Robot\Collections\Official; use Hanson\Vbot\Collections\Official;
if (! function_exists('server')) { if (! function_exists('server')) {
/** /**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!