-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
30 lines (18 loc) · 730 Bytes
/
utils.py
File metadata and controls
30 lines (18 loc) · 730 Bytes
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
import requests
from geopy.geocoders import Nominatim
def send_text(TOKEN, USERID, message="test"):
# Create url
url = f'https://api.telegram.org/bot{TOKEN}/sendMessage'
# Create json link with message
data = {'chat_id': USERID, 'text': message}
# POST the message
requests.post(url, data)
def send_location(TOKEN, USERID, location):
loc = Nominatim(user_agent="GetLoc")
getLoc = loc.geocode(f"{location} New Jersey")
# Create url
url = f'https://api.telegram.org/bot{TOKEN}/sendVenue'
# Create json link with message
data = {'chat_id': USERID, 'address': location, 'latitude': getLoc.latitude, 'longitude': getLoc.longitude,'title': location}
# POST the message
requests.post(url, data)