Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

feat: Cache user status and activity #448

Merged
merged 1 commit into from
Apr 18, 2022
Merged

feat: Cache user status and activity #448

merged 1 commit into from
Apr 18, 2022

Conversation

LordOfPolls
Copy link
Member

What type of pull request is this?

  • Non-breaking code change
  • Breaking code change
  • Documentation change/addition
  • Tests change

Description

Resolves #436
Snek now caches user status/ activity updates in user objects.

Changes

  • Add Status and activities attributes to user object
  • Combine guild-chunk presence and status payload with members payload
  • presence-update events update user objects

Checklist

  • I've formatted my code with Black
  • I've ensured my code works on Python 3.10.x
  • I've tested my code

@LordOfPolls LordOfPolls linked an issue Apr 17, 2022 that may be closed by this pull request
Copy link
Contributor

@zevaryx zevaryx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@LordOfPolls LordOfPolls merged commit d0a6870 into dev Apr 18, 2022
@LordOfPolls LordOfPolls deleted the presence-caching branch April 18, 2022 17:31
AstreaTSS added a commit to AstreaTSS/NAFF that referenced this pull request May 11, 2022
* feat: Add suppress_embeds kwarg to sends

* feat: add BaseInteraction.expired and expires_at

* feat: use BaseChannel when new channel type detected

* feat: Allow string footers (NAFTeam#431)

* feat: Allow raw strings to be passed to Embed.footer

Closes NAFTeam#428

* fix: fix type hinting shenanigans

* ci: Run tests on each of the possible extras snek can be installed with (NAFTeam#429)

* ci: Add autoflake to pre-commit, make it remove unused imports (NAFTeam#435)

* ci: Add autoflake to pre-commit, make it remove unused imports

* fix: remove unused imports

* [pre-commit.ci] pre-commit autoupdate (NAFTeam#437)

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.1.0 → v4.2.0](pre-commit/pre-commit-hooks@v4.1.0...v4.2.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: Add modal callbacks (NAFTeam#432)

* Docs: Add information on how to use the cookiecuttter template (NAFTeam#433)

* docs: add information on how to use cookiecuttter template I made

* fix: Update docs/src/Guides/01 Getting Started.md

Co-authored-by: LordOfPolls <22540825+LordOfPolls@users.noreply.github.com>

* docs: put installation methods in content tabs

Co-authored-by: LordOfPolls <22540825+LordOfPolls@users.noreply.github.com>

* feat: switch to api V10 (NAFTeam#430)

* refactor: store api version as const value

* feat💥: bump api version to v10

* feat: Send error to channel with default error handlers (NAFTeam#427)

* feat: Send error to channel with default error handlers

* feat: filter bot token

Intentionally mirroring style of debug exec

* fix: prevent overflowing message cap

* feat: Add client kwarg to disable sending tracebacks

* feat: Add specific error embeds

For max concurrency, cooldowns, and checks

* fix: bad auto-resolve of conflicts

* fix: Add missing intents for v10 (NAFTeam#440)

* fix: Add missing intents for v10

* fix: Add new intents to new method

* feat: support multi-scale unloading (NAFTeam#441)

* feat💥: support multiple scales in one extension file

* feat💥: sssss

* fix: update shed_scale

* feat: restore get_scale

* feat: Add mypy plugin.  This adds support for our custom attrs wrapper. (NAFTeam#438)

* build: Add speed up install extra deps (NAFTeam#443)

* build: Add speed up install extra deps

* tests: Add the "speedup" extra to pytest

* feat 💥: Remove ytdl support (NAFTeam#446)

* refactor💥: Re-order client args, and enforce kw_only (NAFTeam#442)

* feat: sync app-cmds on scale (un)loading (NAFTeam#439)

* feat: sync app-cmds on scale (un)loading

* fix: erroneous error raising

* fix: Fully yeet ytdl

* fix: guild.member_count accuracy (NAFTeam#450)

* fix: VoiceChannel.voice_members was not updating correctly (NAFTeam#449)

* feat: message system_content property (NAFTeam#447)

* feat: message system_content property

* feat: support more rare system messages

* feat💥: Localisation support (NAFTeam#445)

* feat: Add attrs_validator

* feat: Add localisation object

* feat: add const.default_locale

* fix: outputting tweaks to LocalisedField

* feat: integrate ugly-ass localisation into app_cmds

Discord i hate how you did localisation - its midnight, im tired, this works, i want to scream. ive had "enaff"

* feat: Add helpers to LocalisedField

* feat: ctx.invoked_name is now localised

* perf: Improve get_locale + comments

* fix: readability improvement

* fix: Fix syncing

* feat: check localisation fields during sync

* feat: localise localizations

* fix: Add localisers to `__all__`

* docs: Add localisation docs

* docs: Add `ctx.locale` reference

* feat: Cache user status and activity (NAFTeam#448)

* fix: Component commands erroneously using localisation

* fix: prevent attempting to sync before event loop has started

* fix: Only attempt to sync scales if bot is ready

* fix: fix subcommand squashing

* fix: Autocomplete assignment

* fix: choices not serializing correctly

* fix: Restore context menu validation

Context menus were erroneously using the slash command validation

* fix: snowflake object comparison when str passed (NAFTeam#452)

* fix: snowflake object comparison when str passed

* refactor: simplify

* feat: Support async entrypoint for scales (NAFTeam#451)

* feat: Support async entrypoint for scales

* fix: Yet another localisation fix to syncing

I really should have tested this more, thank fuck this is the dev branch

* fix: Cleanup after audio stop

* fix: CustomEmoji got multiple values for kwarg `guild_id`

* fix: prevent 🧟 zombie ffmpeg processes

* fix: Fix aspects of threads (NAFTeam#454)

* fix: set default thread_type to public

API V10 requires this to be specified

* fix: Allow message-threads to be created in news channels

* fix: handle discord being inconsistent as always with emoji

* feat: voice text support

* feat🔥: Handle unknown channel types without data-loss (NAFTeam#457)

* feat: GuildVoice in TYPE_MESSAGEABLE_CHANNEL (NAFTeam#456)

* feat: Add auto-mod message type

* fix: various slash command fixes (NAFTeam#460)

* fix: ann > annotation

* fix: make slash anno choices pass correctly if None

* refactor: remove redundant todos

* fix💥: GuildStageVoice no longer inherits from GuildVoice (NAFTeam#461)

GuildVoice supports messages, GuildStageVoice does not

* feat💥: Add support for perms2.0 and retire support for perms1.0 (NAFTeam#458)

* fix: remove no longer existing `Batch Edit Application Command Permissions` endpoint

* !feat: remove `default_permission` and `permissions` in favor of the new `default_member_permissions` and `dm_permission`

* !feat: remove `slash_permission` decorator and `Permission` / `PermissionTypes` classes in favor of the new `slash_default_member_permission` decorator

* fix: no longer try to sync command permissions

* fix: process the permissions dict and sync commands correctly

* docs: add perms docs

* docs: add information about checks

* docs: remove outdated text

* fix: TypeError if subcommand has no permissions set

* fix: Suppress auto defer bad request

https://canary.discord.com/channels/870046872864165888/893158404237979688/970215914228285510

* feat💥: completely remake prefixed commands (NAFTeam#444)

* refactor💥: converters > attr_converters

Just wanted to avoid confusion with molter's converters.

* feat: make pending regex ignore newlines

* feat: add converters and BadArgument

* feat: Allow Converters to be used in Commands

* fix: adjust imports to avoid circular importing

* feat: add T_co constant

* refactor: use consts over redefining TypeVars

* refactor: remove unneeded imports

* refactor: more circular reference resolution(#2)

refactor: more circular reference resolution

* refactor💥: message commands > prefixed commands

Renaming it like this avoids confusion with context menu message commands.
"Prefixed" (or "prefix") is the most commonly used terminology, too.

I might have missed something still. Sorry!

* refactor💥: message_context > prefixed_context

* fix: missed a rename, haha

* refactor💥: commands > prefixed_commands

* feat💥: completely remake prefixed commands

Otherwise known as the molter merge.
These changes are untested as of right now.

* fix: make sure subcommands aren't added to the bot

* feat: added prefixed help command

* fix: clear out old params just in case

* docs: add basic pages to match structure changes

* docs: fix doc building

for future note you can test doc building by running

`mkdocs serve`

* docs: add missing index entries

* fix: properly handle errors for hierarchical_checking

* refactor: ArgsIterator > _PrefixedArgsIterator

* docs: polish docstrings for PrefixedCommand

* docs: add docstrings for PrefixedCommandParameter

* docs: add docstrings for Converter

* feat: make LiteralConverter protected

There's little need for anyone to use this directly.

* refactor: adjust quotes handling

* literally have to merge because of one commit smh

* docs: add and update docstrings for converters

* fix: don't match PartialEmojis by ID

* docs: adjust docstrings for MessageConverter

* docs: start work on prefixed cmd guide

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* docs: header adjustments

* feat: make is_subcomamnd for prefixed cmd a property

This is consistent with application commands.

* fix: app cmds not working for scales

* fix: is_subcomamnd > is_subcommand

* feat: add error handling for 2+ var/kw-only args

* docs: further work on prefixed commands guide

* fix: remove unnecessary annotated check

* refactor: sourcery complained

* docs: more work on documentation

* docs: even more progress

* docs: mostly finish up prefixed commands

* feat: check for more cases for Greedy

* docs: remove unneeded notes

* fix: do union check before valid type check

This allows the inner value to be extracted first.

* fix: don't allow unions in unions

* docs: add note about function arguments

* docs: start converters guide

* feat💥: make CMD_* converters

This also removes define_annotation, as it has been superceded by converters.

* docs: work on converters

* docs: finish up guides

* docs: add and adjust docs for help commands

* docs: adjust note about prefixed command porting

* docs: slight adjustments here and there

* feat: make MessageableChannelConverter more dynamic

* docs: remove unneeded comment

* docs: adjust notes about prefixed command naming

* fix: parse variable arguments correctly

* fix: make parser error out special parameters with greedy

* fix: convert Literal arguments

* docs: adjust and add images for guide

* fix: copying and pasting mistake

* refactor💥: models.utils > model.misc

Naming it "utils" messed with "client.utils" for some reason.

* fix/feat: don't "eat up" args for CMD_*

* feat💥: remove support for 0 argument functions

* fix: missed a place

* refactor: move around and adjust NoArgumentConverter

* refactor: import Converter from protocols

* docs: slight wording changes

Co-authored-by: Katelyn Gigante <clockwork.singularity@gmail.com>
Co-authored-by: LordOfPolls <ddavidallen13@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: Add APPLICATION_COMMAND_PERMISSION_UPDATE audit type

* fix: fix incorrect converters in audit log

* feat: add VoiceChannelConverter (NAFTeam#463)

* perf: Convert all __all__ statements into tuples  (NAFTeam#462)

* perf: dunder all should be tuple

* fix: Black removed the tuples, theyre now back

* feat: Add support for application cmds attrib of audit log (NAFTeam#464)

* refactor: Rename root folder

* refactor: rename Snake -> client

* refactor: rename SnakeBotUser -> NaffUser

* refactor: rename task name for dispatcher

* refactor: Rename SnakeException -> NaffException

* docs: Remove client snake comments

* refactor: rename models/snek -> models/naff

* refactor: Rename Scale -> Cog

* refactor: Remove snek/snake references

* tests: refactor tests

* build: rename library

* docs: update docs for new structure

* feat: ability to move a member to a different vc (NAFTeam#466)

* build: update build information

* perf: Add Brotli speedup extra dep

* perf: use tuples for context menu cache lookup

* perf: import methods directly in player

* perf: use list comprehension for thread parsing

* perf: Use tuple instead of list

* perf: Convert for loops in client into comprehensions where applicable

* perf: Convert const list into tuple

Consts are... constant, use a tuple

* perf: another comprehension conversion

* fix💥: Rename `raw_socket_event` -> `raw_gateway_event`

* refactor: Fix erroneous dis-naff mistake

* tests: Add automated tests bot (NAFTeam#468)

* tests: Merge snek-tests into lib pytests

* test: install voice deps to env

* tests: skip voice on non-voice extra

* fix: Wait for member update event

* tests: Use pyproj for coverage

* tests: Remove now redundant pragmas

* tests: prevent multiple test-bots running concurrently

* fix: Don't crash if someone compares a PartialEmoji against other types (NAFTeam#470)

* fix: Don't crash if someone compares a PartialEmoji and a string.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* tests: update imports to naff

* fix: Fix weird caching behaviour of `get_init_keys`

* fix: semaphore/max-concurrency handling (NAFTeam#471)

* fix: semaphore/max-concurrency handling

semaphores are now only released if one was acquired

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix: New permission overwrites not being applied

* ci: add ok-to-test to test pytest for PRs

* fix: don't test if there's no bot token

Co-authored-by: LordOfPolls <ddavidallen13@gmail.com>
Co-authored-by: LordOfPolls <22540825+LordOfPolls@users.noreply.github.com>
Co-authored-by: Katelyn Gigante <clockwork.singularity@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel J <38250010+Kigstn@users.noreply.github.com>
Co-authored-by: zevaryx <57541873+zevaryx@users.noreply.github.com>
Co-authored-by: Leestarb Original <56854192+leestarb@users.noreply.github.com>
Co-authored-by: Aiden <aiden8green@gmail.com>
Co-authored-by: AlbertUnruh <73029826+AlbertUnruh@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Optional presence/activity cache
2 participants