44TODO: Support group messaging
55"""
66
7+ from http import HTTPStatus
78from typing import ClassVar
89
910from pythonxbox .api .provider .baseprovider import BaseProvider
1314 SendMessageResponse ,
1415)
1516
17+ MESSAGE_MAX_LEN = 256
18+
1619
1720class MessageProvider (BaseProvider ):
1821 MSG_URL = "https://xblmessaging.xboxlive.com"
@@ -82,7 +85,7 @@ async def delete_conversation(
8285 resp = await self .client .session .put (
8386 url , json = post_data , headers = self .HEADERS_HORIZON , ** kwargs
8487 )
85- return resp .status_code == 200
88+ return resp .status_code == HTTPStatus . OK
8689
8790 async def delete_message (
8891 self , conversation_id : str , message_id : str , ** kwargs
@@ -102,7 +105,7 @@ async def delete_message(
102105 resp = await self .client .session .delete (
103106 url , headers = self .HEADERS_MESSAGE , ** kwargs
104107 )
105- return resp .status_code == 200
108+ return resp .status_code == HTTPStatus . OK
106109
107110 async def send_message (
108111 self , xuid : str , message_text : str , ** kwargs
@@ -117,8 +120,10 @@ async def send_message(
117120 Returns:
118121 :class:`SendMessageResponse`: Send Message Response
119122 """
120- if len (message_text ) > 256 :
121- raise ValueError ("Message text exceeds max length of 256 chars" )
123+ if len (message_text ) > MESSAGE_MAX_LEN :
124+ raise ValueError (
125+ f"Message text exceeds max length of { MESSAGE_MAX_LEN } chars"
126+ )
122127
123128 url = f"{ self .MSG_URL } /network/Xbox/users/me/conversations/users/xuid({ xuid } )"
124129 post_data = {
0 commit comments