diff --git a/go.mod b/go.mod index 3801818..c1937e0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.14 require ( github.com/Pallinder/go-randomdata v1.2.0 github.com/diamondburned/aqs v0.0.0-20200704043812-99b676ee44eb - github.com/diamondburned/cchat v0.3.8 + github.com/diamondburned/cchat v0.3.11 github.com/lucasb-eyer/go-colorful v1.0.3 github.com/pkg/errors v0.9.1 golang.org/x/text v0.3.3 // indirect diff --git a/go.sum b/go.sum index 8a52531..feee3d6 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,10 @@ github.com/diamondburned/cchat v0.3.6 h1:at9bnxlABa3TGscra/cRq/ASsmJh6GCdQ0vnCD9 github.com/diamondburned/cchat v0.3.6/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= github.com/diamondburned/cchat v0.3.8 h1:vgFe8giVfwsAO+WpTYsTDIXvRUN48osVPNu0pZNvPEk= github.com/diamondburned/cchat v0.3.8/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= +github.com/diamondburned/cchat v0.3.9 h1:qsYUz68aBApoMz7zo1snrIz3U/ljPJ+YyRhZcpQvzbw= +github.com/diamondburned/cchat v0.3.9/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= +github.com/diamondburned/cchat v0.3.11 h1:C1f9Tp7Kz3t+T1SlepL1RS7b/kACAKWAIZXAgJEpCHg= +github.com/diamondburned/cchat v0.3.11/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= diff --git a/internal/service/authenticator.go b/internal/service/authenticator.go index 3f2d1ac..3befed4 100644 --- a/internal/service/authenticator.go +++ b/internal/service/authenticator.go @@ -4,6 +4,7 @@ import ( "github.com/diamondburned/cchat" "github.com/diamondburned/cchat-mock/internal/internet" "github.com/diamondburned/cchat-mock/internal/session" + "github.com/diamondburned/cchat/text" "github.com/pkg/errors" ) @@ -11,6 +12,14 @@ type Authenticator struct{} var _ cchat.Authenticator = (*Authenticator)(nil) +func (Authenticator) Name() text.Rich { + return text.Plain("Slow Authentication") +} + +func (Authenticator) Description() text.Rich { + return text.Plain("") +} + func (Authenticator) AuthenticateForm() []cchat.AuthenticateEntry { return []cchat.AuthenticateEntry{ { @@ -27,19 +36,28 @@ func (Authenticator) AuthenticateForm() []cchat.AuthenticateEntry { } } -func (Authenticator) Authenticate(form []string) (cchat.Session, error) { +func (Authenticator) Authenticate(form []string) (cchat.Session, cchat.AuthenticateError) { // SLOW IO TIME. - if err := internet.SimulateAustralian(); err != nil { - return nil, errors.Wrap(err, "Authentication failed") + err := internet.SimulateAustralian() + if err == nil { + return session.New(form[0], ""), nil } - return session.New(form[0], ""), nil + return nil, cchat.WrapAuthenticateError(errors.Wrap(err, "Authentication failed")) } type FastAuthenticator struct{} var _ cchat.Authenticator = (*FastAuthenticator)(nil) +func (FastAuthenticator) Name() text.Rich { + return text.Plain("Fast Authenticator") +} + +func (FastAuthenticator) Description() text.Rich { + return text.Plain("Internet fails and slow-downs disabled.") +} + func (FastAuthenticator) AuthenticateForm() []cchat.AuthenticateEntry { return []cchat.AuthenticateEntry{ { @@ -48,6 +66,6 @@ func (FastAuthenticator) AuthenticateForm() []cchat.AuthenticateEntry { } } -func (FastAuthenticator) Authenticate(form []string) (cchat.Session, error) { +func (FastAuthenticator) Authenticate(form []string) (cchat.Session, cchat.AuthenticateError) { return session.New(form[0], ""), nil }