mirror of
https://github.com/diamondburned/cchat-mock.git
synced 2024-12-28 06:06:45 +00:00
28 lines
603 B
Go
28 lines
603 B
Go
package shared
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/diamondburned/cchat"
|
|
"github.com/diamondburned/cchat-mock/internal/internet"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// StaticIcon is a struct that implements cchat.Iconer. It never updates.
|
|
type StaticIcon struct {
|
|
URL string
|
|
}
|
|
|
|
func NewStaticIcon(url string) StaticIcon {
|
|
return StaticIcon{url}
|
|
}
|
|
|
|
func (icn StaticIcon) Icon(ctx context.Context, iconer cchat.IconContainer) (func(), error) {
|
|
if err := internet.SimulateAustralian(); err != nil {
|
|
return nil, errors.Wrap(err, "failed to query for icon")
|
|
}
|
|
|
|
iconer.SetIcon(icn.URL)
|
|
return func() {}, nil
|
|
}
|