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
2ed0411c
Commit
2ed0411c
authored
Feb 15, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConsoleUI warning
parent
0e4c9916
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
16 deletions
+36
-16
mirai-console/build.gradle.kts
mirai-console/build.gradle.kts
+1
-0
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsole.kt
...i-console/src/main/kotlin/net/mamoe/mirai/MiraiConsole.kt
+19
-13
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsoleUI.kt
...console/src/main/kotlin/net/mamoe/mirai/MiraiConsoleUI.kt
+16
-3
No files found.
mirai-console/build.gradle.kts
View file @
2ed0411c
...
@@ -43,5 +43,6 @@ dependencies {
...
@@ -43,5 +43,6 @@ dependencies {
api
(
group
=
"org.yaml"
,
name
=
"snakeyaml"
,
version
=
"1.25"
)
api
(
group
=
"org.yaml"
,
name
=
"snakeyaml"
,
version
=
"1.25"
)
api
(
group
=
"com.moandjiezana.toml"
,
name
=
"toml4j"
,
version
=
"0.7.2"
)
api
(
group
=
"com.moandjiezana.toml"
,
name
=
"toml4j"
,
version
=
"0.7.2"
)
api
(
group
=
"com.googlecode.lanterna"
,
name
=
"lanterna"
,
version
=
"3.0.2"
)
api
(
group
=
"com.googlecode.lanterna"
,
name
=
"lanterna"
,
version
=
"3.0.2"
)
api
(
"org.bouncycastle:bcprov-jdk15on:1.64"
)
// classpath is not set correctly by IDE
// classpath is not set correctly by IDE
}
}
\ No newline at end of file
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsole.kt
View file @
2ed0411c
...
@@ -10,19 +10,22 @@ package net.mamoe.mirai
...
@@ -10,19 +10,22 @@ package net.mamoe.mirai
*/
*/
import
kotlinx.coroutines.runBlocking
import
kotlinx.coroutines.runBlocking
import
net.mamoe.mirai.api.http.MiraiHttpAPIServer
import
net.mamoe.mirai.api.http.generateSessionKey
import
net.mamoe.mirai.contact.sendMessage
import
net.mamoe.mirai.plugins.PluginManager
import
net.mamoe.mirai.plugins.PluginManager
import
net.mamoe.mirai.plugins.loadAsConfig
import
net.mamoe.mirai.plugins.loadAsConfig
import
net.mamoe.mirai.plugins.withDefaultWrite
import
net.mamoe.mirai.plugins.withDefaultWrite
import
net.mamoe.mirai.plugins.withDefaultWriteSave
import
net.mamoe.mirai.plugins.withDefaultWriteSave
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
net.mamoe.mirai.utils.SimpleLogger
import
org.bouncycastle.jce.provider.BouncyCastleProvider
import
java.io.File
import
java.io.File
import
java.io.PrintStream
import
java.security.Security
import
java.util.*
import
java.util.concurrent.LinkedBlockingQueue
import
kotlin.concurrent.thread
import
kotlin.concurrent.thread
object
MiraiConsole
{
object
MiraiConsole
{
val
bots
val
bots
get
()
=
Bot
.
instances
get
()
=
Bot
.
instances
...
@@ -48,7 +51,6 @@ object MiraiConsole {
...
@@ -48,7 +51,6 @@ object MiraiConsole {
val
build
=
"Beta"
val
build
=
"Beta"
fun
start
()
{
fun
start
()
{
MiraiConsoleUI
.
start
()
logger
(
"Mirai-console [v$version $build | core version v$coreVersion] is still in testing stage, majority feature is available"
)
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
(
"Mirai-console now running under "
+
System
.
getProperty
(
"user.dir"
))
logger
(
"Get news in github: https://github.com/mamoe/mirai"
)
logger
(
"Get news in github: https://github.com/mamoe/mirai"
)
...
@@ -65,7 +67,6 @@ object MiraiConsole {
...
@@ -65,7 +67,6 @@ object MiraiConsole {
logger
(
"Mirai-console 启动完成"
)
logger
(
"Mirai-console 启动完成"
)
logger
(
"\"/login qqnumber qqpassword \" to login a bot"
)
logger
(
"\"/login qqnumber qqpassword \" to login a bot"
)
logger
(
"\"/login qq号 qq密码 \" 来登陆一个BOT"
)
logger
(
"\"/login qq号 qq密码 \" 来登陆一个BOT"
)
}
}
fun
stop
()
{
fun
stop
()
{
...
@@ -108,14 +109,15 @@ object MiraiConsole {
...
@@ -108,14 +109,15 @@ object MiraiConsole {
}
}
val
qqNumber
=
it
[
0
].
toLong
()
val
qqNumber
=
it
[
0
].
toLong
()
val
qqPassword
=
it
[
1
]
val
qqPassword
=
it
[
1
]
logger
(
"login..."
)
logger
(
"
[Bot Login]"
,
0
,
"
login..."
)
try
{
try
{
runBlocking
{
runBlocking
{
Bot
(
qqNumber
,
qqPassword
).
alsoLogin
()
Bot
(
qqNumber
,
qqPassword
).
alsoLogin
()
println
(
"$qqNumber login successes"
)
logger
(
"[Bot Login]"
,
0
,
"$qqNumber login successes"
)
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
println
(
"$qqNumber login failed"
)
logger
(
"[Bot Login]"
,
0
,
"$qqNumber login failed -> "
+
e
.
message
)
e
.
printStackTrace
()
}
}
true
true
}
}
...
@@ -234,14 +236,15 @@ object MiraiConsole {
...
@@ -234,14 +236,15 @@ object MiraiConsole {
}
}
object
CommandListener
{
object
CommandListener
{
val
commandChannel
:
Queue
<
String
>
=
LinkedBlockingQueue
<
String
>()
fun
start
()
{
fun
start
()
{
thread
{
thread
{
//
processNextCommandLine()
processNextCommandLine
()
}
}
}
}
tailrec
fun
processNextCommandLine
()
{
tailrec
fun
processNextCommandLine
()
{
var
fullCommand
=
readLine
()
var
fullCommand
=
commandChannel
.
poll
()
if
(
fullCommand
!=
null
)
{
if
(
fullCommand
!=
null
)
{
if
(!
fullCommand
.
startsWith
(
"/"
))
{
if
(!
fullCommand
.
startsWith
(
"/"
))
{
fullCommand
=
"/$fullCommand"
fullCommand
=
"/$fullCommand"
...
@@ -283,11 +286,14 @@ class MiraiConsoleLoader {
...
@@ -283,11 +286,14 @@ class MiraiConsoleLoader {
companion
object
{
companion
object
{
@JvmStatic
@JvmStatic
fun
main
(
args
:
Array
<
String
>)
{
fun
main
(
args
:
Array
<
String
>)
{
Security
.
removeProvider
(
"BC"
)
Security
.
addProvider
(
BouncyCastleProvider
())
//Security.addProvider(BouncyCastle)
MiraiConsoleUI
.
start
()
MiraiConsole
.
start
()
MiraiConsole
.
start
()
Runtime
.
getRuntime
().
addShutdownHook
(
thread
(
start
=
false
)
{
Runtime
.
getRuntime
().
addShutdownHook
(
thread
(
start
=
false
)
{
MiraiConsole
.
stop
()
MiraiConsole
.
stop
()
})
})
}
}
}
}
}
}
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsoleUI.kt
View file @
2ed0411c
...
@@ -168,6 +168,7 @@ object MiraiConsoleUI {
...
@@ -168,6 +168,7 @@ object MiraiConsoleUI {
update
()
update
()
}
}
KeyType
.
Enter
->
{
KeyType
.
Enter
->
{
MiraiConsole
.
CommandListener
.
commandChannel
.
offer
(
commandBuilder
.
toString
())
emptyCommand
()
emptyCommand
()
}
}
else
->
{
else
->
{
...
@@ -290,8 +291,6 @@ object MiraiConsoleUI {
...
@@ -290,8 +291,6 @@ object MiraiConsoleUI {
if
(
currentHeight
+
heightNeed
>
maxHeight
)
{
if
(
currentHeight
+
heightNeed
>
maxHeight
)
{
cleanPage
()
cleanPage
()
}
}
textGraphics
.
foregroundColor
=
TextColor
.
ANSI
.
GREEN
textGraphics
.
backgroundColor
=
TextColor
.
ANSI
.
DEFAULT
val
width
=
terminal
.
terminalSize
.
columns
-
7
val
width
=
terminal
.
terminalSize
.
columns
-
7
var
x
=
string
var
x
=
string
while
(
true
)
{
while
(
true
)
{
...
@@ -306,6 +305,8 @@ object MiraiConsoleUI {
...
@@ -306,6 +305,8 @@ object MiraiConsoleUI {
}
}
}
}
try
{
try
{
textGraphics
.
foregroundColor
=
TextColor
.
ANSI
.
GREEN
textGraphics
.
backgroundColor
=
TextColor
.
ANSI
.
DEFAULT
textGraphics
.
putString
(
3
,
currentHeight
,
toWrite
,
SGR
.
ITALIC
)
textGraphics
.
putString
(
3
,
currentHeight
,
toWrite
,
SGR
.
ITALIC
)
}
catch
(
ignored
:
Exception
)
{
}
catch
(
ignored
:
Exception
)
{
//
//
...
@@ -401,11 +402,23 @@ object MiraiConsoleUI {
...
@@ -401,11 +402,23 @@ object MiraiConsoleUI {
}
}
var
lastEmpty
:
Job
?
=
null
private
fun
emptyCommand
()
{
private
fun
emptyCommand
()
{
commandBuilder
=
StringBuilder
()
commandBuilder
=
StringBuilder
()
redrawCommand
()
if
(
terminal
is
SwingTerminal
)
{
if
(
terminal
is
SwingTerminal
)
{
redrawCommand
()
terminal
.
flush
()
terminal
.
flush
()
}
else
{
lastEmpty
=
GlobalScope
.
launch
{
delay
(
100
)
if
(
lastEmpty
==
coroutineContext
[
Job
])
{
terminal
.
clearScreen
()
//inited = false
update
()
redrawCommand
()
redrawLogs
(
log
[
screens
[
currentScreenId
]]
!!
)
}
}
}
}
}
}
...
...
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