Python 电报机器人可以';t向该组发送相同的消息

Python 电报机器人可以';t向该组发送相同的消息,python,telegram,Python,Telegram,我制作了一个脚本,将从NASA API获取的一些信息通过电报发送给一个小组。我制作了一个机器人,我只能发送一次消息。我不能再发同样的信息了。在代码中,我创建了临时变量k,如果我更改字符串,它将被发送。我的主消息bot只发送了一次,现在不发送了。 有人的建议吗 import json import requests import requests_cache import schedule from mars_api import NASA_API_KEY as nasa_key from ma

我制作了一个脚本,将从NASA API获取的一些信息通过电报发送给一个小组。我制作了一个机器人,我只能发送一次消息。我不能再发同样的信息了。在代码中,我创建了临时变量
k
,如果我更改字符串,它将被发送。我的主消息bot只发送了一次,现在不发送了。 有人的建议吗

import json
import requests
import requests_cache
import schedule

from mars_api import NASA_API_KEY as nasa_key
from mars_api import BOT_TOKEN as bot_token
from mars_api import bot_chatID

# from mars_api import TELEGRAM_API_KEY as telegram_key

requests_cache.install_cache('mars_cache')


class MarsDataLoader:

    def __init__(self,nasa_key):

        self.nasa_key = nasa_key
        data_from_nasa_api = requests.get(f'https://api.nasa.gov/insight_weather/?api_key={nasa_key}&feedtype=json&ver=1.0')
        content = data_from_nasa_api.json()
        self.content = content 

class DayAtMars(MarsDataLoader):

    def __init__(self, content):
        self.today = content['sol_keys'][0]
        self.temperature_on_mars = content[self.today]['AT']['av']
        self.speed_of_wind_on_mars = content[self.today]['HWS']['av']
        self.pressure_on_mars = content[self.today]['PRE']['av']

    def create_weather_on_mars_information(self,):
        massage =f'''Goood morning! Today is going to be sunny day on Elysium Platinia. There will be no clouds. 
        Temperature outside: {self.temperature_on_mars}, light wind with {self.speed_of_wind_on_mars} m/s. Air pressure is {self.pressure_on_mars} Pa. 
        Unfortunately there is still no chance to survive outside on Mars. So brace yourself 
        and prepare for another beautifull day on Earth. In case you ARE on Mars... so sunny 
        weather but still you are in a deep shit if you are outside without a spacesuit on.'''
        return massage

k = 'harrrrry'

def telegram_send_text_massage(massage, bot_token, bot_chatID):

    send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + massage

    response = requests.get(send_text)

    return response.json()

if __name__ == '__main__':
    data_from_nasa_api = MarsDataLoader(nasa_key)
    day_at_mars = DayAtMars(data_from_nasa_api.content)
    current_condition_on_mars = day_at_mars.create_weather_on_mars_information()
    print(type(current_condition_on_mars))
    print(type(k))
    telegram_send_text_massage(k,bot_token,bot_chatID)
    telegram_send_text_massage(current_condition_on_mars,bot_token,bot_chatID)

我已经解决了我的问题。因为我使用了库请求和缓存,所以我认为这是在存储响应。我已经移除了它,现在它开始工作了!无论如何,感谢您的回答

本论坛是针对特定问题,或是针对解决问题的方向。我们不是一个编码/错误修复服务。关于我要问的方向。我的代码正在工作,可能是电报机器人的一些设置,但我找不到它。我添加代码只是为了避免回答这样的问题:首先显示您的代码,这可能是来自电报方面的一些限制,每条消息之间的时间延迟是多少?它表示每分钟20次按摩。但情况是,当我发送消息“让我的一天”并且在15分钟后我想再试一次时,它不会出现在群中,但当我发送“让我的一天”时,它会立即发送。在你的代码中,没有“让我的一天”我的兄弟。。。试着创造一个新的环境,这个问题很可能会自行解决。请点击答案上的“绿色浓密”选择最佳问题。