Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
35742632
Commit
35742632
authored
Feb 04, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Group Card
parent
a76606ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
14 deletions
+25
-14
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+7
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
...e/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
+6
-0
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
...o-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
+11
-12
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
35742632
...
...
@@ -61,6 +61,7 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
internal
class
MemberImpl
(
qq
:
QQImpl
,
override
var
groupCard
:
String
,
group
:
GroupImpl
,
override
val
coroutineContext
:
CoroutineContext
,
override
val
permission
:
MemberPermission
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
35742632
...
...
@@ -174,6 +174,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
group
.
owner
=
MemberImpl
(
qq
=
bot
.
QQ
(
it
.
dwGroupOwnerUin
)
as
QQImpl
,
groupCard
=
""
,
//unknown now
group
=
group
,
coroutineContext
=
group
.
coroutineContext
,
permission
=
MemberPermission
.
OWNER
...
...
@@ -253,6 +254,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
list
.
delegate
.
addLast
(
MemberImpl
(
qq
=
bot
.
QQ
(
it
.
memberUin
)
as
QQImpl
,
groupCard
=
it
.
sShowName
?:
it
.
sName
?:
it
.
nick
,
group
=
group
,
coroutineContext
=
group
.
coroutineContext
,
permission
=
when
{
...
...
@@ -262,8 +264,11 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
}
)
)
}
else
if
(
it
.
dwFlag
==
1L
)
{
group
.
botPermission
=
MemberPermission
.
ADMINISTRATOR
}
else
{
group
.
owner
.
groupCard
=
it
.
sShowName
?:
it
.
sName
?:
it
.
nick
if
(
it
.
dwFlag
==
1L
)
{
group
.
botPermission
=
MemberPermission
.
ADMINISTRATOR
}
}
}
size
+=
data
.
members
.
size
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
View file @
35742632
...
...
@@ -21,6 +21,11 @@ interface Member : QQ, Contact {
*/
val
permission
:
MemberPermission
/**
*
*/
var
groupCard
:
String
/**
* 禁言
*
...
...
@@ -37,6 +42,7 @@ interface Member : QQ, Contact {
* 解除禁言
*/
suspend
fun
unmute
():
Boolean
}
@ExperimentalTime
...
...
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
View file @
35742632
...
...
@@ -2,7 +2,6 @@ package demo.gentleman
import
com.alibaba.fastjson.JSON
import
kotlinx.coroutines.*
import
kotlinx.serialization.json.JsonObject
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.uploadAsImage
...
...
@@ -18,21 +17,24 @@ class GentleImage {
val
seImage
:
Deferred
<
Image
>
by
lazy
{
getImage
(
1
)
}
fun
getImage
(
r18
:
Int
):
Deferred
<
Image
>
{
GlobalScope
.
async
{
return
GlobalScope
.
async
{
withTimeoutOrNull
(
5
*
1000
)
{
withContext
(
Dispatchers
.
IO
)
{
val
result
=
JSON
.
parseObject
(
Jsoup
.
connect
(
"https://api.lolicon.app/setu/?r18=$r18"
).
ignoreContentType
(
true
).
timeout
(
10
_0000
).
get
().
body
().
text
(),
val
result
=
JSON
.
parseObject
(
Jsoup
.
connect
(
"https://api.lolicon.app/setu/?r18=$r18"
).
ignoreContentType
(
true
).
timeout
(
10
_0000
).
get
().
body
().
text
()
)
va
r
url
=
""
;
va
r
pid
=
""
;
va
l
url
:
String
va
l
pid
:
String
with
(
result
.
getJSONArray
(
"data"
).
getJSONObject
(
0
))
{
url
=
this
.
getString
(
"url"
)
pid
=
this
.
getString
(
"pid"
)
}
val
image
=
Jsoup
Jsoup
.
connect
(
url
)
.
followRedirects
(
true
)
.
timeout
(
180
_000
)
...
...
@@ -41,12 +43,9 @@ class GentleImage {
.
referrer
(
"https://www.pixiv.net/member_illust.php?mode=medium&illust_id=$pid"
)
.
ignoreHttpErrors
(
true
)
.
maxBodySize
(
10000000
)
.
execute
()
if
(
image
.
statusCode
()
!=
200
)
error
(
"Failed to download image"
)
.
execute
().
also
{
check
(
it
.
statusCode
()
==
200
)
{
"Failed to download image"
}
}
}
image
.
bodyStream
().
uploadAsImage
(
contact
)
?:
error
(
"Unable to upload image"
)
}
}
?.
bodyStream
()
?.
uploadAsImage
(
contact
)
?:
error
(
"Unable to download image"
)
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment