add player package with key client-side player functionality, update protocol codecs, and refactor metadata definitions and slot usage

This commit is contained in:
2025-08-23 16:19:45 +08:00
parent cff9d4a809
commit 4528bdc86a
32 changed files with 2613 additions and 468 deletions

20
pkg/bot/event.go Normal file
View File

@ -0,0 +1,20 @@
package bot
type EventHandler interface {
PublishEvent(event string, data any) error
SubscribeEvent(event string, handler func(data any) error)
}
type Event interface {
EventID() string
}
func PublishEvent(client Client, event Event) error {
return client.EventHandler().PublishEvent(event.EventID(), event)
}
func SubscribeEvent(client Client, event string, handler func(event Event) error) {
client.EventHandler().SubscribeEvent(event, func(data any) error {
return handler(data.(Event))
})
}