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
0e4c9916
Commit
0e4c9916
authored
Feb 15, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConsoleUI warning
parent
b6e77fd8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
19 deletions
+35
-19
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/MiraiHttpAPIServer.kt
...ain/kotlin/net/mamoe/mirai/api/http/MiraiHttpAPIServer.kt
+3
-2
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsole.kt
...i-console/src/main/kotlin/net/mamoe/mirai/MiraiConsole.kt
+15
-7
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsoleUI.kt
...console/src/main/kotlin/net/mamoe/mirai/MiraiConsoleUI.kt
+12
-9
mirai-console/src/main/kotlin/net/mamoe/mirai/plugins/PluginBase.kt
...ole/src/main/kotlin/net/mamoe/mirai/plugins/PluginBase.kt
+5
-1
No files found.
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/MiraiHttpAPIServer.kt
View file @
0e4c9916
...
...
@@ -25,8 +25,9 @@ import kotlin.coroutines.CoroutineContext
object
MiraiHttpAPIServer
:
CoroutineScope
{
private
val
logger
=
DefaultLogger
(
"Mirai HTTP API"
)
override
val
coroutineContext
:
CoroutineContext
=
CoroutineExceptionHandler
{
_
,
throwable
->
logger
.
error
(
throwable
)
}
var
logger
=
DefaultLogger
(
"Mirai HTTP API"
)
override
val
coroutineContext
:
CoroutineContext
=
CoroutineExceptionHandler
{
_
,
throwable
->
logger
.
error
(
throwable
)
}
init
{
SessionManager
.
authKey
=
generateSessionKey
()
//用于验证的key, 使用和SessionKey相同的方法生成, 但意义不同
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsole.kt
View file @
0e4c9916
...
...
@@ -18,6 +18,7 @@ import net.mamoe.mirai.api.http.MiraiHttpAPIServer
import
net.mamoe.mirai.api.http.generateSessionKey
import
net.mamoe.mirai.contact.sendMessage
import
net.mamoe.mirai.utils.MiraiLogger
import
net.mamoe.mirai.utils.SimpleLogger
import
java.io.File
import
java.io.PrintStream
import
kotlin.concurrent.thread
...
...
@@ -38,16 +39,17 @@ object MiraiConsole {
val
pluginManager
:
PluginManager
get
()
=
PluginManager
var
logger
=
UIPushLogger
(
0
)
var
logger
=
UIPushLogger
var
path
:
String
=
System
.
getProperty
(
"user.dir"
)
val
version
=
"0.01"
var
coreVersion
=
"0.1
3
"
var
coreVersion
=
"0.1
5
"
val
build
=
"Beta"
fun
start
()
{
logger
(
"Mirai-console v$version $build | core version v$coreVersion is still in testing stage, majority feature is available"
)
MiraiConsoleUI
.
start
()
logger
(
"Mirai-console [v$version $build | core version v$coreVersion] is still in testing stage, majority feature is available"
)
logger
(
"Mirai-console now running under "
+
System
.
getProperty
(
"user.dir"
))
logger
(
"Get news in github: https://github.com/mamoe/mirai"
)
logger
(
"Mirai为开源项目,请自觉遵守开源项目协议"
)
...
...
@@ -77,11 +79,14 @@ object MiraiConsole {
logger
(
"请尽快更改初始生成的HTTP API AUTHKEY"
)
}
logger
(
"正在启动HTTPAPI; 端口="
+
MiraiProperties
.
HTTP_API_PORT
)
MiraiHttpAPIServer
.
logger
=
SimpleLogger
(
"HTTP API"
)
{
_
,
message
,
e
->
logger
(
"[Mirai HTTP API]"
,
0
,
message
)
}
MiraiHttpAPIServer
.
start
(
MiraiProperties
.
HTTP_API_PORT
,
MiraiProperties
.
HTTP_API_AUTH_KEY
)
logger
(
"HTTPAPI启动完成; 端口="
+
MiraiProperties
.
HTTP_API_PORT
)
logger
(
"HTTPAPI启动完成; 端口=
"
+
MiraiProperties
.
HTTP_API_PORT
)
}
}
...
...
@@ -249,11 +254,14 @@ object MiraiConsole {
}
}
class
UIPushLogger
(
val
identity
:
Long
)
{
object
UIPushLogger
{
operator
fun
invoke
(
any
:
Any
?
=
null
)
{
MiraiConsoleUI
.
start
()
invoke
(
"[Mirai$version $build]"
,
0L
,
any
)
}
operator
fun
invoke
(
identityStr
:
String
,
identity
:
Long
,
any
:
Any
?
=
null
)
{
if
(
any
!=
null
)
{
MiraiConsoleUI
.
pushLog
(
identity
,
"
[Mirai$version $build]
: $any"
)
MiraiConsoleUI
.
pushLog
(
identity
,
"
$identityStr
: $any"
)
}
}
}
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsoleUI.kt
View file @
0e4c9916
...
...
@@ -36,19 +36,22 @@ import kotlin.math.ceil
@SuppressWarnings
(
"UNCHECKED"
)
object
MiraiConsoleUI
{
val
cacheLogSize
=
50
val
log
=
mutableMapOf
<
Long
,
LimitLinkedQueue
<
String
>>().
also
{
it
[
0L
]
=
LimitLinkedQueue
(
50
)
it
[
2821869985L
]
=
LimitLinkedQueue
(
50
)
it
[
0L
]
=
LimitLinkedQueue
(
cacheLogSize
)
}
val
botAdminCount
=
mutableMapOf
<
Long
,
Long
>()
private
val
screens
=
mutableListOf
(
0L
,
2821869985L
)
private
var
currentScreenId
=
0
fun
addBotScreen
(
uin
:
Long
)
{
screens
.
add
(
uin
)
log
[
uin
]
=
LimitLinkedQueue
()
log
[
uin
]
=
LimitLinkedQueue
(
cacheLogSize
)
botAdminCount
[
uin
]
=
0
}
...
...
@@ -182,7 +185,7 @@ object MiraiConsoleUI {
}
}
fun
getLeftScreenId
():
Int
{
private
fun
getLeftScreenId
():
Int
{
var
newId
=
currentScreenId
-
1
if
(
newId
<
0
)
{
newId
=
screens
.
size
-
1
...
...
@@ -190,7 +193,7 @@ object MiraiConsoleUI {
return
newId
}
fun
getRightScreenId
():
Int
{
private
fun
getRightScreenId
():
Int
{
var
newId
=
1
+
currentScreenId
if
(
newId
>=
screens
.
size
)
{
newId
=
0
...
...
@@ -198,7 +201,7 @@ object MiraiConsoleUI {
return
newId
}
fun
getScreenName
(
id
:
Int
):
String
{
private
fun
getScreenName
(
id
:
Int
):
String
{
return
when
(
screens
[
id
])
{
0L
->
{
"Console Screen"
...
...
@@ -369,7 +372,7 @@ object MiraiConsoleUI {
}
}
fun
addCommandChar
(
private
fun
addCommandChar
(
c
:
Char
)
{
if
(
commandBuilder
.
isEmpty
()
&&
c
!=
'/'
)
{
...
...
@@ -385,7 +388,7 @@ object MiraiConsoleUI {
}
}
fun
deleteCommandChar
()
{
private
fun
deleteCommandChar
()
{
if
(!
commandBuilder
.
isEmpty
())
{
commandBuilder
=
StringBuilder
(
commandBuilder
.
toString
().
substring
(
0
,
commandBuilder
.
length
-
1
))
}
...
...
@@ -398,7 +401,7 @@ object MiraiConsoleUI {
}
fun
emptyCommand
()
{
private
fun
emptyCommand
()
{
commandBuilder
=
StringBuilder
()
redrawCommand
()
if
(
terminal
is
SwingTerminal
)
{
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/plugins/PluginBase.kt
View file @
0e4c9916
...
...
@@ -11,8 +11,10 @@ package net.mamoe.mirai.plugins
import
net.mamoe.mirai.ICommand
import
kotlinx.coroutines.*
import
net.mamoe.mirai.MiraiConsole
import
net.mamoe.mirai.utils.DefaultLogger
import
net.mamoe.mirai.utils.MiraiLogger
import
net.mamoe.mirai.utils.SimpleLogger
import
net.mamoe.mirai.utils.io.encodeToString
import
java.io.File
import
java.net.URL
...
...
@@ -156,7 +158,9 @@ object PluginManager {
File
(
it
).
mkdirs
()
}
val
logger
=
DefaultLogger
(
"Mirai Plugin Manager"
)
val
logger
=
SimpleLogger
(
"Plugin Manager"
)
{
_
,
message
,
e
->
MiraiConsole
.
logger
(
"[Plugin Manager]"
,
0
,
message
)
}
//已完成加载的
private
val
nameToPluginBaseMap
:
MutableMap
<
String
,
PluginBase
>
=
mutableMapOf
()
...
...
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