mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-11-03 10:01:05 +08:00
Clean chat handlers
This commit is contained in:
@@ -16,6 +16,8 @@ type Client interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Kick struct {
|
type Kick struct {
|
||||||
|
CloseCtx context.Context
|
||||||
|
CloseFn context.CancelFunc
|
||||||
Channel *kickcom.ChannelV1
|
Channel *kickcom.ChannelV1
|
||||||
Client Client
|
Client Client
|
||||||
ChatHandler *ChatHandler
|
ChatHandler *ChatHandler
|
||||||
@@ -44,7 +46,10 @@ func New(
|
|||||||
return nil, fmt.Errorf("unable to obtain channel info: %w", err)
|
return nil, fmt.Errorf("unable to obtain channel info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx, closeFn := context.WithCancel(ctx)
|
||||||
k := &Kick{
|
k := &Kick{
|
||||||
|
CloseCtx: ctx,
|
||||||
|
CloseFn: closeFn,
|
||||||
Client: client,
|
Client: client,
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
SaveCfgFn: saveCfgFn,
|
SaveCfgFn: saveCfgFn,
|
||||||
@@ -60,6 +65,7 @@ func New(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k *Kick) Close() error {
|
func (k *Kick) Close() error {
|
||||||
|
k.CloseFn()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (k *Kick) SetTitle(ctx context.Context, title string) error {
|
func (k *Kick) SetTitle(ctx context.Context, title string) error {
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ func New(
|
|||||||
return nil, fmt.Errorf("the function GetOAuthListenPorts returned zero ports")
|
return nil, fmt.Errorf("the function GetOAuthListenPorts returned zero ports")
|
||||||
}
|
}
|
||||||
|
|
||||||
closeCtx, closeFn := context.WithCancel(ctx)
|
ctx, closeFn := context.WithCancel(ctx)
|
||||||
t := &Twitch{
|
t := &Twitch{
|
||||||
closeCtx: closeCtx,
|
closeCtx: ctx,
|
||||||
closeFn: closeFn,
|
closeFn: closeFn,
|
||||||
config: cfg,
|
config: cfg,
|
||||||
saveCfgFn: saveCfgFn,
|
saveCfgFn: saveCfgFn,
|
||||||
|
|||||||
Reference in New Issue
Block a user