Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
vbot
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ce435cad
authored
Dec 25, 2016
by
hanccc
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
消息发送模块
1 parent
889d390d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
949 additions
and
55 deletions
composer.json
composer.lock
src/Collections/Account.php
src/Collections/ContactFactory.php
src/Collections/GroupAccount.php
src/Core/Http.php
src/Core/MessageHandler.php
src/Core/Server.php
src/Message/Message.php
test/test.php
composer.json
View file @
ce435ca
...
@@ -21,5 +21,8 @@
...
@@ -21,5 +21,8 @@
"psr-4"
:
{
"psr-4"
:
{
"Hanson
\\
Robot
\\
"
:
"src/"
"Hanson
\\
Robot
\\
"
:
"src/"
}
}
},
"require-dev"
:
{
"phpstan/phpstan"
:
"^0.4.2"
}
}
}
}
composer.lock
View file @
ce435ca
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
"This file is @generated automatically"
],
],
"hash": "
a651fd0a020b70751704aec9ca9217f9
",
"hash": "
6af130a3acc2b00f4ce8782188ada4cf
",
"content-hash": "
524011ccf768eadbec9c686506e6057c
",
"content-hash": "
a8ac3a77959b316bf6ef9568195ba937
",
"packages": [
"packages": [
{
{
"name": "doctrine/inflector",
"name": "doctrine/inflector",
...
@@ -869,7 +869,871 @@
...
@@ -869,7 +869,871 @@
"time": "2016-11-14 01:06:16"
"time": "2016-11-14 01:06:16"
}
}
],
],
"packages-dev": [],
"packages-dev": [
{
"name": "nette/bootstrap",
"version": "v2.4.2",
"source": {
"type": "git",
"url": "https://github.com/nette/bootstrap.git",
"reference": "4db37e6d42ddf41b50417950741113b5dfc86e27"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/bootstrap/4db37e6d42ddf41b50417950741113b5dfc86e27.zip",
"reference": "4db37e6d42ddf41b50417950741113b5dfc86e27",
"shasum": ""
},
"require": {
"nette/di": "~2.4.0",
"nette/utils": "~2.4",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"latte/latte": "~2.2",
"nette/application": "~2.3",
"nette/caching": "~2.3",
"nette/database": "~2.3",
"nette/forms": "~2.3",
"nette/http": "~2.4.0",
"nette/mail": "~2.3",
"nette/robot-loader": "~2.2",
"nette/safe-stream": "~2.2",
"nette/security": "~2.3",
"nette/tester": "~2.0",
"tracy/tracy": "^2.4.1"
},
"suggest": {
"nette/robot-loader": "to use Configurator::createRobotLoader()",
"tracy/tracy": "to use Configurator::enableTracy()"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette Bootstrap",
"homepage": "https://nette.org",
"time": "2016-12-19 12:12:10"
},
{
"name": "nette/caching",
"version": "v2.5.2",
"source": {
"type": "git",
"url": "https://github.com/nette/caching.git",
"reference": "7da6cc65f301e220acba4fd8a11d3afdc642be9e"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/caching/7da6cc65f301e220acba4fd8a11d3afdc642be9e.zip",
"reference": "7da6cc65f301e220acba4fd8a11d3afdc642be9e",
"shasum": ""
},
"require": {
"nette/finder": "~2.2",
"nette/utils": "~2.4",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"latte/latte": "~2.4",
"nette/di": "~2.4",
"nette/tester": "~2.0",
"tracy/tracy": "^2.4"
},
"suggest": {
"ext-pdo_sqlite": "to use SQLiteStorage or SQLiteJournal"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette Caching Component",
"homepage": "https://nette.org",
"time": "2016-10-06 00:08:42"
},
{
"name": "nette/di",
"version": "v2.4.5",
"source": {
"type": "git",
"url": "https://github.com/nette/di.git",
"reference": "b265f305e1fef2dad1cb2e7340b49d274d3dd14c"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/di/b265f305e1fef2dad1cb2e7340b49d274d3dd14c.zip",
"reference": "b265f305e1fef2dad1cb2e7340b49d274d3dd14c",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"nette/neon": "^2.3.3",
"nette/php-generator": "^2.4",
"nette/utils": "^2.4",
"php": ">=5.6.0"
},
"conflict": {
"nette/bootstrap": "<2.4",
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette Dependency Injection Component",
"homepage": "https://nette.org",
"time": "2016-12-23 10:26:44"
},
{
"name": "nette/finder",
"version": "v2.4.0",
"source": {
"type": "git",
"url": "https://github.com/nette/finder.git",
"reference": "5cabd5fe89f9903715359a403b820c7f94f9bb5e"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/finder/5cabd5fe89f9903715359a403b820c7f94f9bb5e.zip",
"reference": "5cabd5fe89f9903715359a403b820c7f94f9bb5e",
"shasum": ""
},
"require": {
"nette/utils": "~2.4",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette Finder: Files Searching",
"homepage": "https://nette.org",
"time": "2016-05-17 15:49:06"
},
{
"name": "nette/neon",
"version": "v2.4.0",
"source": {
"type": "git",
"url": "https://github.com/nette/neon.git",
"reference": "c40c63f2afa4196844ac40d9d2a2cfb313f76906"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/neon/c40c63f2afa4196844ac40d9d2a2cfb313f76906.zip",
"reference": "c40c63f2afa4196844ac40d9d2a2cfb313f76906",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"php": ">=5.6.0"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette NEON: parser & generator for Nette Object Notation",
"homepage": "http://ne-on.org",
"time": "2016-06-25 13:59:48"
},
{
"name": "nette/php-generator",
"version": "v2.4.1",
"source": {
"type": "git",
"url": "https://github.com/nette/php-generator.git",
"reference": "e9f4429f5ac526661634242198a1ff394fa5440a"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/php-generator/e9f4429f5ac526661634242198a1ff394fa5440a.zip",
"reference": "e9f4429f5ac526661634242198a1ff394fa5440a",
"shasum": ""
},
"require": {
"nette/utils": "~2.4",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette PHP Generator",
"homepage": "https://nette.org",
"time": "2016-07-31 13:50:37"
},
{
"name": "nette/robot-loader",
"version": "v2.4.1",
"source": {
"type": "git",
"url": "https://github.com/nette/robot-loader.git",
"reference": "980d7c5f20f4792d0be49285c7b2ffde8c8d9fe5"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/robot-loader/980d7c5f20f4792d0be49285c7b2ffde8c8d9fe5.zip",
"reference": "980d7c5f20f4792d0be49285c7b2ffde8c8d9fe5",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"nette/caching": "~2.2",
"nette/finder": "~2.3",
"nette/utils": "~2.4",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette RobotLoader: comfortable autoloading",
"homepage": "https://nette.org",
"time": "2016-09-29 15:55:27"
},
{
"name": "nette/utils",
"version": "v2.4.2",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "fd2e67c2ce28da409864507d8d124621780d036d"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/utils/fd2e67c2ce28da409864507d8d124621780d036d.zip",
"reference": "fd2e67c2ce28da409864507d8d124621780d036d",
"shasum": ""
},
"require": {
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"suggest": {
"ext-gd": "to use Image",
"ext-iconv": "to use Strings::webalize() and toAscii()",
"ext-intl": "for script transliteration in Strings::webalize() and toAscii()",
"ext-json": "to use Nette\\Utils\\Json",
"ext-mbstring": "to use Strings::lower() etc...",
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette Utility Classes",
"homepage": "https://nette.org",
"time": "2016-12-19 22:01:55"
},
{
"name": "nikic/php-parser",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "adf44419c0fc014a0f191db6f89d3e55d4211744"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nikic/PHP-Parser/adf44419c0fc014a0f191db6f89d3e55d4211744.zip",
"reference": "adf44419c0fc014a0f191db6f89d3e55d4211744",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
},
"bin": [
"bin/php-parse"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"PhpParser\\": "lib/PhpParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov"
}
],
"description": "A PHP parser written in PHP",
"keywords": [
"parser",
"php"
],
"time": "2016-12-06 11:30:35"
},
{
"name": "phpstan/phpstan",
"version": "0.4.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "075b4924eefbf84cd857d1e09842036d06b05c08"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/phpstan/phpstan/075b4924eefbf84cd857d1e09842036d06b05c08.zip",
"reference": "075b4924eefbf84cd857d1e09842036d06b05c08",
"shasum": ""
},
"require": {
"nette/bootstrap": "~2.4",
"nette/caching": "~2.4",
"nette/di": "~2.4",
"nette/robot-loader": "~2.4",
"nette/utils": "~2.4",
"nikic/php-parser": "~3.0.2",
"php": "~7.0",
"symfony/console": "~2.8 || ~3.0",
"symfony/finder": "~2.8 || ~3.0",
"tracy/tracy": "~2.4"
},
"require-dev": {
"consistence/coding-standard": "~0.12.0",
"phing/phing": "^2.13.0",
"phpunit/phpunit": "^5.6",
"satooshi/php-coveralls": "^1.0",
"slevomat/coding-standard": "dev-php7#d4a1a9cd4e"
},
"bin": [
"bin/phpstan"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.4-dev"
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"time": "2016-12-12 20:31:52"
},
{
"name": "psr/log",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/php-fig/log/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d.zip",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2016-10-10 12:19:37"
},
{
"name": "symfony/console",
"version": "v3.2.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "d12aa9ca20f4db83ec58410978dab6afcb9d6aaa"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/symfony/console/d12aa9ca20f4db83ec58410978dab6afcb9d6aaa.zip",
"reference": "d12aa9ca20f4db83ec58410978dab6afcb9d6aaa",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/debug": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/filesystem": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/filesystem": "",
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2016-12-11 14:34:22"
},
{
"name": "symfony/debug",
"version": "v3.2.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "9f923e68d524a3095c5a2ae5fc7220c7cbc12231"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/symfony/debug/9f923e68d524a3095c5a2ae5fc7220c7cbc12231.zip",
"reference": "9f923e68d524a3095c5a2ae5fc7220c7cbc12231",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"psr/log": "~1.0"
},
"conflict": {
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
},
"require-dev": {
"symfony/class-loader": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Debug\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2016-11-16 22:18:16"
},
{
"name": "symfony/finder",
"version": "v3.2.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/symfony/finder/a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b.zip",
"reference": "a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2016-12-13 09:39:43"
},
{
"name": "tracy/tracy",
"version": "v2.4.4",
"source": {
"type": "git",
"url": "https://github.com/nette/tracy.git",
"reference": "c1ec73ea7661b79aa9fade863b75f8cad9f47bb5"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/nette/tracy/c1ec73ea7661b79aa9fade863b75f8cad9f47bb5.zip",
"reference": "c1ec73ea7661b79aa9fade863b75f8cad9f47bb5",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-session": "*",
"php": ">=5.4.4"
},
"require-dev": {
"nette/di": "~2.3",
"nette/tester": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src"
],
"files": [
"src/shortcuts.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Tracy: useful PHP debugger",
"homepage": "https://tracy.nette.org",
"keywords": [
"debug",
"debugger",
"nette"
],
"time": "2016-12-10 15:04:11"
}
],
"aliases": [],
"aliases": [],
"minimum-stability": "stable",
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": [],
...
...
src/Collections/Account.php
View file @
ce435ca
...
@@ -40,13 +40,14 @@ class Account extends Collection
...
@@ -40,13 +40,14 @@ class Account extends Collection
/**
/**
* 增加群聊天
* 增加群聊天
*
*
* @param $id
* @param $groupMember
* @param $groupMember
*/
*/
public
function
addGroupMember
(
$groupMember
)
public
function
addGroupMember
(
$
id
,
$
groupMember
)
{
{
$account
=
static
::
$instance
->
all
();
$account
=
static
::
$instance
->
all
();
$account
[
static
::
GROUP_MEMBER
][]
=
$groupMember
;
$account
[
static
::
GROUP_MEMBER
][
$id
]
=
$groupMember
;
static
::
$instance
=
static
::
$instance
->
make
(
$account
);
static
::
$instance
=
static
::
$instance
->
make
(
$account
);
}
}
...
@@ -54,13 +55,14 @@ class Account extends Collection
...
@@ -54,13 +55,14 @@ class Account extends Collection
/**
/**
* 增加联系人聊天
* 增加联系人聊天
*
*
* @param $id
* @param $normalMember
* @param $normalMember
*/
*/
public
function
addNormalMember
(
$normalMember
)
public
function
addNormalMember
(
$
id
,
$
normalMember
)
{
{
$account
=
static
::
$instance
->
all
();
$account
=
static
::
$instance
->
all
();
$account
[
static
::
NORMAL_MEMBER
][]
=
$normalMember
;
$account
[
static
::
NORMAL_MEMBER
][
$id
]
=
$normalMember
;
static
::
$instance
=
static
::
$instance
->
make
(
$account
);
static
::
$instance
=
static
::
$instance
->
make
(
$account
);
}
}
...
@@ -109,4 +111,11 @@ class Account extends Collection
...
@@ -109,4 +111,11 @@ class Account extends Collection
return
$target
[
$id
]
??
null
;
return
$target
[
$id
]
??
null
;
}
}
public
function
getGroupMember
(
$id
)
{
$target
=
static
::
$instance
->
get
(
static
::
GROUP_MEMBER
);
return
$target
[
$id
]
??
null
;
}
}
}
\ No newline at end of file
\ No newline at end of file
src/Collections/ContactFactory.php
View file @
ce435ca
...
@@ -37,11 +37,10 @@ class ContactFactory
...
@@ -37,11 +37,10 @@ class ContactFactory
$content
=
$this
->
server
->
http
->
json
(
$url
,
[
$content
=
$this
->
server
->
http
->
json
(
$url
,
[
'BaseRequest'
=>
$this
->
server
->
baseRequest
'BaseRequest'
=>
$this
->
server
->
baseRequest
]);
],
true
);
// file_put_contents($this->server->config['tmp'] . 'debug.json', json_encode($content));
$memberList
=
json_decode
(
$content
,
true
)[
'MemberList'
];
$this
->
makeContactList
(
$
memberList
);
$this
->
makeContactList
(
$
content
[
'MemberList'
]
);
}
}
/**
/**
...
@@ -65,7 +64,7 @@ class ContactFactory
...
@@ -65,7 +64,7 @@ class ContactFactory
$type
=
'contact'
;
$type
=
'contact'
;
ContactAccount
::
getInstance
()
->
put
(
$contact
[
'UserName'
],
$contact
);
ContactAccount
::
getInstance
()
->
put
(
$contact
[
'UserName'
],
$contact
);
}
}
Account
::
getInstance
()
->
addNormalMember
(
[
$contact
[
'UserName'
]
=>
[
'type'
=>
$type
,
'info'
=>
$contact
]
]);
Account
::
getInstance
()
->
addNormalMember
(
$contact
[
'UserName'
],
[
'type'
=>
$type
,
'info'
=>
$contact
]);
}
}
$this
->
getBatchGroupMembers
();
$this
->
getBatchGroupMembers
();
...
@@ -88,11 +87,11 @@ class ContactFactory
...
@@ -88,11 +87,11 @@ class ContactFactory
$list
[]
=
[
'UserName'
=>
$key
,
'EncryChatRoomId'
=>
''
];
$list
[]
=
[
'UserName'
=>
$key
,
'EncryChatRoomId'
=>
''
];
});
});
file_put_contents
(
$this
->
server
->
config
[
'tmp'
]
.
'debug.json'
,
json_encode
([
//
file_put_contents($this->server->config['tmp'] . 'debug.json', json_encode([
'BaseRequest'
=>
$this
->
server
->
baseRequest
,
//
'BaseRequest' => $this->server->baseRequest,
'Count'
=>
GroupAccount
::
getInstance
()
->
count
(
),
// 'Count' => count($list
),
'List'
=>
$list
//
'List' => $list
]));
//
]));
$content
=
$this
->
server
->
http
->
json
(
$url
,
[
$content
=
$this
->
server
->
http
->
json
(
$url
,
[
'BaseRequest'
=>
$this
->
server
->
baseRequest
,
'BaseRequest'
=>
$this
->
server
->
baseRequest
,
...
@@ -116,7 +115,7 @@ class ContactFactory
...
@@ -116,7 +115,7 @@ class ContactFactory
$groupAccount
[
'ChatRoomId'
]
=
$group
[
'EncryChatRoomId'
];
$groupAccount
[
'ChatRoomId'
]
=
$group
[
'EncryChatRoomId'
];
GroupAccount
::
getInstance
()
->
put
(
$group
[
'UserName'
],
$groupAccount
);
GroupAccount
::
getInstance
()
->
put
(
$group
[
'UserName'
],
$groupAccount
);
foreach
(
$group
[
'MemberList'
]
as
$member
)
{
foreach
(
$group
[
'MemberList'
]
as
$member
)
{
Account
::
getInstance
()
->
addGroupMember
(
[
$member
[
'UserName'
]
=>
[
'type'
=>
'groupMember'
,
'info'
=>
$member
,
'group'
=>
$group
]
]);
Account
::
getInstance
()
->
addGroupMember
(
$member
[
'UserName'
],
[
'type'
=>
'groupMember'
,
'info'
=>
$member
,
'group'
=>
$group
]);
}
}
}
}
...
...
src/Collections/GroupAccount.php
View file @
ce435ca
...
@@ -30,4 +30,8 @@ class GroupAccount extends Collection
...
@@ -30,4 +30,8 @@ class GroupAccount extends Collection
return
static
::
$instance
;
return
static
::
$instance
;
}
}
public
static
function
isGroup
(
$userName
){
return
strstr
(
$userName
,
'@@'
)
!==
false
;
}
}
}
\ No newline at end of file
\ No newline at end of file
src/Core/Http.php
View file @
ce435ca
...
@@ -22,11 +22,13 @@ class Http
...
@@ -22,11 +22,13 @@ class Http
return
$this
->
request
(
$url
,
'GET'
,
$query
);
return
$this
->
request
(
$url
,
'GET'
,
$query
);
}
}
public
function
post
(
$url
,
$options
=
[])
public
function
post
(
$url
,
$options
=
[]
,
$array
=
false
)
{
{
$key
=
is_array
(
$options
)
?
'form_params'
:
'body'
;
$key
=
is_array
(
$options
)
?
'form_params'
:
'body'
;
return
$this
->
request
(
$url
,
'POST'
,
[
$key
=>
$options
]);
$content
=
$this
->
request
(
$url
,
'POST'
,
[
$key
=>
$options
]);
return
$array
?
json_decode
(
$content
,
true
)
:
$content
;
}
}
public
function
json
(
$url
,
$options
=
[],
$array
=
false
)
public
function
json
(
$url
,
$options
=
[],
$array
=
false
)
...
...
src/Core/MessageHandler.php
View file @
ce435ca
...
@@ -106,15 +106,30 @@ class MessageHandler
...
@@ -106,15 +106,30 @@ class MessageHandler
return
false
;
return
false
;
}
}
$this
->
server
->
http
->
json
(
Server
::
BASE_URI
.
'/webwxsendmsg?pass_ticket='
.
$this
->
server
->
passTicket
,
[
$random
=
strval
(
time
()
*
1000
)
.
'0'
.
strval
(
rand
(
100
,
999
));
echo
$response
;
$result
=
$this
->
server
->
http
->
json
(
Server
::
BASE_URI
.
'/webwxsendmsg?pass_ticket='
.
$this
->
server
->
passTicket
,
[
'BaseRequest'
=>
$this
->
server
->
baseRequest
,
'BaseRequest'
=>
$this
->
server
->
baseRequest
,
'Msg'
=>
[
'Msg'
=>
[
'Type'
=>
1
,
'Type'
=>
1
,
'Content'
=>
urlencode
(
$response
)
,
'Content'
=>
$response
,
'FromUserName'
=>
$this
->
server
->
getMyAccount
(),
'FromUserName'
=>
$this
->
server
->
getMyAccount
(),
'ToUserName'
=>
$content
->
to
'ToUserName'
=>
$content
->
rawMsg
[
'FromUserName'
],
'LocalID'
=>
$random
,
'ClientMsgId'
=>
$random
]
]
]);
],
true
);
if
(
$result
[
'BaseResponse'
][
'Ret'
]
!=
0
){
Log
::
echo
(
'发送消息失败'
);
}
}
private
function
unicode
(
$utf8_str
)
{
$unicode
=
(
ord
(
$utf8_str
[
0
])
&
0x1F
)
<<
12
;
$unicode
|=
(
ord
(
$utf8_str
[
1
])
&
0x3F
)
<<
6
;
$unicode
|=
(
ord
(
$utf8_str
[
2
])
&
0x3F
);
return
dechex
(
$unicode
);
}
}
/**
/**
...
...
src/Core/Server.php
View file @
ce435ca
...
@@ -11,6 +11,7 @@ namespace Hanson\Robot\Core;
...
@@ -11,6 +11,7 @@ namespace Hanson\Robot\Core;
use
Endroid\QrCode\QrCode
;
use
Endroid\QrCode\QrCode
;
use
GuzzleHttp\Client
;
use
GuzzleHttp\Client
;
use
Hanson\Robot\Collections\Account
;
use
Hanson\Robot\Collections\ContactFactory
;
use
Hanson\Robot\Collections\ContactFactory
;
use
Hanson\Robot\Collections\GroupAccount
;
use
Hanson\Robot\Collections\GroupAccount
;
use
Hanson\Robot\Support\Log
;
use
Hanson\Robot\Support\Log
;
...
@@ -212,22 +213,31 @@ class Server
...
@@ -212,22 +213,31 @@ class Server
$content
=
$this
->
http
->
json
(
$url
,
[
$content
=
$this
->
http
->
json
(
$url
,
[
'BaseRequest'
=>
$this
->
baseRequest
'BaseRequest'
=>
$this
->
baseRequest
]);
]);
print_r
(
$this
->
baseRequest
);
$result
=
json_decode
(
$content
,
true
);
$result
=
json_decode
(
$content
,
true
);
$this
->
generateSyncKey
(
$result
);
$this
->
generateSyncKey
(
$result
);
static
::
$myAccount
=
$result
[
'User'
];
static
::
$myAccount
=
$result
[
'User'
];
$this
->
initContactList
(
$result
[
'ContactList'
]);
if
(
$result
[
'BaseResponse'
][
'Ret'
]
!=
0
){
if
(
$result
[
'BaseResponse'
][
'Ret'
]
!=
0
){
print_r
(
$result
);
file_put_contents
(
$this
->
config
[
'tmp'
]
.
'debug.json'
,
$content
);
throw
new
Exception
(
'[ERROR] init fail!'
);
throw
new
Exception
(
'[ERROR] init fail!'
);
}
}
}
}
protected
function
initContactList
(
$contactList
)
{
if
(
$contactList
){
foreach
(
$contactList
as
$contact
)
{
if
(
GroupAccount
::
isGroup
(
$contact
[
'UserName'
])){
GroupAccount
::
getInstance
()
->
put
(
$contact
[
'UserName'
],
$contact
);
Account
::
getInstance
()
->
addNormalMember
(
$contact
[
'UserName'
],
[
'type'
=>
'group'
,
'info'
=>
$contact
]);
}
}
}
}
protected
function
initContact
()
protected
function
initContact
()
{
{
new
ContactFactory
(
$this
);
new
ContactFactory
(
$this
);
...
...
src/Message/Message.php
View file @
ce435ca
...
@@ -78,10 +78,10 @@ class Message
...
@@ -78,10 +78,10 @@ class Message
// $this->setContent();
// $this->setContent();
$this
->
setType
();
$this
->
setFromType
();
$this
->
setFromType
();
$this
->
setType
();
return
$this
;
return
$this
;
}
}
...
@@ -205,7 +205,7 @@ class Message
...
@@ -205,7 +205,7 @@ class Message
private
function
setLocationMessage
()
private
function
setLocationMessage
()
{
{
$this
->
FromType
=
'Location'
;
$this
->
FromType
=
'Location'
;
$this
->
url
=
$this
->
rawMsg
[
'Url'
];
//
$this->url = $this->rawMsg['Url'];
$this
->
content
->
msg
=
Location
::
getLocationText
(
$this
->
rawMsg
[
'Content'
]);
$this
->
content
->
msg
=
Location
::
getLocationText
(
$this
->
rawMsg
[
'Content'
]);
}
}
...
@@ -218,7 +218,7 @@ class Message
...
@@ -218,7 +218,7 @@ class Message
{
{
list
(
$uid
,
$content
)
=
explode
(
'<br/>'
,
$content
,
2
);
list
(
$uid
,
$content
)
=
explode
(
'<br/>'
,
$content
,
2
);
$this
->
sender
=
Account
::
getInstance
()
->
get
(
'normalMember'
)[
substr
(
$uid
,
0
,
-
1
)]
;
$this
->
sender
=
Account
::
getInstance
()
->
get
GroupMember
(
substr
(
$uid
,
0
,
-
1
))
;
$this
->
rawMsg
[
'Content'
]
=
$this
->
formatContent
(
$content
);
$this
->
rawMsg
[
'Content'
]
=
$this
->
formatContent
(
$content
);
}
}
...
...
test/test.php
View file @
ce435ca
...
@@ -8,35 +8,23 @@
...
@@ -8,35 +8,23 @@
require_once
__DIR__
.
'./../vendor/autoload.php'
;
require_once
__DIR__
.
'./../vendor/autoload.php'
;
$robot
=
new
\Hanson\Robot\Robot
([
'tmp'
=>
realpath
(
'./tmp'
)
.
'/'
,
'debug'
=>
true
,
'tuling'
=>
true
,
'tuling_key'
=>
''
]);
//$robot->run();
$robot
=
new
\Hanson\Robot\Foundation\Robot
([
$robot
=
new
\Hanson\Robot\Foundation\Robot
([
'tmp'
=>
realpath
(
'./tmp'
)
.
'/'
,
'tmp'
=>
realpath
(
'./tmp'
)
.
'/'
,
'debug'
=>
true
,
'debug'
=>
true
,
'tuling'
=>
true
,
'tuling_key'
=>
''
]);
]);
$client
=
new
\GuzzleHttp\Client
();
$robot
->
server
->
setMessageHandler
(
function
(
$message
){
$robot
->
server
->
setMessageHandler
(
function
(
$message
)
use
(
$client
,
$robot
){
// if($message->type === 'text'){
$url
=
'http://www.tuling123.com/openapi/api'
;
//
// }elseif ($message->type === 'location'){
// return Message::make();
// }
//
// if($message->FromUserName === ''){
// # do something;
// }
$result
=
$robot
->
server
->
http
->
post
(
$url
,
[
'key'
=>
'1dce02aef026258eff69635a06b0ab7d'
,
'info'
=>
$message
->
rawMsg
[
'Content'
]
],
true
);
print_r
(
$message
);
print_r
(
$message
);
print_r
(
$result
);
return
$result
[
'text'
];
});
});
$robot
->
server
->
run
();
$robot
->
server
->
run
();
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment