-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (35 loc) · 1.25 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests
import sys
from providers import bing, spotlight
def bot_send_photo(url: str, bot_token: str, chat_id: str, caption: str):
message = requests.post(
f'https://api.telegram.org/bot{bot_token}/sendPhoto',
json={
'chat_id': chat_id,
'photo': url,
'caption': caption,
'parse_mode': 'html'
})
print(message.json())
def bot_send_document(url: str, bot_token: str, chat_id: str, caption: str):
message = requests.post(
f'https://api.telegram.org/bot{bot_token}/sendDocument',
json={
'chat_id': chat_id,
'document': url,
'caption': caption,
'parse_mode': 'html'
})
print(message.json())
def main(bot_token: str, chat_id: str):
# send bing photo
(url, caption) = bing.get_wallpaper_details()
# bot_send_photo(url, bot_token, chat_id, caption)
bot_send_document(url, bot_token, chat_id, caption)
# send spotlight photo
for url, caption in spotlight.get_wallpaper_details():
# bot_send_photo(url, bot_token, chat_id, caption)
bot_send_document(url, bot_token, chat_id, caption)
if __name__ == '__main__':
# typer.run(main)
main(sys.argv[1], sys.argv[2])