diff options
| author | Mistivia <i@mistivia.com> | 2025-11-05 15:34:49 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-11-05 15:34:49 +0800 |
| commit | 95caa5bdaff4e5b5a924a9141b51c756a57abc0f (patch) | |
| tree | bb0ff8eddfe8a06558317464cea14405e76b7ebc /deprecated-webircgateway/pkg/webircgateway/hooks.go | |
| parent | 8532af453ccc9071ddc919b063788d6b496af991 (diff) | |
remove deprecated
Diffstat (limited to 'deprecated-webircgateway/pkg/webircgateway/hooks.go')
| -rw-r--r-- | deprecated-webircgateway/pkg/webircgateway/hooks.go | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/deprecated-webircgateway/pkg/webircgateway/hooks.go b/deprecated-webircgateway/pkg/webircgateway/hooks.go deleted file mode 100644 index 1bfd564..0000000 --- a/deprecated-webircgateway/pkg/webircgateway/hooks.go +++ /dev/null @@ -1,152 +0,0 @@ -package webircgateway - -import "github.com/kiwiirc/webircgateway/pkg/irc" - -var hooksRegistered map[string][]interface{} - -func init() { - hooksRegistered = make(map[string][]interface{}) -} - -func HookRegister(hookName string, p interface{}) { - _, exists := hooksRegistered[hookName] - if !exists { - hooksRegistered[hookName] = make([]interface{}, 0) - } - - hooksRegistered[hookName] = append(hooksRegistered[hookName], p) -} - -type Hook struct { - ID string - Halt bool -} - -func (h *Hook) getCallbacks(eventType string) []interface{} { - var f []interface{} - f = make([]interface{}, 0) - - callbacks, exists := hooksRegistered[eventType] - if exists { - f = callbacks - } - - return f -} - -/** - * HookIrcConnectionPre - * Dispatched just before an IRC connection is attempted - * Types: irc.connection.pre - */ -type HookIrcConnectionPre struct { - Hook - Client *Client - UpstreamConfig *ConfigUpstream -} - -func (h *HookIrcConnectionPre) Dispatch(eventType string) { - for _, p := range h.getCallbacks(eventType) { - if f, ok := p.(func(*HookIrcConnectionPre)); ok { - f(h) - } - } -} - -/** - * HookIrcLine - * Dispatched when either: - * * A line arrives from the IRCd, before sending to the client - * * A line arrives from the client, before sending to the IRCd - * Types: irc.line - */ -type HookIrcLine struct { - Hook - Client *Client - UpstreamConfig *ConfigUpstream - Line string - Message *irc.Message - ToServer bool -} - -func (h *HookIrcLine) Dispatch(eventType string) { - for _, p := range h.getCallbacks(eventType) { - if f, ok := p.(func(*HookIrcLine)); ok { - f(h) - } - } -} - -/** - * HookClientState - * Dispatched after a client connects or disconnects - * Types: client.state - */ -type HookClientState struct { - Hook - Client *Client - Connected bool -} - -func (h *HookClientState) Dispatch(eventType string) { - for _, p := range h.getCallbacks(eventType) { - if f, ok := p.(func(*HookClientState)); ok { - f(h) - } - } -} - -/** - * HookClientInit - * Dispatched directly after a new Client instance has been created - * Types: client.init - */ -type HookClientInit struct { - Hook - Client *Client - Connected bool -} - -func (h *HookClientInit) Dispatch(eventType string) { - for _, p := range h.getCallbacks(eventType) { - if f, ok := p.(func(*HookClientInit)); ok { - f(h) - } - } -} - -/** - * HookStatus - * Dispatched for each line output of the _status HTTP request - * Types: status.client - */ -type HookStatus struct { - Hook - Client *Client - Line string -} - -func (h *HookStatus) Dispatch(eventType string) { - for _, p := range h.getCallbacks(eventType) { - if f, ok := p.(func(*HookStatus)); ok { - f(h) - } - } -} - -/** - * HookGatewayClosing - * Dispatched when the gateway has been told to shutdown - * Types: gateway.closing - */ -type HookGatewayClosing struct { - Hook -} - -func (h *HookGatewayClosing) Dispatch(eventType string) { - for _, p := range h.getCallbacks(eventType) { - if f, ok := p.(func(*HookGatewayClosing)); ok { - f(h) - } - } -} |
