Commit Graph

3084 Commits

Author SHA1 Message Date
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
Him188
55fe85473a Remove unused variables 2021-12-23 01:37:11 +00:00
Him188
7faf630454 Update kotlin-jvm-blocking-bridge to 2.0.0-160.2 2021-12-23 01:37:11 +00:00
Him188
46865721b0 Use new Duration methods 2021-12-23 01:37:11 +00:00
Him188
0f1227d401 Use Mutex than @Synchronized 2021-12-23 01:37:11 +00:00
Him188
df92607841 Use Mutex than @Synchronized 2021-12-23 01:37:11 +00:00
Him188
10af69f05e Filter out duplicated GroupTalkativeChangeEvent and relevant events with same subject. Fix #1707 2021-12-21 22:55:54 +00:00
Him188
aa53d92fbe Fix Desensitizer for NestedStructure 2021-12-21 22:22:15 +00:00
Him188
83d7c0d3d1 Add test for MemberJoinEvent.Active when request was accepted by bot 2021-12-21 22:21:41 +00:00
Him188
282f0b212c Ignore local test files 2021-12-21 19:19:17 +00:00
Him188
eb0bf21505 Fix FriendMessageSyncEvent, fix #1624 2021-12-21 19:18:57 +00:00
Him188
3a2663104b Rewrite and generalize ConstructorCallCodegen for multipurpose usage. 2021-12-21 18:46:25 +00:00
Him188
bf98ab7858 Move _contentToString outside mirai-core main sourceSets, and rename it to structureToString 2021-12-21 18:46:25 +00:00
Him188
68ec6d52e7 Fix FriendMessageSyncEvent, fix #1624 2021-12-21 03:32:27 +00:00
Him188
e202149c3a Improve AbstractNoticeProcessorTest 2021-12-21 03:32:27 +00:00
Him188
a7e0f1b288 Initialize ecKf before static-init for ECDH on Android, #1732 2021-12-15 21:14:29 +00:00
Him188
2367ee0fd9
Revert prohibition of sending file message: (#1716)
* Revert prohibition of sending file message:
- close #1715
- Report a warning in logging with stacktrace
- Show stacktrace only once

* Update util.kt
2021-12-06 15:32:51 +00:00
Him188
bc1cce313f
Support AbsoluteFolder.resolveFolderById (#1712)
* Support `AbsoluteFolder.resolveFolderById`

* resolveFolderById: Always return null when receiver is not root and id is not root
2021-12-06 15:23:27 +00:00
Karlatemp
561d333cc7
NetInternalKit 2021-12-05 18:28:44 +08:00
Him188
74fc5a5037 Throw specific SendMessageFailedException when reaching group chat limit, close #1220 2021-11-30 13:06:01 +00:00
Him188
a989ea9db1 Add SendMessageFailedException, change supertypes of MessageTooLargeException and BotIsBeingMutedException to the new exception 2021-11-30 13:06:01 +00:00
Him188
5b16414e9e Add note to NormalMemberImpl.kick 2021-11-26 18:21:48 +00:00
Him188
ca80f5285f Throw specific ISE when kicking members too fast, close #1503 2021-11-26 18:04:35 +00:00
Him188
8e8dd0e26b minor: Do not use Member but required properties in TroopManagement.Kick 2021-11-26 18:04:35 +00:00
Him188
25970cbf56 minor: move NormalMember.kick overloads from mirai-core to mirai-core-api 2021-11-26 17:59:07 +00:00
Him188
64920a399e Throw a specific exception when reaching maximum AtAll times limit, fix #1201 2021-11-26 17:31:35 +00:00
Him188
7c550bff7d
Add Image.Factory and Image.Builder for constructing Image inst… (#1673)
* Add `Image.Factory` and `Image.Builder` for constructing `Image` instances with specific properties. close #1672

* Remove redundant `create`s

* Add docs for `Image.Builder`

* Remove Image.Factory, use Image.Builder in all places.

* Fix cache & parameters

Co-authored-by: Karlatemp <karlatemp@vip.qq.com>
2021-11-20 23:36:14 +00:00
Karlatemp
a35a19ffcc
Fix LightApp refining; fix #1660 2021-11-20 18:15:09 +08:00
Karlatemp
511d1fa4f8
Fix NetReplayHelper [no ci] 2021-11-20 17:40:58 +08:00
Karlatemp
3da565ab02
AbstractRealTimeActionTestUnit 2021-11-19 23:12:09 +08:00
Karlatemp
813d8485b6 Fix AbsoluteFileFolder resolving with absolute path 2021-11-19 15:06:41 +00:00
sandtechnology
4e3873c3d3
Fix #1674, apply right nick and remark impl to contact design (#1678)
* Fix #1674, apply right nick and remark impl for contact design

* Fix build, add missed member impl

* Fix wrong delegate in AbstractMember impl

Co-authored-by: sandtechnology <a1294790523@hotmail.com>

Co-authored-by: Him188 <him188@mamoe.net>
2021-11-16 14:54:39 +00:00
Karlatemp
736f52275f
Drop InternalFlag in MessageReceipt 2021-11-16 22:12:02 +08:00
Him188
bd041e43d1
Support Image.isUploaded, (#1671)
* Support `Image.isUploaded`,
add member `Image.md5`,
add `Image.calculateImageMd5ByImageId`,
close #1401

* Update docs
2021-11-16 10:50:17 +00:00
Karlatemp
79d92a0114
Fix old RemoteFile uploading logic 2021-11-16 18:21:55 +08:00
Karlatemp
cf2b4a193c
Fix bytecode analyze 2021-11-16 18:13:22 +08:00
Karlatemp
42510d7c1c
Fix UserProfile.sign, fix #1620 2021-11-16 12:32:55 +08:00
Karlatemp
2422aa34b5
Add image caches; Fix deserialized image not rendering in ForwardMessage; fix #1507, fix #1636 2021-11-16 12:32:28 +08:00
Karlatemp
b5d8c708bd
Redesign MultiMsg; Support nested ForwardMessage sending; close #1198 2021-11-16 12:32:28 +08:00
Karlatemp
b42a57736d
Fix ServiceMessage not refined in ANDROID_WATCH; fix #1652 2021-11-16 12:29:11 +08:00
Karlatemp
4db04e2a76
Fix group detection; fix #1661 2021-11-12 21:35:41 +08:00
Eritque arcus
12e3c4fa90
check permission before recall (#1662)
* recall check(owner sender)

* recall check

* test

* fix permission check and test

* update test

* add one more test
2021-11-10 14:39:18 +00:00
sandtechnology
57a20ea08c
Handle service unavailable case when sending message, thanks to EDG (#1659)
* Handle server busy case in sending message, thanks to EDG

* Rename to ServiceUnavailable and throw ServiceUnavailableException

* Rename to ServiceUnavailable

* Remove ServiceUnavailableException, replace with IllegalStateException
2021-11-09 22:54:19 +00:00
Him188
cb4fb495a3 Rename ByteArray.encodeToString to .decodeToString 2021-11-09 22:12:11 +00:00
Karlatemp
e1ca6dd6c9
Avoid user injection 2021-11-09 18:20:56 +08:00
Karlatemp
fa364b4b45
Reject sending FileMessage (#1657)
* Reject sending `FileMessage`

* Update docs

* Update mirai-core-api/src/commonMain/kotlin/contact/file/AbsoluteFile.kt

Co-authored-by: Him188 <Him188@mamoe.net>

Co-authored-by: Him188 <Him188@mamoe.net>
2021-11-07 10:55:02 +00:00
Karlatemp
76d23c5b0c
NetReplayHelper 2021-11-07 12:33:02 +08:00
Karlatemp
0403de2b39
Improve error message of downloadLongMessage&ForwardMessage 2021-11-06 23:24:09 +08:00
Karlatemp
69931538f5
Fix QuoteReply without msgHead, fix #1641 2021-11-06 23:20:48 +08:00
Karlatemp
8870558d4c
Fix message logging 2021-11-06 19:15:30 +08:00
Albert
3f51867f52
删除多余登录服务器 (#1634) 2021-10-30 16:06:16 +01:00
Him188
9e151e7026
Redesign group files (#1589)
* Prototype new `RemoteFiles` design

* add `@JavaFriendlyAPI`

* remove `quietly`

* move `moveTo` to `AbsoluteFile`

* Add java friendly apis

* Remove `condoneMissing`

* Change `renameTo`

* Extract interface declarations

* update docs

* Add `AbsoluteFileFolder.exists`

* Add common ProgressionCallback

* Implement `RemoteFiles` and relevant `Absolute*`

* Implement `refresh` and `refreshed`

* Update docs

* Forbid blank paths

* Update docs

* Deprecate `RemoteFile` and implement `FileMessage.toAbsoluteFile`

* Change corresponding properties on operations

* Deprecate more old declarations

* Update docs

* Add check for permission

* Allow relative paths and fix upload

* fix absolutePath

* doc update

* api dump

* `Result<R>.onSuccessCatching`

* return null when file not exists

* Fix file uploading

* Fix folder.absolutePath

* add `resolveFileById`

* Implement toString

* Add `nameWithoutExtension` and `extension`

* Add `deep` to resolveFileById

* Implement permission check

* Remove notes

* Fix `resolveFileById`

* Fix `extension`

* add docs

* Improve docs

Co-authored-by: Karlatemp <karlatemp@vip.qq.com>
2021-10-30 16:05:57 +01:00
Him188
767475f9ab Deprecate IMirai.calculateGroupUinByGroupCode, and migrate usages to getUin. Close #1479 2021-10-30 13:44:49 +01:00
Albert
790f37ce05
修复群联系人保存 (#1633) 2021-10-30 13:38:35 +01:00
Karlatemp
217907c58a
Support sending MusicShare to friends. (#1615)
* Support sending `MusicShare` to friends.

- Also fix a potential data out-of-bounds issues

* `TypeSafeMap.get` with default values

* Fix tests
2021-10-28 13:44:18 +01:00
Karlatemp
e61fbbcc70
Fix getRawGroupHonorListData, getRawGroupActiveData (#1616) 2021-10-28 13:44:00 +01:00
Karlatemp
527fe08446
Redesign MessageChain.cleanupRubbishMessageElements() (#1607)
* Redesign `MessageChain.cleanupRubbishMessageElements()`

* Fix logic

* `CleanupRubbishMessageElementsTest`

* Fix testing unit

* more testing
2021-10-28 13:43:41 +01:00
sandtechnology
3d502a496e
Handle other cases in jpeg header (#1611)
* Handle other cases in jpeg header

Co-authored-by: sandtechnology <a1294790523@hotmail.com>

* Add unit tests

Co-authored-by: Karlatemp <karlatemp@vip.qq.com>
2021-10-28 13:43:31 +01:00
Karlatemp
d0171878ff
Fix GroupAllowConfessTalkEvent; fix #1622 2021-10-26 22:53:51 +08:00
Karlatemp
938e7eae57
Fix ImageDecoder of JPEG format; fix #1610 2021-10-17 17:11:34 +08:00
Karlatemp
ace32caa28
Fix cross images downloading url; fix #1600 2021-10-16 16:54:15 +08:00
Karlatemp
b31f7b1ba7
AudioToSilkService (#1591)
* AudioToSilkService

* Update mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt

Co-authored-by: Eritque arcus <1930893235@qq.com>

* `@since`; `@Experimental`

Co-authored-by: Eritque arcus <1930893235@qq.com>
2021-10-09 09:21:58 +01:00
Karlatemp
b027c6c7b7
Allow load settings from file 2021-10-07 12:04:43 +08:00
Karlatemp
0b2a759028
Image.isEmoji() (#1596)
- Also remove image regex inlining
2021-10-05 22:01:14 +08:00
Karlatemp
3e19e4b22a
Improve error message of ImageDecoder; #1593 2021-10-03 15:11:08 +08:00
Karlatemp
b1ad60fc11
Fix ForwardMessage length check; fix #1590 2021-10-02 19:03:30 +08:00