1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-09 16:35:12 +00:00
Commit graph

45 commits

Author SHA1 Message Date
diamondburned fd59b91de1
state: Handle Thread events 2022-04-01 04:40:15 -07:00
Juby210 2d3bf2974a
state: Fix decrementing reaction count (#302)
* state: fix updating reaction count in reaction remove event

* move r.Me branch to if
2022-01-17 16:35:49 -08:00
diamondburned 54cadd2f45 gateway: Refactor for a better concurrent API
This commit refactors the whole package gateway as well as utils/ws
(formerly utils/wsutil) and voice/voicegateway. The new refactor
utilizes a design pattern involving a concurrent loop and an arriving
event channel.

An additional change was made to the way gateway events are typed.
Before, pretty much any type will satisfy a gateway event type, since
the actual type was just interface{}. The new refactor defines a
concrete interface that events can implement:

    type Event interface {
        Op() OpCode
        EventType() EventType
    }

Using this interface, the user can easily add custom gateway events
independently of the library without relying on string maps. This adds a
lot of type safety into the library and makes type-switching on Event
types much more reasonable.

Gateway error callbacks are also almost entirely removed in favor of
custom gateway events. A catch-all can easily be added like this:

    s.AddHandler(func(err error) {
        log.Println("gateway error:, err")
    })
2021-12-14 13:49:34 -08:00
diamondburned efde3f4ea6
state, handler: Refactor state storage and sync handlers
This commit refactors a lot of packages.

It refactors the handler package, removing the Synchronous field and
replacing it the AddSyncHandler API, which allows each handler to
control whether or not it should be ran synchronously independent of
other handlers. This is useful for libraries that need to guarantee the
incoming order of events.

It also refactors the store interfaces to accept more interfaces. This
is to make the API more consistent as well as reducing potential useless
copies. The public-facing state API should still be the same, so this
change will mostly concern users with their own store implementations.

Several miscellaneous functions (such as a few in package gateway) were
modified to be more suitable to other packages, but those functions
should rarely ever be used, anyway.

Several tests are also fixed within this commit, namely fixing state's
intents bug.
2021-11-03 15:16:02 -07:00
diamondburned 64bd519156 state: Store Threads as channels 2021-08-19 20:58:38 -07:00
diamondburned 5b328bdab0 shard: Remake shard manager (#226) 2021-06-14 15:22:55 -07:00
diamondburned ba49bff80a state: Fix voice state removal condition
This commit addresses issue #220.
2021-06-10 16:52:31 -07:00
Maximilian von Lindern a808b52f00
state: Add paginating State.Messages (#213)
* Store,State: Add update param to all store.XXXStore.XXXSet methods

* State: add paginating Messages

* Store: Fix test error

* store: merge shouldPrependMessage and shouldAppendMessage into single messageInsertPosition
2021-06-03 21:39:49 +02:00
Samuel Hernandez 40e1a3757d *: Migrated Go Modules to v3 2021-06-01 19:59:01 -07:00
diamondburned 4e62f120a2 Gateway: Readd Presences into Ready 2020-12-19 18:46:21 -08:00
diamondburned f11edb7260 State: Add Ready Supplement handlers 2020-12-18 22:51:26 -08:00
diamondburned c6679dc52c State: Separate Store into smaller interfaces, Cabinet API
This commit refactors the Store interface in State into smaller
interfaces in package store. These interfaces are combined into one
structure called a "Cabinet". The default implementation of those
interfaces have been rewritten in package defaultstore, while the old
no-op implementation stays with the store package.

This commit also omitted several state handlers for user events, as it
is unclear what they are actually structured like.
2020-11-29 16:57:58 -08:00
Maximilian von Lindern 3230916c45
State: don't check store if resource is not tracked through intents (#163)
Partially reviewed; good for the most part.
2020-11-19 10:43:31 -08:00
diamondburned 6cbe95d2b3 State: Fixed erroneous context setting and races in Ready 2020-11-14 15:30:18 -08:00
diamondburned 615b52de57 Gateway: Added missing GuildCreateEvent handler 2020-11-01 18:58:03 -08:00
diamondburned b7b8118d0b State: Fixed breaking change from previous Gateway change 2020-10-28 19:47:22 -07:00
diamondburned 75df94d9f4 *: Migrated Go Modules to v2 2020-10-28 15:39:59 -07:00
diamondburned f0c73f4c99 State: Ready events now automatically reset the state 2020-08-18 10:20:48 -07:00
Maximilian von Lindern 1585797b52 *: Linting and typo fixes (#134)
* Linting and typo fixes

* Linting and typo fixes

* revert comma fix
2020-07-29 16:58:33 -07:00
diamondburned e79132f2c5 State: Breaking API to fix race conditions in store 2020-07-29 16:58:33 -07:00
Tadeo Kondrak d290b0d01c *: Add typed Snowflake IDs (#122)
This PR closes #120.
2020-07-29 16:58:33 -07:00
diamondburned 9d7f5cb953 Gateway: Deprecated useless type definitions for embedded structs 2020-07-14 21:38:31 -07:00
diamondburned (Forefront) 01021f0902 Fixed a compile bug 2020-06-19 00:59:44 -07:00
diamondburned (Forefront) 88dd0f8995 State now handles MsgCreate's missing Member.User field, some bug fixes
This addresses discord/discord-api-docs#1440.

State documentation has been added, which documents the store and
handlers as well.

Bug fixes include:

- PreHandler being called after the state handler; it is now called
before as documented.
- Minor behavior changes regarding Guild Create events. Refer to State's
documentation.
2020-06-19 00:33:22 -07:00
Maximilian von Lindern de3d0e2160
Gateway: Split GuildCreateEvent (#116)
* Session: fix event handler loop not getting properly closed

* Implement #113

* Session: move guild events to state

* Session: close hStop
2020-06-06 13:47:15 -07:00
diamondburned (Forefront) 53c1ea0f0d State: Fixed Discord not setting GuildID for Ready.Guild.Channels 2020-05-17 23:11:14 -07:00
mavolin 41ce1f389e
make all error messages lowercase 2020-05-16 23:14:49 +02:00
mavolin 40a61dab98
State: resolve errors 2020-05-12 05:06:28 +02:00
diamondburned (Forefront) d82aa60fdc Utils: Added extra wsutil logging 2020-05-11 16:57:40 -07:00
Matthew Penner 5845348e47 Make only get voice state return ErrNotImplemented 2020-04-18 20:58:32 -06:00
Matthew Penner b6c167970a Add VoiceStates returned on GuildCreate and Ready to the state cache 2020-04-18 20:34:25 -06:00
Matthew Penner 9686a41539 Add voice state caching 2020-04-18 20:22:49 -06:00
diamondburned (Forefront) e95227d3f5 State: Fixed reaction adds not being updated 2020-04-12 21:25:22 -07:00
diamondburned (Forefront) 9873d475aa State: Added Reaction state handlers 2020-04-12 16:14:27 -07:00
diamondburned (Forefront) 58f0feb143 State: Unavailable guilds are no longer added into the state 2020-04-06 13:27:33 -07:00
diamondburned (Forefront) 1b785b1c38 State: Added guild emoji handlers 2020-03-11 19:41:14 -07:00
diamondburned (Forefront) f0102d765f Gateway: Added a retry limit
State: Event handlers now handle all of Ready's Guilds field
Session: Added Wait, which blocks until SIGINT or Gateway error
2020-02-29 18:13:58 -08:00
diamondburned (Forefront) 79c4c1caca Gateway/State: Added message acking and more user update events for State 2020-02-24 21:50:13 -08:00
diamondburned (Forefront) 688248346b State: Added handlers for PresencesReplaceEvent 2020-02-23 20:11:33 -08:00
diamondburned (Forefront) 4e9bd53b0f Gateway: Added extra events 2020-02-15 21:29:25 -08:00
diamondburned (Forefront) 165ef71cb5 State: Changed Self to Me for consistency 2020-02-08 11:51:00 -08:00
diamondburned (Forefront) 91e213135c State: Changed Self to Me for consistency 2020-02-08 11:48:45 -08:00
diamondburned (Forefront) 5acf01d984 State: Fixed bug where range values are dereferenced incorrectly
https://github.com/golang/go/wiki/CommonMistakes#using-reference-to-loop-iterator-variable
2020-02-07 00:22:41 -08:00
diamondburned (Forefront) 1746065f70 Separated state errors into a separate no-op logger 2020-01-20 01:06:47 -08:00
diamondburned (Forefront) b11b3e1a42 Added state handlers 2020-01-18 13:04:12 -08:00