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