mirror of
https://github.com/fromchat-messenger/app.git
synced 2026-09-22 19:15:05 +03:00
Redesign plugins UI and demo raw + high-level hooks
- Match exteraGram-style card layout with master toggle and plugin actions - Add usage manifest field, pin/delete/removePlugin engine APIs - Hello World plugin hooks Logger.d (raw) and send pipeline (high-level) - Bundle updated hello_world.fcplugin; stop debug auto-enable Co-authored-by: denis0001-dev <denis0001.dev@ya.ru>
This commit is contained in:
@@ -35,9 +35,10 @@ tasks.register("packageFcPlugin") {
|
||||
{
|
||||
"id": "hello_world",
|
||||
"name": "Hello World",
|
||||
"description": "Rewrites .hello commands into a friendly greeting",
|
||||
"description": "Demonstrates high-level send hooks and raw Logger.d hooks.",
|
||||
"author": "FromChat",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"usage": "Send .hello Name in any chat to rewrite the message. Raw hook shows a bulletin when a message is queued for sending.",
|
||||
"app_version": ">=1.0.0",
|
||||
"sdk_version": ">=1.0.0",
|
||||
"entry_class": "ru.fromchat.plugins.sample.hello.HelloWorldPlugin",
|
||||
|
||||
+12
@@ -13,6 +13,17 @@ class HelloWorldPlugin : BasePlugin() {
|
||||
addOnSendMessageHook { context ->
|
||||
onSendMessage(context)
|
||||
}
|
||||
hookShared(
|
||||
hookId = "logger.debug",
|
||||
after = { args, _ ->
|
||||
val tag = args.getOrNull(0) as? String ?: return@hookShared HookResult()
|
||||
val message = args.getOrNull(1) as? String ?: return@hookShared HookResult()
|
||||
if (tag == "OutgoingMessageCoordinator" && message.contains("enqueue")) {
|
||||
showBulletin("Raw hook: intercepted outgoing message pipeline")
|
||||
}
|
||||
HookResult()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
override fun createSettings(): List<PluginSetting> = listOf(
|
||||
@@ -36,6 +47,7 @@ class HelloWorldPlugin : BasePlugin() {
|
||||
val name = parts.getOrNull(1)?.trim().orEmpty().ifEmpty { "World" }
|
||||
val template = getSettingString("template", "Hello, {name}!")
|
||||
context.text = template.replace("{name}", name)
|
||||
showBulletin("High-level hook: rewrote .hello command")
|
||||
return HookResult(strategy = HookStrategy.MODIFY, value = context)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user