MicroPython doesn't like f strings

This commit is contained in:
Jimmy 2021-07-08 23:05:44 +12:00
parent 361cb37fe3
commit 7c4f46009e
1 changed files with 4 additions and 4 deletions

View File

@ -10,9 +10,9 @@ with open("config.json", 'r') as f:
offset = "0"
while True:
#long poll for response
querry = f'limit=1&offset={offset}&timeout=10'
querry = 'limit=1&offset={}&timeout=10'.format(offset)
try:
resp = requests.get(url=f'https://api.telegram.org/bot{config["token"]}/{"getUpdates"}?{querry}')
resp = requests.get(url='https://api.telegram.org/bot{}/{}?{}'.format(config["token"], "getUpdates", querry))
json = resp.json()
resp.close()
if json.get("result"):
@ -21,8 +21,8 @@ while True:
text = json["result"][0]["message"]["text"]
print(text)
#echo message
querry = f'chat_id={config["recipient"]}&text={text}'
requests.get(url=f'https://api.telegram.org/bot{config["token"]}/{"sendMessage"}?{querry}')
querry = 'chat_id={}&text={}'.format(config["recipient"], text)
requests.get(url='https://api.telegram.org/bot{}/{}?{}'.format(config["token"], "sendMessage", querry))
except Exception as e:
print(e)
resp.close()