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
ab160776
Commit
ab160776
authored
Feb 16, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename console
parent
9c74e27d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
41 deletions
+103
-41
mirai-console/build.gradle.kts
mirai-console/build.gradle.kts
+0
-1
mirai-console/src/main/kotlin/net/mamoe/mirai/console/Command.kt
...onsole/src/main/kotlin/net/mamoe/mirai/console/Command.kt
+2
-2
mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsole.kt
...e/src/main/kotlin/net/mamoe/mirai/console/MiraiConsole.kt
+32
-10
mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleUI.kt
...src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleUI.kt
+34
-15
mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/ConfigSection.kt
...n/kotlin/net/mamoe/mirai/console/plugins/ConfigSection.kt
+19
-5
mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/PluginBase.kt
...main/kotlin/net/mamoe/mirai/console/plugins/PluginBase.kt
+15
-7
mirai-plugins/image-sender/src/main/java/net/mamoe/mirai/imageplugin/ImageSenderMain.kt
.../main/java/net/mamoe/mirai/imageplugin/ImageSenderMain.kt
+1
-1
No files found.
mirai-console/build.gradle.kts
View file @
ab160776
...
...
@@ -7,7 +7,6 @@ plugins {
apply
(
plugin
=
"com.github.johnrengelman.shadow"
)
apply
(
plugin
=
"java-library"
)
tasks
.
withType
<
com
.
github
.
jengelman
.
gradle
.
plugins
.
shadow
.
tasks
.
ShadowJar
>()
{
manifest
{
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/Command.kt
→
mirai-console/src/main/kotlin/net/mamoe/mirai/
console/
Command.kt
View file @
ab160776
package
net.mamoe.mirai
package
net.mamoe.mirai
.console
/*
* Copyright 2020 Mamoe Technologies and contributors.
...
...
@@ -9,7 +9,7 @@ package net.mamoe.mirai
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
import
net.mamoe.mirai.plugins.PluginManager
import
net.mamoe.mirai.
console.
plugins.PluginManager
object
CommandManager
{
private
val
registeredCommand
:
MutableMap
<
String
,
ICommand
>
=
mutableMapOf
()
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsole.kt
→
mirai-console/src/main/kotlin/net/mamoe/mirai/
console/
MiraiConsole.kt
View file @
ab160776
package
net.mamoe.mirai
package
net.mamoe.mirai
.console
/*
* Copyright 2020 Mamoe Technologies and contributors.
...
...
@@ -13,10 +13,12 @@ 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.loadAsConfig
import
net.mamoe.mirai.plugins.withDefaultWrite
import
net.mamoe.mirai.plugins.withDefaultWriteSave
import
net.mamoe.mirai.console.plugins.PluginManager
import
net.mamoe.mirai.console.plugins.loadAsConfig
import
net.mamoe.mirai.console.plugins.withDefaultWrite
import
net.mamoe.mirai.console.plugins.withDefaultWriteSave
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.alsoLogin
import
net.mamoe.mirai.utils.SimpleLogger
import
org.bouncycastle.jce.provider.BouncyCastleProvider
import
java.io.File
...
...
@@ -52,7 +54,11 @@ object MiraiConsole {
fun
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
(
"Mirai-console now running under "
+
System
.
getProperty
(
"user.dir"
)
)
logger
(
"Get news in github: https://github.com/mamoe/mirai"
)
logger
(
"Mirai为开源项目,请自觉遵守开源项目协议"
)
logger
(
"Powered by Mamoe Technologies and contributors"
)
...
...
@@ -113,10 +119,18 @@ object MiraiConsole {
try
{
runBlocking
{
Bot
(
qqNumber
,
qqPassword
).
alsoLogin
()
logger
(
"[Bot Login]"
,
0
,
"$qqNumber login successes"
)
logger
(
"[Bot Login]"
,
0
,
"$qqNumber login successes"
)
}
}
catch
(
e
:
Exception
)
{
logger
(
"[Bot Login]"
,
0
,
"$qqNumber login failed -> "
+
e
.
message
)
logger
(
"[Bot Login]"
,
0
,
"$qqNumber login failed -> "
+
e
.
message
)
e
.
printStackTrace
()
}
true
...
...
@@ -224,7 +238,11 @@ object MiraiConsole {
description
=
"About Mirai-Console"
onCommand
{
logger
(
"v$version $build is still in testing stage, majority feature is available"
)
logger
(
"now running under "
+
System
.
getProperty
(
"user.dir"
))
logger
(
"now running under "
+
System
.
getProperty
(
"user.dir"
)
)
logger
(
"在Github中获取项目最新进展: https://github.com/mamoe/mirai"
)
logger
(
"Mirai为开源项目,请自觉遵守开源项目协议"
)
logger
(
"Powered by Mamoe Technologies and contributors"
)
...
...
@@ -259,7 +277,11 @@ object MiraiConsole {
object
UIPushLogger
{
operator
fun
invoke
(
any
:
Any
?
=
null
)
{
invoke
(
"[Mirai$version $build]"
,
0L
,
any
)
invoke
(
"[Mirai$version $build]"
,
0L
,
any
)
}
operator
fun
invoke
(
identityStr
:
String
,
identity
:
Long
,
any
:
Any
?
=
null
)
{
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/MiraiConsoleUI.kt
→
mirai-console/src/main/kotlin/net/mamoe/mirai/
console/
MiraiConsoleUI.kt
View file @
ab160776
package
net.mamoe.mirai
package
net.mamoe.mirai
.console
import
com.googlecode.lanterna.SGR
import
com.googlecode.lanterna.TerminalSize
...
...
@@ -16,9 +16,9 @@ import kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
net.mamoe.mirai.MiraiConsoleUI.LoggerDrawer.cleanPage
import
net.mamoe.mirai.MiraiConsoleUI.LoggerDrawer.drawLog
import
net.mamoe.mirai.MiraiConsoleUI.LoggerDrawer.redrawLogs
import
net.mamoe.mirai.
console.
MiraiConsoleUI.LoggerDrawer.cleanPage
import
net.mamoe.mirai.
console.
MiraiConsoleUI.LoggerDrawer.drawLog
import
net.mamoe.mirai.
console.
MiraiConsoleUI.LoggerDrawer.redrawLogs
import
java.awt.Font
import
java.io.OutputStream
import
java.io.PrintStream
...
...
@@ -42,8 +42,10 @@ object MiraiConsoleUI {
val
cacheLogSize
=
50
val
log
=
mutableMapOf
<
Long
,
LimitLinkedQueue
<
String
>>().
also
{
it
[
0L
]
=
LimitLinkedQueue
(
cacheLogSize
)
it
[
2821869985L
]
=
LimitLinkedQueue
(
cacheLogSize
)
it
[
0L
]
=
LimitLinkedQueue
(
cacheLogSize
)
it
[
2821869985L
]
=
LimitLinkedQueue
(
cacheLogSize
)
}
val
botAdminCount
=
mutableMapOf
<
Long
,
Long
>()
...
...
@@ -54,7 +56,8 @@ object MiraiConsoleUI {
fun
addBotScreen
(
uin
:
Long
)
{
screens
.
add
(
uin
)
log
[
uin
]
=
LimitLinkedQueue
(
cacheLogSize
)
log
[
uin
]
=
LimitLinkedQueue
(
cacheLogSize
)
botAdminCount
[
uin
]
=
0
}
...
...
@@ -173,19 +176,23 @@ object MiraiConsoleUI {
when
(
keyStroke
.
keyType
)
{
KeyType
.
ArrowLeft
->
{
currentScreenId
=
getLeftScreenId
()
currentScreenId
=
getLeftScreenId
()
clearRows
(
2
)
cleanPage
()
update
()
}
KeyType
.
ArrowRight
->
{
currentScreenId
=
getRightScreenId
()
currentScreenId
=
getRightScreenId
()
clearRows
(
2
)
cleanPage
()
update
()
}
KeyType
.
Enter
->
{
MiraiConsole
.
CommandListener
.
commandChannel
.
offer
(
commandBuilder
.
toString
())
MiraiConsole
.
CommandListener
.
commandChannel
.
offer
(
commandBuilder
.
toString
()
)
emptyCommand
()
}
else
->
{
...
...
@@ -232,7 +239,11 @@ object MiraiConsoleUI {
fun
clearRows
(
row
:
Int
)
{
textGraphics
.
putString
(
0
,
row
,
" "
.
repeat
(
terminal
.
terminalSize
.
columns
))
textGraphics
.
putString
(
0
,
row
,
" "
.
repeat
(
terminal
.
terminalSize
.
columns
)
)
}
fun
drawFrame
(
...
...
@@ -257,7 +268,8 @@ object MiraiConsoleUI {
textGraphics
.
foregroundColor
=
TextColor
.
ANSI
.
DEFAULT
textGraphics
.
backgroundColor
=
TextColor
.
ANSI
.
DEFAULT
val
leftName
=
getScreenName
(
getLeftScreenId
())
val
leftName
=
getScreenName
(
getLeftScreenId
())
// clearRows(2)
textGraphics
.
putString
((
width
-
title
.
length
)
/
2
-
"$leftName << "
.
length
,
2
,
"$leftName << "
)
textGraphics
.
foregroundColor
=
TextColor
.
ANSI
.
WHITE
...
...
@@ -265,7 +277,8 @@ object MiraiConsoleUI {
textGraphics
.
putString
((
width
-
title
.
length
)
/
2
,
2
,
title
,
SGR
.
BOLD
)
textGraphics
.
foregroundColor
=
TextColor
.
ANSI
.
DEFAULT
textGraphics
.
backgroundColor
=
TextColor
.
ANSI
.
DEFAULT
val
rightName
=
getScreenName
(
getRightScreenId
())
val
rightName
=
getScreenName
(
getRightScreenId
())
textGraphics
.
putString
((
width
+
title
.
length
)
/
2
+
1
,
2
,
">> $rightName"
)
}
...
...
@@ -324,7 +337,10 @@ object MiraiConsoleUI {
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
)
{
//
}
...
...
@@ -449,7 +465,10 @@ object MiraiConsoleUI {
drawMainFrame
(
screens
.
size
-
1
)
}
else
->
{
drawBotFrame
(
screens
[
currentScreenId
],
0
)
drawBotFrame
(
screens
[
currentScreenId
],
0
)
}
}
redrawLogs
(
log
[
screens
[
currentScreenId
]]
!!
)
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/plugins/ConfigSection.kt
→
mirai-console/src/main/kotlin/net/mamoe/mirai/
console/
plugins/ConfigSection.kt
View file @
ab160776
...
...
@@ -7,7 +7,7 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package
net.mamoe.mirai.plugins
package
net.mamoe.mirai.
console.
plugins
import
com.alibaba.fastjson.JSON
import
com.alibaba.fastjson.JSONObject
...
...
@@ -55,7 +55,14 @@ interface Config {
companion
object
{
fun
load
(
fileName
:
String
):
Config
{
return
load
(
File
(
fileName
.
replace
(
"//"
,
"/"
)))
return
load
(
File
(
fileName
.
replace
(
"//"
,
"/"
)
)
)
}
fun
load
(
file
:
File
):
Config
{
...
...
@@ -115,7 +122,12 @@ inline fun <reified T : Any> Config.withDefault(
inline
fun
<
reified
T
:
Any
>
Config
.
withDefaultWrite
(
noinline
defaultValue
:
()
->
T
):
WithDefaultWriteLoader
<
T
>
{
return
WithDefaultWriteLoader
(
T
::
class
,
this
,
defaultValue
,
false
)
return
WithDefaultWriteLoader
(
T
::
class
,
this
,
defaultValue
,
false
)
}
/* 带有默认值且如果为空会写入保存的代理 */
...
...
@@ -258,7 +270,8 @@ interface ConfigSection : Config, MutableMap<String, Any> {
}
@Serializable
open
class
ConfigSectionImpl
()
:
ConcurrentHashMap
<
String
,
Any
>(),
ConfigSection
{
open
class
ConfigSectionImpl
()
:
ConcurrentHashMap
<
String
,
Any
>(),
ConfigSection
{
override
fun
set
(
key
:
String
,
value
:
Any
)
{
super
.
put
(
key
,
value
)
}
...
...
@@ -310,7 +323,8 @@ interface FileConfig : Config {
abstract
class
FileConfigImpl
internal
constructor
(
private
val
file
:
File
)
:
FileConfig
,
ConfigSection
{
)
:
FileConfig
,
ConfigSection
{
private
val
content
by
lazy
{
deserialize
(
file
.
readText
())
...
...
mirai-console/src/main/kotlin/net/mamoe/mirai/plugins/PluginBase.kt
→
mirai-console/src/main/kotlin/net/mamoe/mirai/
console/
plugins/PluginBase.kt
View file @
ab160776
...
...
@@ -7,11 +7,11 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package
net.mamoe.mirai.plugins
package
net.mamoe.mirai.
console.
plugins
import
net.mamoe.mirai.ICommand
import
net.mamoe.mirai.
console.
ICommand
import
kotlinx.coroutines.*
import
net.mamoe.mirai.MiraiConsole
import
net.mamoe.mirai.
console.
MiraiConsole
import
net.mamoe.mirai.utils.DefaultLogger
import
net.mamoe.mirai.utils.MiraiLogger
import
net.mamoe.mirai.utils.SimpleLogger
...
...
@@ -146,7 +146,14 @@ class PluginDescription(
depends
.
add
(
line
.
substringAfter
(
"-"
).
trim
())
}
}
return
PluginDescription
(
name
,
author
,
basePath
,
version
,
info
,
depends
)
return
PluginDescription
(
name
,
author
,
basePath
,
version
,
info
,
depends
)
}
}
}
...
...
@@ -194,7 +201,8 @@ object PluginManager {
logger
.
info
(
"plugin.yml not found in jar "
+
jar
.
name
+
", it will not be consider as a Plugin"
)
}
else
{
val
description
=
PluginDescription
.
readFromContent
(
URL
(
"jar:file:"
+
file
.
absoluteFile
+
"!/"
+
pluginYml
.
name
).
openConnection
().
inputStream
.
use
{
PluginDescription
.
readFromContent
(
URL
(
"jar:file:"
+
file
.
absoluteFile
+
"!/"
+
pluginYml
.
name
).
openConnection
().
inputStream
.
use
{
it
.
readBytes
().
encodeToString
()
})
pluginsFound
[
description
.
name
]
=
description
...
...
mirai-plugins/image-sender/src/main/java/net/mamoe/mirai/imageplugin/ImageSenderMain.kt
View file @
ab160776
...
...
@@ -14,7 +14,7 @@ import kotlinx.coroutines.GlobalScope
import
net.mamoe.mirai.event.events.BotOnlineEvent
import
net.mamoe.mirai.event.subscribeAlways
import
net.mamoe.mirai.event.subscribeMessages
import
net.mamoe.mirai.plugins.PluginBase
import
net.mamoe.mirai.
console.
plugins.PluginBase
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
class
ImageSenderMain
:
PluginBase
()
{
...
...
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