[V3 Mod] Support global users with userinfo #2282

Closed
laggron42 wants to merge 8 commits from patch-26 into V3/develop
laggron42 commented 2018-11-01 00:28:46 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

The [p]userinfo command can now fetch informations about any Discord user, even if he doesn't share a server with the bot, using the bot.get_user_info(ID) endpoint.

Example

image

### Type - [ ] Bugfix - [ ] Enhancement - [x] New feature ### Description of the changes The `[p]userinfo` command can now fetch informations about any Discord user, even if he doesn't share a server with the bot, using the `bot.get_user_info(ID)` endpoint. ### Example ![image](https://user-images.githubusercontent.com/23153234/47824422-0cc1c780-dd6d-11e8-8c9d-145ea1602d05.png)
palmtree5 (Migrated from github.com) reviewed 2018-11-01 00:28:46 +01:00
Zephyrkul (Migrated from github.com) reviewed 2018-11-01 00:37:38 +01:00
Zephyrkul (Migrated from github.com) commented 2018-11-01 00:37:38 +01:00

get_user_info isn't like get_member and the like - if the user ID is not found, it raises a 404 Not Found error (specifically discord.NotFound) instead of returning None.

It's also worth noting that there's a get_user method of bot, which will fetch the user from the bot's global cache of connected users. It may be worth checking that before using get_user_info.

`get_user_info` isn't like `get_member` and the like - if the user ID is not found, it raises a 404 Not Found error (specifically `discord.NotFound`) instead of returning `None`. It's also worth noting that there's a `get_user` method of `bot`, which will fetch the user from the bot's global cache of connected users. It may be worth checking that before using `get_user_info`.
Zephyrkul (Migrated from github.com) reviewed 2018-11-01 22:15:50 +01:00
Zephyrkul (Migrated from github.com) commented 2018-11-01 22:15:49 +01:00

Forbidden is a 403 error. You want to catch NotFound, a 404 error, as per my last comment.

`Forbidden` is a 403 error. You want to catch `NotFound`, a 404 error, as per my last comment.
mikeshardmind commented 2018-11-23 23:29:06 +01:00 (Migrated from github.com)

Considering the ratelimits that endpoint is subject to, I think this belongs in a separate command which isn't available to all users.

Considering the ratelimits that endpoint is subject to, I think this belongs in a separate command which isn't available to all users.
Zephyrkul commented 2018-11-25 02:24:27 +01:00 (Migrated from github.com)

How about allowing cache access (get_user) for anyone but only allowing get_user_info if it's the bot owner?

How about allowing cache access (`get_user`) for anyone but only allowing `get_user_info` if it's the bot owner?
Kowlin commented 2018-11-28 20:36:49 +01:00 (Migrated from github.com)

I'd feel more comfortable with only allowing to look up the member from the cache if the the person the author is looking up has a mutual server with him. This avoids the issue of trying to brute force information on public Red bots if we ever decide to add more information to userinfo

I'd feel more comfortable with only allowing to look up the member from the cache if the the person the author is looking up has a mutual server with him. This avoids the issue of trying to brute force information on public Red bots if we ever decide to add more information to userinfo
mikeshardmind commented 2018-11-28 21:23:48 +01:00 (Migrated from github.com)

I've given this a little more thought as well. Rather than expand userinfo in this manner, I think it is appropriate to add a finduser command.

The following internal filtering would need to occur in such a command:

  1. If the user is in bot.users:
    If any of the guilds are mutually shared between the bot, queried user, and author, allow the info.
    If the author is the bot owner, allow the info
    Otherwise, don't share the info

  2. If the user is not in bot.users
    Allow only to the owner.

Additionally, this lookup should use redbot.core.utils.antispam (Not a straight cooldown) to limit this commands repeated usability to non-bot owners.

I've given this a little more thought as well. Rather than expand `userinfo` in this manner, I think it is appropriate to add a `finduser` command. The following internal filtering would need to occur in such a command: 1. If the user is in bot.users: If any of the guilds are mutually shared between the bot, queried user, and author, allow the info. If the author is the bot owner, allow the info Otherwise, don't share the info 2. If the user is not in bot.users Allow only to the owner. Additionally, this lookup should use `redbot.core.utils.antispam` (Not a straight cooldown) to limit this commands repeated usability to non-bot owners.
laggron42 commented 2018-12-01 12:51:47 +01:00 (Migrated from github.com)

@mikeshardmind good idea, but should this stay inside the mod cog?

@mikeshardmind good idea, but should this stay inside the mod cog?
mikeshardmind commented 2018-12-02 23:02:46 +01:00 (Migrated from github.com)

@retke I think so, this has very little practical purpose outside of moderation. I'm open to the new command being placed elsewhere with a logical reason for doing so though.

@retke I think so, this has very little practical purpose outside of moderation. I'm open to the new command being placed elsewhere with a logical reason for doing so though.
mikeshardmind commented 2018-12-03 05:39:36 +01:00 (Migrated from github.com)

I've pushed a sample implementation of this command into a staging cog on my cog repo.
I'll PR this to exist within core mod if the implementation here looks reasonable enough for general use.

Source

I've pushed a sample implementation of this command into a `staging` cog on my cog repo. I'll PR this to exist within core mod if the implementation here looks reasonable enough for general use. [Source](https://github.com/mikeshardmind/SinbadCogs/blob/v3/staging/staging.py)
laggron42 commented 2019-07-09 13:53:06 +02:00 (Migrated from github.com)

Will be rewritten into a new command.

Will be rewritten into a new command.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!2282
No description provided.