Commit Graph

556 Commits

Author SHA1 Message Date
Him188
d08c6b81a8 Add simplified one-line API for publishing a single announcement 2021-07-06 19:12:45 +08:00
Him188
b98fcdd2e5 Add default argument to OfflineAnnouncement 2021-07-06 19:12:45 +08:00
Him188
f7e2391d96 Add contracts for eligible Announcement API 2021-07-06 19:12:45 +08:00
Him188
d10cd270e8 Make AnnouncementParameters better for Java 2021-07-06 19:12:45 +08:00
Him188
5c89645056 Add a stable factory-method for AnnouncementImage 2021-07-06 19:12:45 +08:00
Him188
b239c57679 Re-order parameters of AnnouncementImage 2021-07-06 19:12:45 +08:00
Him188
858766d6b5 Make OfflineAnnouncement.create synthetic 2021-07-06 19:12:45 +08:00
Him188
1abc65fb16 Update docs for Announcement API 2021-07-06 19:12:45 +08:00
Him188
47192f3ee3 Make Announcements.asStream not suspend 2021-07-06 19:12:45 +08:00
Him188
9f1343c02e Generate equals, hashCode and toString for AnnouncementParameters abd AnnouncementImage 2021-07-06 19:12:45 +08:00
Him188
d2e35772d0 Add constructor-like functions for Kotlin users 2021-07-06 19:12:45 +08:00
Him188
1abfcf4317 Add OfflineAnnouncement.serializer 2021-07-06 19:12:45 +08:00
Him188
b319e2bc5c Remove parameter title of Announcement 2021-07-06 19:12:45 +08:00
Him188
4a2b510a70 Remove announcements' low-level API and bundle them into AnnouncementProtocol, improve code style and maintainability 2021-07-06 19:12:45 +08:00
Him188
f5ce64ba4f Redesign Announcement API
Co-authored-by: Karlatemp <karlatemp@vip.qq.com>
2021-07-06 19:12:45 +08:00
Him188
194d34d309 Remove meaningless @LazyProperty 2021-07-06 19:12:10 +08:00
Him188
d6c4b5456f Remove inappropriate weak references 2021-07-06 19:12:10 +08:00
Him188
be3c873f4f
Face.toString: use contentToString() for better readability (#1382) 2021-07-06 16:07:41 +08:00
Karlatemp
a4f0bbfe80
Fix document of RandomAccessFile.toExternalResource() 2021-07-05 18:16:53 +08:00
Him188
69f2d24c22 Fix build 2021-07-05 18:02:01 +08:00
Him188
c4fd79ef22 Fix doc on ExternalResource 2021-07-05 18:00:57 +08:00
Him188
8fdce4dc98 Update docs on ExternalResource for auto release, and categorise declarations 2021-07-05 17:20:57 +08:00
Him188
abc2bfcb3e
Add @NotStableForInheritance and apply it to suitable classes (#1385)
* Add `@NotStableForInheritance` and apply it to suitable classes

* apiDump

* Fix import

* fix
2021-07-05 12:50:00 +08:00
Him188
7722a5a0b0 Move KSerializer.map to mirai-core-utils 2021-07-04 17:56:23 +08:00
Karlatemp
4c810ee3ee
ExternalResourceLeakObserver (#1383)
* ExternalResourceLeakObserver

* Avoid exceptions of user-defined run-when-close actions

* Fix build

* Release references

* Move `ExternalResourceLeakObserver` to mirai-core-api

* Make internal

* Make `close()` thread-safely

* typo

* Don't track `ExternalResource` creation stack by default

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

Co-authored-by: Him188 <Him188@mamoe.net>
2021-07-03 22:05:12 +08:00
Him188
ceac90ed19 Minor update for doc of BotJoinGroupEvent.Active 2021-07-02 22:11:38 +08:00
Him188
91a9e63877 Do light refine after constructing MessageReceipt, fix #1371 2021-07-02 21:06:31 +08:00
Karlatemp
a4b62b0909
Voice serialization (#1368)
* Voice serialization

* Implement `hashCode` and `equals` for `Voice`

* Update test

* Update test

* Add note of `PttMessage.pttInternalInstance`

* Fix logic of `Voice.equals`
2021-07-02 12:10:20 +08:00
Him188
adc39a93b5 Update copyright 2021-07-02 00:39:10 +08:00
Him188
b9eb654a51 Reformat and cleanup code 2021-07-02 00:39:10 +08:00
Him188
6eff4bdf40 Add EVENT_LAUNCH_UNDISPATCHED to allow to launch coroutines for event listeners in a UNDISPATCHED start mode 2021-06-29 22:43:02 +08:00
Him188
3d0fba2d8f Fix EventChannel.filter, allow blocking calls correctly 2021-06-29 22:21:58 +08:00
Karlatemp
06c005e068
Update document link of captcha solving 2021-06-26 19:31:30 +08:00
Karlatemp
a20833bb2a
Enable slider captcha for built-in login solvers 2021-06-26 19:31:28 +08:00
Karlatemp
eb5c7414d7
Add hashCode and equals for Image, close #1302 2021-06-26 16:29:40 +08:00
Karlatemp
ae54a5fb41
Private voice support (#1310)
* Support voice for private messaging

* typo

* Add extension functions for `uploadAsVoice`; Update KDocs

* Update KDoc

* Update error message

* Fix `C2CPttStoreBDH` error

* Deprecated `ExternalResource.uploadAsVoice(Contact): Voice`

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

* apiDump

Co-authored-by: Him188 <Him188@mamoe.net>
2021-06-26 10:02:23 +08:00
Him188
baf1ca618e Improve performance of MessageChain.get, MessageChain.contains. Add relevant tests. 2021-06-25 07:57:52 +08:00
Noire
b8de3f77ff
GroupAnnoucement (#1141)
* Add more comment about GroupAnnouncement.kt

* Edit comment about GroupAnnouncement.kt
Provide experimental api

* Api Dump

* After review

* Change to interface and API dump

* More change

* More change

* More more change

* Some change

* api dump

* Fix name

* Redesign Announcement public api

* Edit comment about GroupAnnouncement.kt
Provide experimental api

* After review

* Change to interface and API dump

* More change

* Modify to extension fun

* Fix sendAnnouncement and change place

* Change Group.deleteAnnouncement to group companion

* fix publish

* Api dump

* Reformat code

* Add `@since 2.7`

* Fix build

Co-authored-by: Him188 <Him188@mamoe.net>
2021-06-24 00:59:53 +08:00
sandtechnology
76e57d4aae
Update system face (#1260)
* Update system face

* Update api dump

* Update api dump for android

* Update system face which updated today

* Update api dump

* Add new system face

* Update apidump
2021-06-23 15:00:06 +08:00
zhou2008
7ed9f280d7
Update ForwardMessage.kt (#1275) 2021-06-23 14:57:48 +08:00
Him188
415f133cbc Fix Flow<Message>.toMessageChain 2021-06-20 01:36:32 +08:00
Him188
8840ba9e6f Remove contract in MiraiLogger 2021-06-20 00:21:49 +08:00
Him188
c37457cafb Cleanup and move local serializable classes to top-level 2021-06-19 18:28:21 +08:00
Him188
a38f24cbe5 Redesign connection maintenance mechanism:
Reconnection is directed by `BotOfflineEvent`.

### Event Broadcasting

- PacketFactory `MessageSvcPushForceOffline` closes network with `ForceOfflineException`.
 - `network.close(cause)` pass the cause to state observer from `QQAndroidBot.stateObserverChain`, the observer broadcasts as follows:
   - Nothing if `cause` is `ForceOfflineException` or `BotClosedByEvent`(which is broadcast by user)
   - `BotOfflineEvent.Dropped` if cause is NetworkException and is recoverable(which is from Netty handlers)
   - `BotOfflineEvent.Force` if cause is `ForceOfflineException` is from the factory mentioned above.
   - `BotOfflineEvent.Active` otherwise(any other unexpected exceptions considered as an error)

### Deciding whether to reconnect

User can listen and change `BotOfflineEvent.reconnect` to decide. Default values are determined by `BotConfiguration`.

### Event listening

- Component `BotOfflineEventMonitor` listens `BotOfflineEvent`, logs the event for users, and launches a coroutine to do `network.resumeConnection` to notify the selector to renew an instance.
- `BotOnlineWatchdog` in `SelectorNetworkHandler` is removed.
- Selector now handles `maxAttempts` correctly in such a way that `awaitResumeInstance` does not throw exception until maximum attempts reached.
- On every attempt, new exceptions are logged to provide debugging information, and further duplications are ignored.
2021-06-16 16:58:20 +08:00
AdoptOSS
7732014cbd
fix: do trimming properly in startsWith & endsWith, #1282 (#1314)
Co-authored-by: ArcticLampyrid <arcticlampyrid@outlook.com>
2021-06-08 15:42:37 +08:00
Him188
a9489567d0
Clearify docs for ExternalResource and RemoteFile (#1248)
* Update code docs for ExternalResource emphasising its properties

* Update code docs for ExternalResource emphasising its representative file location

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

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

* Clarify docs
2021-06-08 11:23:09 +08:00
Him188
6b442b251f Introduce AbstractEventTest 2021-06-07 18:56:33 +08:00
Him188
fc96ba96dd Add _EventBroadcast to allow tests to overrode implementation of Event.broadcast 2021-06-07 18:29:15 +08:00
Him188
9619338d5b Catch and forward event broadcasting to EventDispatcher 2021-06-07 18:18:07 +08:00
Him188
02681428c9 Review and migrate deprecated calls 2021-06-07 12:57:01 +08:00