Commit Graph

3149 Commits

Author SHA1 Message Date
AdoptOSS
dc747ea438 fix: platform socket on Windows (#2121)
* fix: platform socket on Windows

* fix(workflow): use win platform ssl provider instead of openssl for cURL
openssl can't use system's native CA store by default
2022-07-20 00:30:16 +08:00
Him188
2022074007 Minor docs update for NetworkHandler 2022-07-20 00:30:16 +08:00
AdoptOSS
7325c1f7e2 native: 优化 build script 及 actions,修复 ECDH 相关资源释放问题 (#2110)
* build: fix build on Windows

* test: fix ContentEqualsTest on native

* build: allow disabling targets with property

* fix: free ECDH-related resources properly on native
avoid memory leaking (usually on *nix) or crash (usually on Windows)

Signed-off-by: AdoptOSS <adoptoss@outlook.com>

* build(workflow): remove invalid options

* fix(styling): `mirai.target` property

* build(workflow): try to limit memory usage during mirai-console:tools:gradle-plugin:integTest

* enhance(test): use buildList

* build(workflow): retry

Co-authored-by: ArcticLampyrid <arcticlampyrid@outlook.com>
2022-07-20 00:30:16 +08:00
Him188
afedbdad7b Fix services 2022-07-20 00:30:16 +08:00
Him188
f962618bee Fix compiler warnings 2022-07-20 00:30:16 +08:00
Him188
21c4a5ba04 Use kotlinx-coroutines-test 2022-07-20 00:30:16 +08:00
Him188
e1123e9a96 Move AudioTest to message/data 2022-07-20 00:30:16 +08:00
Him188
0f26dbff5c Add test for test Audio extraData 2022-07-20 00:30:16 +08:00
Him188
cca40b8aa3 Add dummy jvmBase target for IDE 2022-07-20 00:30:16 +08:00
Him188
7dbb1a5ad7 Add RunConfigurations 2022-07-20 00:30:16 +08:00
Him188
fe0a4de368 Produce shared libraries and static libraries 2022-07-20 00:30:16 +08:00
Him188
dab703869f core: Close and join all jobs after each test 2022-07-20 00:30:16 +08:00
Him188
4c6b879873 Upgrade to Ktor 2.0.2, use CIO engine for linux targets; Remove ktor-client-okhttp from mirai-core-api jvmBaseMain
Use Input.readAllText instead of Input.readText, because readText only reads one buffer.
#2084
2022-07-20 00:30:16 +08:00
Him188
7836b2a4b3 Broadcast BotOfflineEvent.Active after state OK -> CLOSED 2022-07-20 00:30:16 +08:00
Him188
c260abb6f3 Cancel TestEventDispatcher jobs after test 2022-07-20 00:30:16 +08:00
Him188
a964f7ee87 Improve core network stability:
Close network and do logout only if networkInitialized

core, network: Guard changing state

core, network: Protect state overriding when setting a state

Always close NetworkHandlerSupport even if CommonNetworkHandler is in CLOSED state
2022-07-20 00:30:16 +08:00
Him188
2f537f90b4 Use different types for TestState 2022-07-20 00:30:16 +08:00
Him188
daf9c4a208 Configure GitHub Actions for native 2022-07-20 00:30:16 +08:00
Him188
21d883b630 Introduce higher performance compression/decompression methods for different purposes for common 2022-07-20 00:30:16 +08:00
Him188
89fa379f8f Add native test entrance 2022-07-20 00:30:16 +08:00
Him188
d27228c8c8 Rewrite MessageSerializers, register serializers in each MessageProtocol, implement for native targets 2022-07-20 00:30:16 +08:00
Him188
13dadd5a95 Implement mirai-core for native 2022-07-20 00:30:16 +08:00
Him188
7088835402 HMPP 2022-07-20 00:30:16 +08:00
Him188
92942c1037 Improve setState stability 2022-07-20 00:30:16 +08:00
Him188
ff2a8acb0c Implement multiplatform modules 2022-07-20 00:30:16 +08:00
Him188
ce87400998 Use ktor-io to replace kotlinx-io 2022-07-20 00:30:16 +08:00
Him188
0571be1a55 Commonize projects: mirai-core series, and mirai-console-compiler-annotations 2022-07-20 00:30:16 +08:00
Him188
d96641dedb Configure HMPP project structure 2022-07-20 00:30:16 +08:00
Karlatemp
0e1585e898
Fix senderName render of ForwardMessage; fix #2143 2022-07-09 10:59:41 +08:00
sandtechnology
057708e637
Fix broken image and gif issue (#2114)
* Try to fix broken image issue #1699

* Re-add deleted comma at tail
2022-07-01 09:00:27 +08:00
Him188
2dcff0cf45
Reduce unnecessary logs from packetLogger 2022-06-14 11:22:04 +01:00
Him188
a4e7fda416
Raise deprecation level for 2.12 2022-06-14 11:19:44 +01:00
Him188
9df7c4bda4
Update RunNoticeRecorder 2022-06-14 10:49:48 +01:00
Him188
297592b9f2 Do not throw exception when failed to locate desensitization rules, for tests on CI 2022-05-25 22:39:53 +01:00
Him188
c4a2f19db6 Use empty internalIds for all OnlineMessageSourceToGroupImpl to speed up tests. 2022-05-25 22:39:53 +01:00
Him188
ab3280f6b7 Add more MessageProtocolTest:
Add fragmented test

Fix MusicShareProtocol and implement sending tests for MusicShareProtocolTest

OutgoingMessagePipelineImpl: set stopWhenConsumed

Fix `currentMessageChain` not updated in `processAlso`, add strong message packets checks, add tests for converting messages failed to send at FIRST step to LongMessageInternal

Add notes for receiving ForwardMessage

Add facade parameters to `download ForwardMessage*`

Add ForwardMessageProtocolTest

Add QuoteReplyProtocolTest

Add CONTAINING_MSG for MessageDecoderContext.attributes, for information-use only

Fix MessageReceiptTest

Fix QuoteReplyProtocolTest
2022-05-25 22:39:53 +01:00
Him188
c75d1f7074 Add MessageSource.isOriginalMessageInitialized 2022-05-25 22:39:53 +01:00
Him188
c8fb354d13 Add LongMessageProtocolTest and various improvements:
Change attributes carrying helper objects to components

Make ClockHolder open

Use originalMessage for MessageReceipt
2022-05-25 22:39:53 +01:00
Him188
112ce644b4 Add preprocessAndSendOutgoingImpl for tests only 2022-05-25 22:39:53 +01:00
Him188
d5ef2aae64 Add MessageProtocolStrategy.sendPacket 2022-05-25 22:39:53 +01:00
Him188
c510a49adc Generalize ImagePatcher 2022-05-25 22:39:53 +01:00
Him188
52968b172f Rename buildChecks to buildCodingChecks 2022-05-25 22:39:53 +01:00
Him188
3270192715 Remove SendMessageHandler and introduce OutgoingMessagePipeline. 2022-05-25 22:39:53 +01:00
Him188
e6b094031c Re-categorize MessageProtocol packages 2022-05-25 22:39:53 +01:00
Him188
9d03260067 Add CustomMessageProtocolTest 2022-05-25 22:39:53 +01:00
Him188
4b79c197e7 Filter out customElem without MIRAI_CUSTOM_ELEM_TYPE 2022-05-25 22:39:53 +01:00
Him188
617b32aa14 Use constant value for MIRAI_CUSTOM_ELEM_TYPE 2022-05-25 22:39:53 +01:00
Him188
1407bcf251 Fix VipFace and add VipFaceProtocolTest 2022-05-25 22:39:53 +01:00
Him188
2dac3b5d92 Add FileMessage tests 2022-05-25 22:39:53 +01:00
Him188
24243e917e Make FileMessage.toString more clear 2022-05-25 22:39:53 +01:00
Him188
50c5ec0456 NoticeProcessorPipeline: desensitize debug logs 2022-05-25 22:39:53 +01:00
Him188
8b6b06ea3b Adapt desensitize in StructureToStringTransformer 2022-05-25 22:39:53 +01:00
Him188
796df9b79f Change Image.toString format to contain more information 2022-05-25 22:39:53 +01:00
Him188
149b77c05b Desensitize LightAppElem.data 2022-05-25 22:39:53 +01:00
Him188
94e49520d7 Move StructureToStringTransformerNew and its relevant files from jvmTest to commonTest 2022-05-25 22:39:53 +01:00
Him188
08d1fc1f38 Add more MessageProtocolTest 2022-05-25 22:39:53 +01:00
Him188
b4f042ae1b Add ImagePatcher for AbstractMockNetworkHandlerTest.components 2022-05-25 22:39:53 +01:00
Him188
67f3b8dee8 Image.equals: compare all properties rather than imageId only 2022-05-25 22:39:53 +01:00
Him188
90deacb692 Fix imageType sent from macOS client, fix #1111 2022-05-25 22:39:53 +01:00
Him188
05aa3c8026 Add ContactOrBot.inferMessageSourceKind 2022-05-25 22:39:53 +01:00
Him188
573473735c Rename RunRecorder to RunNoticeRecorder 2022-05-25 22:39:53 +01:00
Him188
7e87376930 Move toMessageChain and toRichTextElems to MessageProtocolFacade 2022-05-25 22:39:53 +01:00
Him188
a89f6aeaef Integrate new MessageProtocol with existing code 2022-05-25 22:39:53 +01:00
Him188
c47779c726 MessageProtocol implementations 2022-05-25 22:39:53 +01:00
Him188
d6343870b8 MessageProtocol pipeline infrastructure 2022-05-25 22:39:53 +01:00
Him188
0b52c2bb5a Generalize NoticeProcessorPipeline as ProcessorPipeline 2022-05-25 22:39:53 +01:00
Him188
0cef98dec0 Fix OfflineAudioFactory configuration 2022-05-25 22:39:53 +01:00
Him188
287769799a Enable kotlin-dynamic-delegation in mirai-core and mirai-core-api 2022-05-25 22:39:53 +01:00
Him188
7251d87621 Optimize processForwardMessage 2022-05-25 22:39:53 +01:00
Him188
0c708c8197 Redesign MessageChain hierarchy: Add LinearMessageChainImpl and CombinedMessage 2022-05-25 22:39:53 +01:00
Him188
c118180b54 Move messages implementations other than InternalFlagOnlyMessage from .message to .message.data 2022-05-25 22:39:53 +01:00
Him188
255bfafeed Move InternalFlagOnlyMessage implementations from .message to .message.flags 2022-05-25 22:39:53 +01:00
Him188
68c36669fc Rearrange Image implementations into multiple files 2022-05-25 22:39:53 +01:00
Him188
27daf62ba5 Move Image implementations from .message to .message.image 2022-05-25 22:39:53 +01:00
Him188
c30b3a285a Move MessageSource implementations from .message to .message.source 2022-05-25 22:39:53 +01:00
Him188
a9516b401b Generalize chineseLength to mirai-core-utils 2022-05-25 22:39:53 +01:00
Him188
3955546868 Add MessageVisitor, MessageVisitorEx, Message.accept and Message.acceptChildren as internal API 2022-05-25 22:39:53 +01:00
Him188
c3f94a66d6
Remove legacy sendAndExpect to reduce code complexity to avoid compiler bugs, fix #2049 2022-05-25 20:36:58 +01:00
Him188
753342d99e
Add timeout for logout on close 2022-05-21 15:21:07 +01:00
Him188
4495e36e7c Fix event broadcast directly without checks. Add notes for broadcasting an event. 2022-05-16 19:14:14 +01:00
Him188
f83d20bed9 Enable EventLaunchUndispatchedTest 2022-05-16 19:14:14 +01:00
Him188
e0140c6272 Remove useless sub test in NettyHandlerEventTest 2022-05-16 19:14:14 +01:00
Him188
c7ff26ab19 Assign different bot ids for each test bot instance 2022-05-16 19:14:14 +01:00
Him188
5deee909a9 StateObserver: Make beforeStateResume and afterStateResume suspend 2022-05-16 19:14:14 +01:00
Him188
bdf125e26d Broadcast BotOfflineEvent async and ensure joinBroadcast works for it 2022-05-16 19:14:14 +01:00
Him188
da65f4d86d Run login recovery in EventDispatcher's scope 2022-05-16 19:14:14 +01:00
Him188
baf6c35e46 Wait async connector in SelectorRecoveryTest 2022-05-16 19:14:14 +01:00
Him188
ac1fc887c5 Close test bot instance after each test 2022-05-16 19:14:14 +01:00
Him188
8ac5b2d8c0 Do not set mirai.event.trace by default 2022-05-16 19:14:14 +01:00
Him188
4e57c21646 SingleEntrantLock: use reference comparison 2022-05-16 19:14:14 +01:00
Him188
1c7e3bc5a1 Revise exception handling in NetworkHandler, involving:
- HeartbeatProcessor
- HeartbeatFailedException: IOException is not recoverable, since this is not even thrown
2022-05-16 19:14:14 +01:00
Him188
0c809f4e4c Remove internal EventBroadcast, code cleanup 2022-05-16 19:14:14 +01:00
Him188
1d2ae12196 Log events properly in EventChannelImpl 2022-05-16 19:14:14 +01:00
Him188
4c28913a27 Migrate use of GlobalEventChannels in tests to use scoped ones 2022-05-16 19:14:14 +01:00
Him188
c61a79e299 Add trace logging for event listener, with system property mirai.event.trace 2022-05-16 19:14:14 +01:00
Him188
c391d3f886 Refine nextEvent and syncFromEvent: handle exceptions correctly 2022-05-16 19:14:14 +01:00
Him188
30dbd1b1c2 Pass exceptions caught in subscriber context to subscriber only 2022-05-16 19:14:14 +01:00
Him188
c192047361 Move event implementations to EventDispatcher and add EventChannel.asFlow. 2022-05-16 19:14:14 +01:00
ryoii
bc8fea2195
Fix AbsoluteFolder.resolveFileById for recursive (#2033)
```kotlin
@Test
    fun testFirst() {
        val f = { a: Int ->
            if (a > 0) a
            else null
        }

        val a = listOf<Int>(-1, -2, -1, -1)
        
        assertEquals(
            a.map{ f(it) }.firstOrNull(),
            null
        )
    }
```
2022-05-15 18:48:52 +01:00
Him188
0d3bc9c684 Fix HB logic: catch TimeoutCancellationException from HB action and report it as non-fatal error. Fix #2024 2022-05-09 08:58:47 +01:00
Him188
71fb5585fe Update docs for NetworkHandler 2022-05-08 09:56:27 +01:00
Him188
b16b3a58ac sendAndExpect: complete the result of the listener with last exception only if it has not yet completed. Maybe fix #2006. 2022-05-06 15:51:44 +01:00
Him188
4fa853065c Add BotConfiguration.disableAccountSecretes 2022-05-02 14:01:53 +01:00
Him188
3a4a8d01a3 Fix test can auto log 2022-05-02 11:20:23 +01:00
Him188
2a417445a7 Invalidate account.secretes on failure to lo in 2022-05-02 10:15:02 +01:00
Him188
ed37609731 Fix TarsInput, fix #1998 2022-05-02 09:59:51 +01:00
Him188
d757764308 Remove MiraiImpl.INSTANCE and move initialization process to MiraiImpl.<clinit>. Close #1992 2022-04-25 15:49:43 +01:00
Him188
3be16c4644 Code cleanup. Remove duplicated internal utilities. 2022-04-25 14:15:29 +01:00
Him188
e7dcf676fc Handle leading length for ByteArray.loadAs, fix deserialization problem with RequestPush. Fix #1991, #1899. 2022-04-25 14:06:31 +01:00
Him188
7f85319a92 Deprecate BotConfiguration.json 2022-04-24 15:30:02 +01:00
Him188
4efdc98cc4 Update docs for NetworHandle.close. 2022-04-24 12:39:50 +01:00
Him188
a5b52a0b7b Network: change state initialization and update sequence:
- Do nothing in init block
- Start state after notifying  `beforeStateChanged`
- StateClosed: do close after being updated to public

close #1893
2022-04-24 12:35:34 +01:00
Him188
88e1146edc Handle exceptions in heartbeat jobs properly, #1893 2022-04-24 12:14:20 +01:00
Him188
f5f7b3736c Show bot id in coroutine name for heartbeat jobs 2022-04-24 11:47:06 +01:00
Him188
4acd74974a Migrate deprecated usages and cleanup code 2022-04-13 13:08:14 +01:00
Him188
8993de9a13 Review deprecation for 2.11, close #1837 2022-04-13 12:47:21 +01:00
Him188
d1cb05025e Deprecated IMirai.Http for future removal 2022-04-13 12:08:39 +01:00
Him188
b4bb1696de Fix commit 'Don't mark failed if received MessageSvcPushForceOffline
' (332e03377c)

The original commit was to fix the problem when receiving MessageSvcPushForceOffline on first login, which calls `setLoginHalted`, and stops the login process.
2022-04-13 11:50:32 +01:00
Karlatemp
efd864449e
Try to fix CI 2022-04-09 16:44:50 +08:00
Karlatemp
332e03377c
Don't mark failed if received MessageSvcPushForceOffline 2022-04-08 12:06:22 +08:00
Him188
e387d4b4a5 Abort first login if any error occurred. Fix #1963 2022-04-06 16:18:10 +01:00
Him188
a96f9cc8e2 PrivateMessageProcessor: ignore processing if FROM_SYNC is absent 2022-04-06 15:51:02 +01:00
Him188
2a8f7de23d Throw SendMessageFailedException with new reason AT_ALL_LIMITED, fix #1948 2022-04-02 13:24:30 +01:00
Him188
7bb788a2cf Relogin when receiving returnCode <= -10000, fix #1961 2022-04-02 13:16:01 +01:00
Karlatemp
7c87f2869b
Fix tests 2022-03-30 15:01:07 +08:00
Karlatemp
629226553c
Fix debug message leak; fix #1955 2022-03-30 14:38:53 +08:00
Karlatemp
cf39a628a2
Drop emoji when rendering at; fix #1938 2022-03-27 21:49:04 +08:00
Him188
ceb192937f Automatically produce detailed logs when failed to decode JceStructs, if 'mirai.jce.deserializer.debug' is set to true, helps #1899 2022-03-16 15:34:12 +00:00
微莹·纤绫
fa48507a78
Update issue report url 2022-02-19 21:22:03 +08:00
Karlatemp
7252879f46
Improve performance 2022-02-16 23:15:27 +08:00
Him188
92cd9e1712 Update copyright on OutgoingPacket.kt 2022-02-12 13:27:08 +00:00
Him188
1cc299431d Rename OutgoingPacketAndroid.kt in commonMain to OutgoingPacket.kt to eliminate ambiguity 2022-02-12 13:03:18 +00:00
Karlatemp
1d2c219b9d
Fix MessagePreSendEvent name; fix #1851 2022-02-09 22:21:09 +08:00
lz1998
e856a017a1 typo 2022-02-07 11:53:59 +00:00
Him188
bd71c486bd Fix botAsMemberInitialized, fix #1848 2022-01-22 15:04:00 +00:00
Him188
2d26f94769 Move AbstractImage, FriendImage, GroupImage from mirai-core-api to mirai-core, close #1670 2022-01-14 19:02:38 +00:00
Him188
4a32f03797 Add logging for uninitialized botAsMember on creating new GroupImpl instance. helps #1776 2022-01-14 18:45:25 +00:00
Him188
7d3971259d
Review deprecation for 2.10. close #1742 (#1774) 2022-01-14 18:26:44 +00:00
Him188
12999356e2 Prohibit sending FileMessage manually, except those from FileMessage.upload. close #1715 2022-01-14 18:21:50 +00:00
Him188
b52783d815 Fix BotOfflineEvent.Active not broadcast on bot.close, fix #1717 2022-01-14 17:57:22 +00:00
Him188
85b00f583b TestEventDispatcherImpl: ensure event is broadcast 2022-01-14 17:57:22 +00:00
Him188
920886434c Fix SafeStateObserver: add missing override beforeStateChanged 2022-01-14 17:57:22 +00:00
Him188
1ab48748ab Fix project structure for Dokka
Co-authored-by: 微莹·纤绫 <karlatemp@vip.qq.com>
2022-01-06 20:26:52 +00:00
Him188
3d864362aa Generalize binary validator 2022-01-06 20:26:52 +00:00
Him188
3844630550 Cleanup code 2022-01-06 20:07:22 +00:00
Him188
2a036d7bb3 Simplify buildscript: remove redundant comments 2022-01-06 04:46:58 +00:00
LaoLittle
0c964f3144
允许使用 IPAD 协议发送戳一戳 (#1711)
* 修改注释

* IPAD协议发送戳一戳时不抛出UnsupportedOperationException

* 修改注释

“安卓协议”的描述并不准确,ANDROID_PAD 也是安卓协议,但是完全不支持戳一戳
修改进行明确

* Apply suggestions from code review

* Update Nudge.kt

Co-authored-by: Initial-heart <63091661+Initial-heart-1@users.noreply.github.com>
Co-authored-by: Him188 <Him188@mamoe.net>
2022-01-06 01:16:42 +00:00
Karlatemp
6d16d77dad Secrets Protection 2022-01-03 17:38:34 +00:00
Karlatemp
09920d35ee
Fix size-less image sending; fix #1769 2021-12-30 22:51:49 +08:00
Karlatemp
1b7c1286ef
Fix migrate of soutv 2021-12-29 18:32:34 +08:00