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
cdd3053e
Commit
cdd3053e
authored
Feb 20, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better
parent
a0843c1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
34 deletions
+27
-34
docs/guide_getting_started.md
docs/guide_getting_started.md
+27
-34
No files found.
docs/guide_getting_started.md
View file @
cdd3053e
...
...
@@ -36,7 +36,7 @@ JDK要求8以上
-
首先添加repositories
```
```
groovy
//添加jcenter仓库
/*
repositories {
...
...
@@ -53,7 +53,7 @@ JDK要求8以上
-
添加依赖,将dependencies部分覆盖为
```
```
groovy
dependencies
{
implementation
'net.mamoe:mirai-core:0.16.0'
implementation
'net.mamoe:mirai-core-qqandroid-jvm:0.16.0'
...
...
@@ -72,38 +72,31 @@ JDK要求8以上
-
在包下新建kotlin文件
```MyLoader.kt```
```
package
net
.
mamoe
.
mirai
.
simpleloader
import
kotlinx
.
coroutines
.*
import
net
.
mamoe
.
mirai
.
Bot
import
net
.
mamoe
.
mirai
.
alsoLogin
import
net
.
mamoe
.
mirai
.
event
.
subscribeMessages
fun
main
(
args
:
Array
<
String
>)
{
runBlocking
{//
阻塞,直到
Mirai
退出
coroutineScope
()
{
launch
{
val
qqId
=
10000L
//
Bot
的
QQ
号,需为
Long
类型,在结尾处添加大写
L
val
password
=
"your_password"
//
Bot
的密码
val
miraiBot
=
Bot
(
qqId
,
password
).
alsoLogin
()//
新建
Bot
并登陆
miraiBot
.
subscribeMessages
{
"你好"
reply
"你好!"
"profile"
reply
{
sender
.
queryProfile
()
}
case
(
"at me"
)
{
reply
(
sender
.
at
()
+
" 给爷爬 "
)
}
(
contains
(
"舔"
)
or
contains
(
"刘老板"
))
{
"刘老板太强了"
.
reply
()
}
}
miraiBot
.
join
()
}
}
}
}
```
```
kotlin
package
net.mamoe.mirai.simpleloader
import
kotlinx.coroutines.*
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.alsoLogin
import
net.mamoe.mirai.event.subscribeMessages
suspend
fun
main
()
{
val
qqId
=
10000L
//Bot的QQ号,需为Long类型,在结尾处添加大写L
val
password
=
"your_password"
//Bot的密码
val
miraiBot
=
Bot
(
qqId
,
password
).
alsoLogin
()
//新建Bot并登陆
miraiBot
.
subscribeMessages
{
"你好"
reply
"你好!"
case
(
"at me"
)
{
reply
(
sender
.
at
()
+
" 给爷爬 "
)
}
(
contains
(
"舔"
)
or
contains
(
"刘老板"
))
{
"刘老板太强了"
.
reply
()
}
}
miraiBot
.
join
()
}
```
-
单击编辑器内第8行(
```fun main```
)左侧的run按钮(绿色三角),等待,MiraiBot成功登录。
-
本例的功能中,在任意群内任意成员发送包含“舔”字或“刘老板”字样的消息,MiraiBot会回复“刘老板太强了”
...
...
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