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 6cee90dc
authored
Mar 16, 2017
by
HanSon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
表情随机发送
1 parent
cdd3479a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
example/index.php
src/Collections/Group.php
example/index.php
View file @
6cee90d
...
@@ -62,7 +62,7 @@ function isAdmin($message)
...
@@ -62,7 +62,7 @@ function isAdmin($message)
$groupMap
=
[
$groupMap
=
[
[
[
'nickname'
=>
'vbo
t
测试群'
,
'nickname'
=>
'vbo 测试群'
,
'id'
=>
1
'id'
=>
1
]
]
];
];
...
@@ -141,6 +141,16 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
...
@@ -141,6 +141,16 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
return
'vbot 从未见过这么犯贱的人'
;
return
'vbot 从未见过这么犯贱的人'
;
}
}
if
(
substr
(
$message
->
content
,
0
,
1
)
===
'@'
&&
preg_match
(
'/@(.+)\s自作孽不可活/'
,
$message
->
content
,
$match
)
&&
isAdmin
(
$message
)){
$nickname
=
$match
[
1
];
$members
=
group
()
->
getMembersByNickname
(
$message
->
from
[
'UserName'
],
$nickname
);
if
(
$members
){
$member
=
current
(
$members
);
Text
::
send
(
$message
->
from
[
'UserName'
],
'拜拜 '
.
$member
[
'NickName'
]
.
' ,君让臣死,臣不得不死'
);
group
()
->
deleteMember
(
$message
->
from
[
'UserName'
],
$member
[
'UserName'
]);
}
}
if
(
$message
->
isAt
)
{
if
(
$message
->
isAt
)
{
return
reply
(
$message
->
content
);
return
reply
(
$message
->
content
);
}
}
...
@@ -158,7 +168,7 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
...
@@ -158,7 +168,7 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
}
}
// 表情信息 返回接收到的表情
// 表情信息 返回接收到的表情
if
(
$message
instanceof
Emoticon
)
{
if
(
$message
instanceof
Emoticon
&&
random_int
(
0
,
1
)
&&
random_int
(
0
,
1
)
)
{
Emoticon
::
sendRandom
(
$message
->
from
[
'UserName'
]);
Emoticon
::
sendRandom
(
$message
->
from
[
'UserName'
]);
}
}
...
...
src/Collections/Group.php
View file @
6cee90d
...
@@ -182,10 +182,15 @@ class Group extends Collection
...
@@ -182,10 +182,15 @@ class Group extends Collection
*/
*/
public
function
addMember
(
$groupUsername
,
$members
)
public
function
addMember
(
$groupUsername
,
$members
)
{
{
if
(
!
$groupUsername
)
return
false
;
$group
=
group
()
->
get
(
$groupUsername
);
$group
=
group
()
->
get
(
$groupUsername
);
if
(
!
$group
)
return
false
;
$groupCount
=
count
(
$group
[
'MemberList'
]);
$groupCount
=
count
(
$group
[
'MemberList'
]);
list
(
$fun
,
$key
)
=
$groupCount
>
40
?
[
'invitemember'
,
'InviteMemberList'
]
:
[
'addmember'
,
'AddMemberList'
];
list
(
$fun
,
$key
)
=
$groupCount
>
40
?
[
'invitemember'
,
'InviteMemberList'
]
:
[
'addmember'
,
'AddMemberList'
];
$members
=
is_string
(
$members
)
?
[
$members
]
:
$members
;
$members
=
is_string
(
$members
)
?
[
$members
]
:
$members
;
$result
=
http
()
->
json
(
sprintf
(
'%s/webwxupdatechatroom?fun=%s&pass_ticket=%s'
,
server
()
->
baseUri
,
$fun
,
server
()
->
passTicket
),
[
$result
=
http
()
->
json
(
sprintf
(
'%s/webwxupdatechatroom?fun=%s&pass_ticket=%s'
,
server
()
->
baseUri
,
$fun
,
server
()
->
passTicket
),
[
'BaseRequest'
=>
server
()
->
baseRequest
,
'BaseRequest'
=>
server
()
->
baseRequest
,
'ChatRoomName'
=>
$groupUsername
,
'ChatRoomName'
=>
$groupUsername
,
...
...
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