Browse Source

Include network type analytics on message send

pull/10109/head
dolfies 1 year ago
parent
commit
bb15f1c6c3
  1. 3
      discord/abc.py
  2. 28
      discord/enums.py
  3. 6
      discord/http.py

3
discord/abc.py

@ -48,7 +48,7 @@ from typing import (
from .object import OLDEST_OBJECT, Object from .object import OLDEST_OBJECT, Object
from .context_managers import Typing from .context_managers import Typing
from .enums import ApplicationCommandType, ChannelType, InviteTarget from .enums import ApplicationCommandType, ChannelType, InviteTarget, NetworkConnectionType
from .errors import ClientException from .errors import ClientException
from .mentions import AllowedMentions from .mentions import AllowedMentions
from .permissions import PermissionOverwrite, Permissions from .permissions import PermissionOverwrite, Permissions
@ -1869,6 +1869,7 @@ class Messageable:
mention_author=mention_author, mention_author=mention_author,
stickers=sticker_ids, stickers=sticker_ids,
flags=flags, flags=flags,
network_type=NetworkConnectionType.unknown,
) as params: ) as params:
data = await state.http.send_message(channel.id, params=params) data = await state.http.send_message(channel.id, params=params)

28
discord/enums.py

@ -122,6 +122,8 @@ __all__ = (
'DirectoryEntryType', 'DirectoryEntryType',
'DirectoryCategory', 'DirectoryCategory',
'HubType', 'HubType',
'NetworkConnectionType',
'NetworkConnectionSpeed',
) )
if TYPE_CHECKING: if TYPE_CHECKING:
@ -1599,6 +1601,32 @@ class HubType(Enum):
university = 2 university = 2
class NetworkConnectionType(Enum):
bluetooth = 'bluetooth'
cellular = 'cellular'
ethernet = 'ethernet'
none = 'none'
other = 'other'
unknown = 'unknown'
wifi = 'wifi'
wimax = 'wimax'
def __str__(self) -> str:
return self.value
class NetworkConnectionSpeed(Enum):
five_g = '5g'
four_g = '4g'
three_g = '3g'
two_g = '2g'
slow_two_g = 'slow-2g'
unknown = 'unknown'
def __str__(self) -> str:
return self.value
def create_unknown_value(cls: Type[E], val: Any) -> E: def create_unknown_value(cls: Type[E], val: Any) -> E:
value_cls = cls._enum_value_cls_ # type: ignore # This is narrowed below value_cls = cls._enum_value_cls_ # type: ignore # This is narrowed below
name = f'unknown_{val}' name = f'unknown_{val}'

6
discord/http.py

@ -54,7 +54,7 @@ import datetime
import aiohttp import aiohttp
from .enums import RelationshipAction, InviteType from .enums import NetworkConnectionType, RelationshipAction, InviteType
from .errors import ( from .errors import (
HTTPException, HTTPException,
RateLimited, RateLimited,
@ -239,6 +239,7 @@ def handle_message_parameters(
previous_allowed_mentions: Optional[AllowedMentions] = None, previous_allowed_mentions: Optional[AllowedMentions] = None,
mention_author: Optional[bool] = None, mention_author: Optional[bool] = None,
thread_name: str = MISSING, thread_name: str = MISSING,
network_type: NetworkConnectionType = MISSING,
channel_payload: Dict[str, Any] = MISSING, channel_payload: Dict[str, Any] = MISSING,
) -> MultipartParameters: ) -> MultipartParameters:
if files is not MISSING and file is not MISSING: if files is not MISSING and file is not MISSING:
@ -295,6 +296,9 @@ def handle_message_parameters(
if thread_name is not MISSING: if thread_name is not MISSING:
payload['thread_name'] = thread_name payload['thread_name'] = thread_name
if network_type is not MISSING:
payload['mobile_network_type'] = str(network_type)
if allowed_mentions: if allowed_mentions:
if previous_allowed_mentions is not None: if previous_allowed_mentions is not None:
payload['allowed_mentions'] = previous_allowed_mentions.merge(allowed_mentions).to_dict() payload['allowed_mentions'] = previous_allowed_mentions.merge(allowed_mentions).to_dict()

Loading…
Cancel
Save