mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Don't allow the sending of messages if bot is not an instance of bot
This commit is contained in:
parent
d03075e539
commit
e1bb5c7365
1 changed files with 4 additions and 1 deletions
|
@ -141,7 +141,7 @@ class Bot:
|
||||||
async with session.request("GET", f"https://api.telegram.org/bot{token}/{endpoint}", params=params) as response:
|
async with session.request("GET", f"https://api.telegram.org/bot{token}/{endpoint}", params=params) as response:
|
||||||
# Check for errors in the request
|
# Check for errors in the request
|
||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
raise TelegramAPIError(f"Request returned {response.status} {response.reason}")
|
raise TelegramAPIError(f"Request returned {response.status} {response.reason}\n{response.text}")
|
||||||
# Parse the json data as soon it's ready
|
# Parse the json data as soon it's ready
|
||||||
data = await response.json()
|
data = await response.json()
|
||||||
# Check for errors in the response
|
# Check for errors in the response
|
||||||
|
@ -226,6 +226,9 @@ class Chat:
|
||||||
|
|
||||||
async def send_message(self, bot, text, **params):
|
async def send_message(self, bot, text, **params):
|
||||||
"""Send a message in the chat through the bot object."""
|
"""Send a message in the chat through the bot object."""
|
||||||
|
# TODO: This could give problems if a class inherits Bot
|
||||||
|
if not isinstance(bot, Bot):
|
||||||
|
raise TypeError("bot is not an instance of Bot.")
|
||||||
await bot.api_request("sendMessage", text=text, chat_id=self.chat_id, **params)
|
await bot.api_request("sendMessage", text=text, chat_id=self.chat_id, **params)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue