Clean chat handlers

This commit is contained in:
Dmitrii Okunev
2024-10-20 23:31:04 +01:00
parent 35a1bec9c3
commit d10087be0d
2 changed files with 8 additions and 2 deletions

View File

@@ -16,6 +16,8 @@ type Client interface {
}
type Kick struct {
CloseCtx context.Context
CloseFn context.CancelFunc
Channel *kickcom.ChannelV1
Client Client
ChatHandler *ChatHandler
@@ -44,7 +46,10 @@ func New(
return nil, fmt.Errorf("unable to obtain channel info: %w", err)
}
ctx, closeFn := context.WithCancel(ctx)
k := &Kick{
CloseCtx: ctx,
CloseFn: closeFn,
Client: client,
Channel: channel,
SaveCfgFn: saveCfgFn,
@@ -60,6 +65,7 @@ func New(
}
func (k *Kick) Close() error {
k.CloseFn()
return nil
}
func (k *Kick) SetTitle(ctx context.Context, title string) error {

View File

@@ -68,9 +68,9 @@ func New(
return nil, fmt.Errorf("the function GetOAuthListenPorts returned zero ports")
}
closeCtx, closeFn := context.WithCancel(ctx)
ctx, closeFn := context.WithCancel(ctx)
t := &Twitch{
closeCtx: closeCtx,
closeCtx: ctx,
closeFn: closeFn,
config: cfg,
saveCfgFn: saveCfgFn,