farfinx31 commited on
Commit
6a8d4f5
·
verified ·
1 Parent(s): a56bb1b

Upload 7 files

Browse files
Files changed (7) hide show
  1. app.py +938 -0
  2. english.txt +110 -0
  3. hindi.txt +110 -0
  4. kannada.txt +110 -0
  5. marathi.txt +58 -0
  6. pass.txt +1 -0
  7. requirements.txt +27 -0
app.py ADDED
@@ -0,0 +1,938 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Response, Request
2
+ import httpx
3
+ import uvicorn
4
+ import requests
5
+ import asyncio
6
+ import psycopg2
7
+ from psycopg2.extras import RealDictCursor
8
+ import json
9
+ from fastapi.middleware.cors import CORSMiddleware
10
+ app = FastAPI()
11
+ # Database connection
12
+ def get_db_connection():
13
+ import os
14
+ from dotenv import load_dotenv
15
+ load_dotenv()
16
+
17
+ return psycopg2.connect(
18
+ host=os.getenv('DB_HOST', '13.126.242.31'),
19
+ database=os.getenv('DB_NAME', 'whatzapp'),
20
+ user=os.getenv('DB_USER', 'far'),
21
+ password=os.getenv('DB_PASSWORD', 'Finovate@2023')
22
+ )
23
+ app.add_middleware(
24
+ CORSMiddleware,
25
+ allow_origins=["*"], # Allows all origins
26
+ allow_credentials=True,
27
+ allow_methods=["*"], # Allows all methods
28
+ allow_headers=["*"], # Allows all headers
29
+ )
30
+
31
+ # Create users table if it doesn't exist#
32
+ def create_users_table():
33
+ conn = get_db_connection()
34
+ cur = conn.cursor()
35
+
36
+ # Create table with language column and latest_otp
37
+ cur.execute("""
38
+ CREATE TABLE IF NOT EXISTS users (
39
+ id SERIAL PRIMARY KEY,
40
+ phone_number VARCHAR(15) UNIQUE NOT NULL,
41
+ name VARCHAR(100) NOT NULL,
42
+ language VARCHAR(50) DEFAULT 'ENGLISH',
43
+ latest_otp VARCHAR(4),
44
+ count INTEGER DEFAULT 0
45
+ )
46
+ """)
47
+
48
+ # First, try to insert the user
49
+ cur.execute("""
50
+ INSERT INTO users (phone_number, name, language)
51
+ VALUES ('919035576651', 'Farhan', 'ENGLISH')
52
+ ON CONFLICT (phone_number) DO UPDATE
53
+ SET language = 'ENGLISH'
54
+ """)
55
+
56
+ conn.commit()
57
+ cur.close()
58
+ conn.close()
59
+
60
+ # Get user name from phone number
61
+ def langupdate(phone_number, new_lang):
62
+ conn = get_db_connection()
63
+ cur = conn.cursor()
64
+
65
+ try:
66
+ # Try with the original phone number
67
+ cur.execute("UPDATE users SET language = %s WHERE phone_number = %s", (new_lang, phone_number))
68
+
69
+ if cur.rowcount == 0 and phone_number.startswith('91'):
70
+ # Try without the '91' prefix
71
+ phone_without_91 = phone_number[2:]
72
+ cur.execute("UPDATE users SET language = %s WHERE phone_number = %s", (new_lang, phone_without_91))
73
+
74
+ elif cur.rowcount == 0 and not phone_number.startswith('91'):
75
+ # Try with '91' prefix
76
+ phone_with_91 = '91' + phone_number
77
+ cur.execute("UPDATE users SET language = %s WHERE phone_number = %s", (new_lang, phone_with_91))
78
+
79
+ conn.commit()
80
+ return True
81
+ except Exception as e:
82
+ print(f"Error updating language: {e}")
83
+ conn.rollback()
84
+ return False
85
+ finally:
86
+ cur.close()
87
+ conn.close()
88
+
89
+ def get_user_name(phone_number):
90
+ conn = get_db_connection()
91
+ cur = conn.cursor(cursor_factory=RealDictCursor)
92
+
93
+ # Try with the original phone number
94
+ cur.execute("SELECT name FROM users WHERE phone_number = %s", (phone_number,))
95
+ result = cur.fetchone()
96
+
97
+ if not result and phone_number.startswith('91'):
98
+ # Try without the '91' prefix
99
+ phone_without_91 = phone_number[2:]
100
+ cur.execute("SELECT name FROM users WHERE phone_number = %s", (phone_without_91,))
101
+ result = cur.fetchone()
102
+
103
+ elif not result and not phone_number.startswith('91'):
104
+ # Try with '91' prefix
105
+ phone_with_91 = '91' + phone_number
106
+ cur.execute("SELECT name FROM users WHERE phone_number = %s", (phone_with_91,))
107
+ result = cur.fetchone()
108
+
109
+ cur.close()
110
+ conn.close()
111
+ return result['name'] if result else "User"
112
+
113
+ # Load messages and menu options
114
+ def get_user_language(phone_number):
115
+ """Get user's language preference from database"""
116
+ conn = get_db_connection()
117
+ cur = conn.cursor()
118
+
119
+ try:
120
+ # Try with original phone number
121
+ cur.execute("SELECT language FROM users WHERE phone_number = %s", (phone_number,))
122
+ result = cur.fetchone()
123
+
124
+ if not result and phone_number.startswith('91'):
125
+ # Try without '91' prefix
126
+ phone_without_91 = phone_number[2:]
127
+ cur.execute("SELECT language FROM users WHERE phone_number = %s", (phone_without_91,))
128
+ result = cur.fetchone()
129
+
130
+ elif not result and not phone_number.startswith('91'):
131
+ # Try with '91' prefix
132
+ phone_with_91 = '91' + phone_number
133
+ cur.execute("SELECT language FROM users WHERE phone_number = %s", (phone_with_91,))
134
+ result = cur.fetchone()
135
+
136
+ return result[0] if result else 'ENGLISH'
137
+ except Exception as e:
138
+ print(f"Error getting user language: {e}")
139
+ return 'ENGLISH'
140
+ finally:
141
+ cur.close()
142
+ conn.close()
143
+
144
+ def load_messages(phone_number):
145
+ """Load messages in user's preferred language"""
146
+ language = get_user_language(phone_number)
147
+ file_mapping = {
148
+ 'ENGLISH': 'english.txt',
149
+ 'HINDI': 'hindi.txt',
150
+ 'KANNADA': 'kannada.txt',
151
+ 'MARATHI': 'marathi.txt'
152
+ }
153
+
154
+ try:
155
+ filename = file_mapping.get(language, 'english.txt')
156
+ with open(filename, 'r', encoding='utf-8') as file:
157
+ return json.load(file)
158
+ except FileNotFoundError:
159
+ print(f"Error: {filename} not found, falling back to english.txt")
160
+ try:
161
+ with open('english.txt', 'r', encoding='utf-8') as file:
162
+ return json.load(file)
163
+ except FileNotFoundError:
164
+ print("Error: english.txt not found")
165
+ return {}
166
+ except json.JSONDecodeError:
167
+ print(f"Error: Invalid JSON in {filename}")
168
+ return {}
169
+
170
+ # Initialize with English messages
171
+ MESSAGES = {}
172
+
173
+ def reload_messages_for_user(phone_number):
174
+ """Reload messages based on user's language preference"""
175
+ global MESSAGES
176
+ MESSAGES = load_messages(phone_number)
177
+
178
+ app = FastAPI()
179
+
180
+ # Add CORS middleware
181
+ app.add_middleware(
182
+ CORSMiddleware,
183
+ allow_origins=["*"], # Allows all origins
184
+ allow_credentials=True,
185
+ allow_methods=["*"], # Allows all methods
186
+ allow_headers=["*"], # Allows all headers
187
+ )
188
+
189
+ # Create tables on startup
190
+ create_users_table()
191
+
192
+ def read_lang_from_file():
193
+ global LANG
194
+ try:
195
+ with open('LANG.txt', 'r') as file:
196
+ LANG = file.read().strip() # Read the contents of the file and remove any surrounding whitespace
197
+ except FileNotFoundError:
198
+ LANG = "ENGLISH" # Default language if the file doesn't exist
199
+
200
+ def send_whatsapp_message(message, destination_number):
201
+ url = 'https://api.gupshup.io/wa/api/v1/msg'
202
+
203
+ headers = {
204
+ 'Content-Type': 'application/x-www-form-urlencoded',
205
+ 'apikey': 'q67ybibvftgeir1me6apoz7xsymopnuq'
206
+ }
207
+
208
+ payload = {
209
+ 'channel': 'whatsapp',
210
+ 'source': '917834811114',
211
+ 'destination': destination_number,
212
+ 'message': f'{{"type": "text", "text": "{message}", "previewUrl": false}}',
213
+ 'src.name': 'FinovateGlobal'
214
+ }
215
+
216
+ response = requests.post(url, headers=headers, data=payload)
217
+
218
+ if response.status_code == 200:
219
+ return response.json() # Success: return the response in JSON format
220
+ else:
221
+ return f"Failed to send message: {response.status_code}, {response.text}"
222
+
223
+ async def ten(Dest):
224
+ print("Executing Function")
225
+ url = 'https://api.gupshup.io/sm/api/v1/msg'
226
+
227
+ lang_menu = MESSAGES["language_menu"]
228
+ title = lang_menu["title"]
229
+ body = lang_menu["body"]
230
+ global_button_title = "Options"
231
+ items = [
232
+ {
233
+ "title": lang_menu["languages"]["title"],
234
+ "subtitle": lang_menu["languages"]["subtitle"],
235
+ "options": lang_menu["languages"]["options"]
236
+ }
237
+ ]
238
+
239
+ payload = {
240
+ "channel": "whatsapp",
241
+ "source": "917834811114",
242
+ "destination": Dest,
243
+ "src.name": "FinovateGlobal",
244
+ "message": {
245
+ "type": "list",
246
+ "title": title,
247
+ "body": body,
248
+ "msgid": "list1",
249
+ "globalButtons": [{"type": "text", "title": global_button_title}],
250
+ "items": items
251
+ }
252
+ }
253
+ headers = {
254
+ "Content-Type": "application/x-www-form-urlencoded",
255
+ "apikey": "q67ybibvftgeir1me6apoz7xsymopnuq"
256
+ }
257
+ async with httpx.AsyncClient() as client:
258
+ response = await client.post(url, params=payload, headers=headers)
259
+
260
+ print("Response from Gupshup API:", response.text)
261
+
262
+ def send_whatsapp_message_lan(destination, message_body, footer, header, button_title, tracking_text, src_name):
263
+ url = 'https://api.gupshup.io/wa/api/v1/msg'
264
+ headers = {
265
+ 'Cache-Control': 'no-cache',
266
+ 'Content-Type': 'application/x-www-form-urlencoded',
267
+ 'apikey': 'q67ybibvftgeir1me6apoz7xsymopnuq',
268
+ }
269
+ payload = {
270
+ 'channel': 'whatsapp',
271
+ 'source': '917834811114',
272
+ 'destination': destination,
273
+ 'message': f'{{"type":"quick_reply","content":{{"type":"text","text":"{message_body}","caption":"{footer}","header":"{header}"}},"options":[{{"title":"{button_title}","postbackText":"{tracking_text}"}}]}}',
274
+ 'src.name': src_name
275
+ }
276
+
277
+ response = requests.post(url, headers=headers, data=payload)
278
+
279
+ return response
280
+
281
+ def send_whatsapp_message_attach(message, destination_number):
282
+ url = 'https://api.gupshup.io/wa/api/v1/msg'
283
+
284
+ headers = {
285
+ 'Content-Type': 'application/x-www-form-urlencoded',
286
+ 'apikey': 'q67ybibvftgeir1me6apoz7xsymopnuq'
287
+ }
288
+
289
+ payload = {
290
+ 'channel': 'whatsapp',
291
+ 'source': '917834811114',
292
+ 'destination': destination_number,
293
+ 'message': f'{{"type": "text", "text": "https://plum-stephie-67.tiiny.site/", "previewUrl": true}}',
294
+ 'src.name': 'FinovateGlobal'
295
+ }
296
+
297
+ response = requests.post(url, headers=headers, data=payload)
298
+
299
+ if response.status_code == 200:
300
+ return response.json()
301
+ else:
302
+ return f"Failed to send message: {response.status_code}, {response.text}"
303
+
304
+ def send_whatsapp_message_attach_2(message, destination_number):
305
+ url = 'https://api.gupshup.io/wa/api/v1/msg'
306
+
307
+ headers = {
308
+ 'Content-Type': 'application/x-www-form-urlencoded',
309
+ 'apikey': 'q67ybibvftgeir1me6apoz7xsymopnuq'
310
+ }
311
+
312
+ payload = {
313
+ 'channel': 'whatsapp',
314
+ 'source': '917834811114',
315
+ 'destination': destination_number,
316
+ 'message': f'{{"type": "text", "text": "https://pdfupload.io/docs/5319d0fb", "previewUrl": true}}',
317
+ 'src.name': 'FinovateGlobal'
318
+ }
319
+
320
+ response = requests.post(url, headers=headers, data=payload)
321
+
322
+ if response.status_code == 200:
323
+ return response.json()
324
+ else:
325
+ return f"Failed to send message: {response.status_code}, {response.text}"
326
+
327
+ def send_whatsapp_message_attach_1(message, destination_number):
328
+ url = 'https://api.gupshup.io/wa/api/v1/msg'
329
+
330
+ headers = {
331
+ 'Content-Type': 'application/x-www-form-urlencoded',
332
+ 'apikey': 'q67ybibvftgeir1me6apoz7xsymopnuq'
333
+ }
334
+
335
+ payload = {
336
+ 'channel': 'whatsapp',
337
+ 'source': '917834811114',
338
+ 'destination': destination_number,
339
+ 'message': f'{{"type": "text", "text": "https://pdfupload.io/docs/5b8e8d41", "previewUrl": true}}',
340
+ 'src.name': 'FinovateGlobal'
341
+ }
342
+
343
+ response = requests.post(url, headers=headers, data=payload)
344
+
345
+ if response.status_code == 200:
346
+ return response.json()
347
+ else:
348
+ return f"Failed to send message: {response.status_code}, {response.text}"
349
+
350
+ def send_whatsapp_message_pay(message, destination_number):
351
+ url = 'https://api.gupshup.io/wa/api/v1/msg'
352
+
353
+ headers = {
354
+ 'Content-Type': 'application/x-www-form-urlencoded',
355
+ 'apikey': 'q67ybibvftgeir1me6apoz7xsymopnuq'
356
+ }
357
+
358
+ payload = {
359
+ 'channel': 'whatsapp',
360
+ 'source': '917834811114',
361
+ 'destination': destination_number,
362
+ 'message': f'{{"type": "text", "text": "https://rzp.io/rzp/6tAlEUab", "previewUrl": true}}',
363
+ 'src.name': 'FinovateGlobal'
364
+ }
365
+
366
+ response = requests.post(url, headers=headers, data=payload)
367
+
368
+ if response.status_code == 200:
369
+ return response.json()
370
+ else:
371
+ return f"Failed to send message: {response.status_code}, {response.text}"
372
+
373
+
374
+ def send_whatsapp_message_reset(message, destination_number):
375
+ url = 'https://api.gupshup.io/wa/api/v1/msg'
376
+
377
+ headers = {
378
+ 'Content-Type': 'application/x-www-form-urlencoded',
379
+ 'apikey': 'q67ybibvftgeir1me6apoz7xsymopnuq'
380
+ }
381
+
382
+ payload = {
383
+ 'channel': 'whatsapp',
384
+ 'source': '917834811114',
385
+ 'destination': destination_number,
386
+ 'message': f'{{"type": "text", "text": "https://secure-pin-reset.vercel.app", "previewUrl": true}}',
387
+ 'src.name': 'FinovateGlobal'
388
+ }
389
+
390
+ response = requests.post(url, headers=headers, data=payload)
391
+
392
+ if response.status_code == 200:
393
+ return response.json()
394
+ else:
395
+ return f"Failed to send message: {response.status_code}, {response.text}"
396
+
397
+ async def ben(Dest):
398
+ print("Executing Function")
399
+ print(f"Phone number received: {Dest}")
400
+ url = 'https://api.gupshup.io/sm/api/v1/msg'
401
+
402
+ # Get user name from database
403
+ user_name = get_user_name(Dest)
404
+
405
+ # If user not found, send registration message
406
+ if user_name == "User":
407
+ message = MESSAGES["messages"]["registration"]
408
+ response = send_whatsapp_message(message, Dest)
409
+ print("Registration message sent:", response)
410
+ return
411
+
412
+ # Continue with menu for registered users
413
+ title = MESSAGES["welcome_message"].format(user_name=user_name)
414
+ body = MESSAGES["select_options"]
415
+ global_button_title = "Options"
416
+
417
+ # Get menu structure from messages file
418
+ menu = MESSAGES["menu"]
419
+ items = [
420
+ {
421
+ "title": section_data["title"],
422
+ "subtitle": section_data["subtitle"],
423
+ "options": [
424
+ {"type": "text", "title": opt["title"], "postbackText": opt["postbackText"]}
425
+ for opt in section_data["options"]
426
+ ]
427
+ }
428
+ for section_name, section_data in menu.items()
429
+ ]
430
+
431
+ payload = {
432
+ "channel": "whatsapp",
433
+ "source": "917834811114",
434
+ "destination": Dest,
435
+ "src.name": "FinovateGlobal",
436
+ "message": {
437
+ "type": "list",
438
+ "title": title,
439
+ "body": body,
440
+ "msgid": "list1",
441
+ "globalButtons": [{"type": "text", "title": global_button_title}],
442
+ "items": items
443
+ }
444
+ }
445
+ headers = {
446
+ "Content-Type": "application/x-www-form-urlencoded",
447
+ "apikey": "q67ybibvftgeir1me6apoz7xsymopnuq"
448
+ }
449
+
450
+ async with httpx.AsyncClient() as client:
451
+ response = await client.post(url, params=payload, headers=headers)
452
+
453
+ print("Response from Gupshup API:", response.text)
454
+ async def setting(Dest):
455
+ print("Executing Function")
456
+ url = 'https://api.gupshup.io/sm/api/v1/msg'
457
+
458
+ settings = MESSAGES["settings"]
459
+ title = settings["title"]
460
+ body = settings["body"]
461
+ global_button_title = "Options"
462
+
463
+ items = [
464
+ {
465
+ "title": settings["security"]["title"],
466
+ "subtitle": settings["security"]["subtitle"],
467
+ "options": settings["security"]["options"]
468
+ }
469
+ ]
470
+
471
+ payload = {
472
+ "channel": "whatsapp",
473
+ "source": "917834811114",
474
+ "destination": Dest,
475
+ "src.name": "FinovateGlobal",
476
+ "message": {
477
+ "type": "list",
478
+ "title": title,
479
+ "body": body,
480
+ "msgid": "list1",
481
+ "globalButtons": [{"type": "text", "title": global_button_title}],
482
+ "items": items
483
+ }
484
+ }
485
+ headers = {
486
+ "Content-Type": "application/x-www-form-urlencoded",
487
+ "apikey": "q67ybibvftgeir1me6apoz7xsymopnuq"
488
+ }
489
+
490
+ async with httpx.AsyncClient() as client:
491
+ response = await client.post(url, params=payload, headers=headers)
492
+
493
+ print("Response from Gupshup API:", response.text)
494
+
495
+ async def billu(Dest):
496
+ print("Executing Function")
497
+ url = 'https://api.gupshup.io/sm/api/v1/msg'
498
+
499
+ bill_payment = MESSAGES["bill_payment"]
500
+ title = bill_payment["title"]
501
+ body = bill_payment["body"]
502
+ global_button_title = "Options"
503
+
504
+ items = [
505
+ {
506
+ "title": bill_payment["utility_bills"]["title"],
507
+ "subtitle": bill_payment["utility_bills"]["subtitle"],
508
+ "options": bill_payment["utility_bills"]["options"]
509
+ },
510
+ {
511
+ "title": bill_payment["vehicle_bills"]["title"],
512
+ "subtitle": bill_payment["vehicle_bills"]["subtitle"],
513
+ "options": bill_payment["vehicle_bills"]["options"]
514
+ }
515
+ ]
516
+
517
+ payload = {
518
+ "channel": "whatsapp",
519
+ "source": "917834811114",
520
+ "destination": Dest,
521
+ "src.name": "FinovateGlobal",
522
+ "message": {
523
+ "type": "list",
524
+ "title": title,
525
+ "body": body,
526
+ "msgid": "list1",
527
+ "globalButtons": [{"type": "text", "title": global_button_title}],
528
+ "items": items
529
+ }
530
+ }
531
+ headers = {
532
+ "Content-Type": "application/x-www-form-urlencoded",
533
+ "apikey": "q67ybibvftgeir1me6apoz7xsymopnuq"
534
+ }
535
+
536
+ async with httpx.AsyncClient() as client:
537
+ response = await client.post(url, params=payload, headers=headers)
538
+
539
+ print("Response from Gupshup API:", response.text)
540
+
541
+ async def benny(Dest):
542
+ print("Executing Function")
543
+ url = 'https://api.gupshup.io/sm/api/v1/msg'
544
+
545
+ # Get menu structure from messages file
546
+ menu = MESSAGES["menu"]
547
+ title = "Thank you" # This could also be moved to language files
548
+ body = MESSAGES["select_options"]
549
+ global_button_title = "Options"
550
+
551
+ items = [
552
+ {
553
+ "title": section_data["title"],
554
+ "subtitle": section_data["subtitle"],
555
+ "options": [
556
+ {"type": "text", "title": opt["title"], "postbackText": opt["postbackText"]}
557
+ for opt in section_data["options"]
558
+ ]
559
+ }
560
+ for section_name, section_data in menu.items()
561
+ ]
562
+
563
+ payload = {
564
+ "channel": "whatsapp",
565
+ "source": "917834811114",
566
+ "destination": Dest,
567
+ "src.name": "FinovateGlobal",
568
+ "message": {
569
+ "type": "list",
570
+ "title": title,
571
+ "body": body,
572
+ "msgid": "list1",
573
+ "globalButtons": [{"type": "text", "title": global_button_title}],
574
+ "items": items
575
+ }
576
+ }
577
+ headers = {
578
+ "Content-Type": "application/x-www-form-urlencoded",
579
+ "apikey": "q67ybibvftgeir1me6apoz7xsymopnuq"
580
+ }
581
+
582
+ async with httpx.AsyncClient() as client:
583
+ response = await client.post(url, params=payload, headers=headers)
584
+
585
+ print("Response from Gupshup API:", response.text)
586
+
587
+ def check_authentication():
588
+ try:
589
+ with open('pass.txt', 'r') as file:
590
+ passcode = file.read().strip()
591
+ return passcode == "4356"
592
+ except FileNotFoundError:
593
+ return False
594
+
595
+ @app.get("/add-passcode")
596
+ async def add_passcode():
597
+ try:
598
+ with open('pass.txt', 'w') as file:
599
+ file.write("4356")
600
+ return {"message": "Passcode added successfully"}
601
+ except Exception as e:
602
+ return {"error": str(e)}
603
+
604
+ @app.get("/remove-passcode")
605
+ async def remove_passcode():
606
+ try:
607
+ with open('pass.txt', 'w') as file:
608
+ file.write("")
609
+ return {"message": "Passcode removed successfully"}
610
+ except Exception as e:
611
+ return {"error": str(e)}
612
+
613
+ @app.get("/hello")
614
+ def read_hello():
615
+ return {"message": "Hello"}
616
+
617
+ @app.get("/total-count")
618
+ async def get_total_count():
619
+ try:
620
+ conn = get_db_connection()
621
+ cur = conn.cursor()
622
+ cur.execute("SELECT SUM(COALESCE(count, 0)) as total FROM users")
623
+ result = cur.fetchone()
624
+ total = result[0] if result[0] is not None else 0
625
+ cur.close()
626
+ conn.close()
627
+ return {"total_count": total}
628
+ except Exception as e:
629
+ print(f"Error getting total count: {e}")
630
+ return {"error": "Failed to get total count"}
631
+
632
+ @app.post("/hello")
633
+ async def read_root(request: Request):
634
+ data = await request.json()
635
+ print("Incoming Request:", data)
636
+
637
+ # Get the user's phone number and load appropriate language messages
638
+ Dest = data["payload"]["source"]
639
+ reload_messages_for_user(Dest)
640
+ print(f"Loaded messages for language: {get_user_language(Dest)}")
641
+
642
+ # Increment count for the user
643
+ try:
644
+ conn = get_db_connection()
645
+ cur = conn.cursor()
646
+ cur.execute("""
647
+ UPDATE users
648
+ SET count = COALESCE(count, 0) + 1
649
+ WHERE phone_number = %s
650
+ """, (Dest,))
651
+ conn.commit()
652
+ cur.close()
653
+ conn.close()
654
+ except Exception as e:
655
+ print(f"Error incrementing count: {e}")
656
+
657
+ # Check authentication
658
+ if not check_authentication():
659
+ message = "please login to access Whatsapp Banking:- https://pinw-1.onrender.com/"
660
+ response = send_whatsapp_message(message, Dest)
661
+ return Response(content="Authentication failed", status_code=401)
662
+
663
+ if "Hi" in str(data):
664
+ Dest = data["payload"]["source"]
665
+ await ben(Dest)
666
+ print("Function ben() executed for destination:", Dest)
667
+ return Response(content="Message sent", status_code=200)
668
+
669
+ elif "BALENG" in str(data):
670
+ Dest = data["payload"]["source"]
671
+
672
+ # Get balance from database
673
+ conn = get_db_connection()
674
+ cur = conn.cursor()
675
+ cur.execute("SELECT balance FROM users WHERE phone_number = %s", (Dest,))
676
+ result = cur.fetchone()
677
+ cur.close()
678
+ conn.close()
679
+
680
+ if result:
681
+ balance = result[0]
682
+ message = MESSAGES["messages"]["balance"].format(balance=balance)
683
+ else:
684
+ message = MESSAGES["messages"]["balance_error"]
685
+
686
+ destination_number = Dest
687
+ response = send_whatsapp_message(message, destination_number)
688
+ print(response)
689
+ await benny(Dest)
690
+
691
+ elif "USER002" in str(data):
692
+ Dest = data["payload"]["source"]
693
+ message = MESSAGES["messages"]["recent_transactions"]
694
+ destination_number = Dest
695
+ response = send_whatsapp_message_attach(message, destination_number)
696
+ print(response)
697
+ await benny(Dest)
698
+
699
+ elif "BILLS" in str(data):
700
+ Dest = data["payload"]["source"]
701
+ message = MESSAGES["messages"]["account_statement"]
702
+ destination_number = Dest
703
+ response = send_whatsapp_message_attach_1(message, destination_number)
704
+ print(response)
705
+ await benny(Dest)
706
+
707
+ elif "DEL" in str(data):
708
+ Dest = data["payload"]["source"]
709
+ message = MESSAGES["messages"]["emi_payment"]
710
+ destination_number = Dest
711
+ response = send_whatsapp_message_pay(message, destination_number)
712
+ print(response)
713
+ await benny(Dest)
714
+
715
+ elif "RESETPIN" in str(data):
716
+ Dest = data["payload"]["source"]
717
+ message = MESSAGES["messages"]["password_reset"]
718
+ destination_number = Dest
719
+ response = send_whatsapp_message_reset(message, destination_number)
720
+ print(response)
721
+ await benny(Dest)
722
+
723
+ elif any(code in str(data) for code in ["ELEC", "WATER", "FAST"]):
724
+ Dest = data["payload"]["source"]
725
+ message = MESSAGES["messages"]["enter_bill"]
726
+ destination_number = Dest
727
+ response = send_whatsapp_message(message, destination_number)
728
+ print(response)
729
+ #await benny(Dest)
730
+
731
+ elif "ADD" in str(data):
732
+ Dest = data["payload"]["source"]
733
+ message = MESSAGES["messages"]["loan_statement"]
734
+ destination_number = Dest
735
+ response = send_whatsapp_message_attach_2(message, destination_number)
736
+ print(response)
737
+ await benny(Dest)
738
+
739
+ elif "WLANG" in str(data) :
740
+ Dest = data["payload"]["source"]
741
+ await ten(Dest)
742
+
743
+ elif "DooDu" in str(data):
744
+ Dest = data["payload"]["source"]
745
+ message = MESSAGES["messages"]["fd_scheme"]
746
+ message_body = MESSAGES["messages"]["fd_nominee"]
747
+ button_title = 'Apply'
748
+ footer = '8.5 %'
749
+ header = ''
750
+ tracking_text = 'traackindg123'
751
+ src_name = 'FinovateGlobal'
752
+
753
+ destination_number = Dest
754
+ response = send_whatsapp_message(message, destination_number)
755
+ print("WhatsApp message sent:", response)
756
+
757
+ try:
758
+ response = send_whatsapp_message_lan(destination_number, message_body, footer, header, button_title, tracking_text, src_name)
759
+ print("Additional message sent:", response)
760
+ # Wait for 3 seconds before showing the menu
761
+ await asyncio.sleep(3)
762
+ await benny(Dest)
763
+ except Exception as e:
764
+ print("Error sending additional message:", e)
765
+
766
+ elif "PR" in str(data):
767
+ Dest = data["payload"]["source"]
768
+ message = MESSAGES["messages"]["request_sent"]
769
+ destination_number = Dest
770
+ response = send_whatsapp_message(message, destination_number)
771
+ print("WhatsApp message sent:", response)
772
+ await benny(Dest)
773
+
774
+
775
+ elif "TILLS" in str(data):
776
+ Dest = data["payload"]["source"]
777
+ message = MESSAGES["messages"]["request_sent"]
778
+ destination_number = Dest
779
+ response = send_whatsapp_message(message, destination_number)
780
+ print("WhatsApp message sent:", response)
781
+ await benny(Dest)
782
+ elif "DANK" in str(data):
783
+ Dest = data["payload"]["source"]
784
+ await billu(Dest)
785
+
786
+ elif "SETWET" in str(data):
787
+ Dest = data["payload"]["source"]
788
+ await setting(Dest)
789
+ return Response(content="Message sent", status_code=200) # Add return statement
790
+
791
+ elif "PERCIS" in str(data):
792
+ Dest = data["payload"]["source"]
793
+ message = MESSAGES["messages"]["enter_cheque"]
794
+ destination_number = Dest
795
+ response = send_whatsapp_message(message, destination_number)
796
+ print("WhatsApp message sent:", response)
797
+ elif "FREEZE" in str(data):
798
+ try:
799
+ Dest = data["payload"]["source"]
800
+ message = "Logged out for now"
801
+ destination_number = Dest
802
+
803
+ # Send WhatsApp message
804
+ whatsapp_response = send_whatsapp_message(message, destination_number)
805
+ print("WhatsApp message sent:", whatsapp_response)
806
+ #import requests
807
+ # Remove passcode
808
+ #api_response = requests.get('http://localhost:8000/remove-passcode')
809
+ #print("Passcode removal response:", api_response.json())
810
+
811
+ # Clear the passcode file directly as backup
812
+ with open('pass.txt', 'w') as file:
813
+ file.write("")
814
+
815
+ return Response(content="Service frozen successfully", status_code=200)
816
+
817
+ except Exception as e:
818
+ print(f"Error in FREEZE operation: {e}")
819
+ return Response(content="Error processing request", status_code=500)
820
+
821
+ elif any(code in str(data) for code in ["tracking123", "xcd123", "dtsi", "vlsi"]):
822
+ Dest = data["payload"]["source"]
823
+
824
+ # Set language and message based on code
825
+ if "tracking123" in str(data):
826
+ new_lang = "HINDI"
827
+ elif "xcd123" in str(data):
828
+ new_lang = "ENGLISH"
829
+ elif "dtsi" in str(data):
830
+ new_lang = "KANNADA"
831
+ elif "vlsi" in str(data):
832
+ new_lang = "MARATHI"
833
+
834
+ # Update language in database
835
+ if langupdate(Dest, new_lang):
836
+ # Reload messages in new language
837
+ reload_messages_for_user(Dest)
838
+ # Get success message in the new language
839
+ message = MESSAGES["messages"]["language_changed"][new_lang]
840
+ response = send_whatsapp_message(message, Dest)
841
+ else:
842
+ # Send error message
843
+ error_message = MESSAGES["messages"]["language_update_error"]
844
+ response = send_whatsapp_message(error_message, Dest)
845
+
846
+ await benny(Dest)
847
+ # Check for 12-digit number with Stop/ISSUE or 4/6 digit numbers
848
+ elif data["payload"]["type"] == "text":
849
+ text = data["payload"]["payload"]["text"]
850
+ Dest = data["payload"]["source"]
851
+
852
+ # Check for 12-digit number with Stop/ISSUE
853
+ if any(word.lower() in text.lower() for word in ["stop", "issue"]):
854
+ numbers = [num for num in text.split() if num.isdigit() and len(num) == 12]
855
+ if numbers:
856
+ message = MESSAGES["messages"]["request_sent"]
857
+ response = send_whatsapp_message(message, Dest)
858
+ print("WhatsApp message sent:", response)
859
+ await benny(Dest)
860
+ return Response(content="Message sent", status_code=200)
861
+
862
+ # Handle numeric inputs (4 or 6 digits)
863
+ if text.isdigit():
864
+ if len(text) == 6:
865
+ # Handle 6-digit check number
866
+ message = MESSAGES["messages"]["outstanding_amount"]
867
+ response = send_whatsapp_message(message, Dest)
868
+ print("WhatsApp message sent:", response)
869
+
870
+ # Generate and store OTP
871
+ import random
872
+ otp = str(random.randint(1000, 9999))
873
+ conn = get_db_connection()
874
+ cur = conn.cursor()
875
+ cur.execute("""
876
+ UPDATE users
877
+ SET latest_otp = %s
878
+ WHERE phone_number = %s
879
+ """, (otp, Dest))
880
+ conn.commit()
881
+ cur.close()
882
+ conn.close()
883
+
884
+ # Send OTP via Twilio
885
+ import requests
886
+ url = 'https://api.twilio.com/2010-04-01/Accounts/AC7a5e6d3727d4e6cd8c66a619cc364aa2/Messages.json'
887
+ auth = ('AC7a5e6d3727d4e6cd8c66a619cc364aa2', '3f7e9ba092833226f054044d00a39c10')
888
+ data = {
889
+ 'To': "+"+Dest,
890
+ 'From': '+16084077139',
891
+ 'Body': f'OTP for Transaction: {otp}'
892
+ }
893
+ twilio_response = requests.post(url, data=data, auth=auth)
894
+ print("Twilio Response:", twilio_response.json())
895
+ return Response(content="Message sent", status_code=200)
896
+
897
+ elif len(text) == 4:
898
+ # Handle 4-digit OTP verification
899
+ conn = get_db_connection()
900
+ cur = conn.cursor()
901
+ cur.execute("SELECT latest_otp, balance FROM users WHERE phone_number = %s", (Dest,))
902
+ result = cur.fetchone()
903
+
904
+ if result and result[0] == text:
905
+ stored_otp, current_balance = result[0], result[1]
906
+ if current_balance >= 597:
907
+ new_balance = current_balance - 597
908
+ cur.execute("""
909
+ UPDATE users
910
+ SET balance = %s, latest_otp = NULL
911
+ WHERE phone_number = %s
912
+ """, (new_balance, Dest))
913
+ conn.commit()
914
+ message = MESSAGES["messages"]["payment_success"].format(new_balance=new_balance)
915
+ else:
916
+ message = MESSAGES["messages"]["insufficient_balance"]
917
+ else:
918
+ message = MESSAGES["messages"]["invalid_otp"]
919
+
920
+ cur.close()
921
+ conn.close()
922
+ response = send_whatsapp_message(message, Dest)
923
+ print("Response message sent:", response)
924
+ return Response(content="Message sent", status_code=200)
925
+
926
+ # If no special patterns match, show main menu
927
+ await ben(Dest)
928
+ return Response(content="Message sent", status_code=200)
929
+ else:
930
+ Dest = data["payload"]["source"]
931
+ await ben(Dest)
932
+ print("Function ben() executed for destination:", Dest)
933
+ return Response(content="Message sent", status_code=200)
934
+
935
+ if __name__ == "__main__":
936
+ uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=False, log_level="debug",
937
+ workers=1, limit_concurrency=1, limit_max_requests=1)
938
+
english.txt ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "welcome_message": "Dear {user_name}, Welcome to National Co-operative Bank",
3
+ "select_options": "Please Select the Options",
4
+ "menu": {
5
+ "account_services": {
6
+ "title": "Account Services",
7
+ "subtitle": "please select the option below",
8
+ "options": [
9
+ {"title": "Balance", "postbackText": "BALENG"},
10
+ {"title": "Recent 7 Transactions", "postbackText": "USER002"},
11
+ {"title": "Account Statement", "postbackText": "BILLS"}
12
+ ]
13
+ },
14
+ "loan_services": {
15
+ "title": "Loan Service",
16
+ "subtitle": "Please Select the Service",
17
+ "options": [
18
+ {"title": "Pay EMI", "postbackText": "DEL"},
19
+ {"title": "Loan Statement", "postbackText": "ADD"}
20
+ ]
21
+ },
22
+ "fd_bills": {
23
+ "title": "FD & Bills",
24
+ "subtitle": "Please Select the Service",
25
+ "options": [
26
+ {"title": "Apply for FD", "postbackText": "DooDu"},
27
+ {"title": "Bill Payments", "postbackText": "DANK"}
28
+ ]
29
+ },
30
+ "other_services": {
31
+ "title": "Other Services",
32
+ "subtitle": "Please Select the Service",
33
+ "options": [
34
+ {"title": "Cheque & Passbook", "postbackText": "PERCIS"},
35
+ {"title": "Change Language", "postbackText": "WLANG"},
36
+ {"title": "Settings", "postbackText": "SETWET"}
37
+ ]
38
+ }
39
+ },
40
+ "messages": {
41
+ "registration": "Please register for WhatsApp service with your bank",
42
+ "balance": "Here are the details of your Active Account AC0283XXX- Available Balance INR {balance:.2f}",
43
+ "balance_error": "Unable to fetch balance. Please try again later.",
44
+ "recent_transactions": "Recent 7 transactions of your account",
45
+ "account_statement": "Your Account Statement",
46
+ "emi_payment": "EMI Payment Page",
47
+ "password_reset": "Password Reset Page",
48
+ "enter_bill": "Enter Bill Number",
49
+ "loan_statement": "Loan Statement",
50
+ "fd_scheme": "Fixed Deposit Scheme offering 8.5%",
51
+ "fd_nominee": "Default Nominee: Wife",
52
+ "request_sent": "Request sent",
53
+ "enter_cheque": "Enter 12 Digit Number,followed by STOP or ISSUE",
54
+ "outstanding_amount": "Outstanding Amount is Rs 597 , Please share the OTP sent,to increase limit contact bank",
55
+ "payment_success": "Payment successful! Rs 597 has been deducted. New balance: Rs {new_balance:.2f}",
56
+ "insufficient_balance": "Insufficient balance for this transaction.",
57
+ "invalid_otp": "Invalid OTP. Please try again.",
58
+ "language_changed": {
59
+ "HINDI": "भाषा बदलकर हिंदी हो गई",
60
+ "ENGLISH": "Language changed to English",
61
+ "KANNADA": "ಭಾಷೆಯನ್ನು ಕನ್ನಡಕ್ಕೆ ಬದಲಾಯಿಸಲಾಗಿದೆ",
62
+ "MARATHI": "भाषा मराठी मध्ये बदलली"
63
+ },
64
+ "language_update_error": "Failed to update language. Please try again."
65
+ },
66
+ "bill_payment": {
67
+ "title": "Bill Payment Services",
68
+ "body": "Please Select the Bill to Pay",
69
+ "utility_bills": {
70
+ "title": "Utility Bills",
71
+ "subtitle": "Select utility bill to pay",
72
+ "options": [
73
+ {"title": "Electricity Bill", "postbackText": "ELEC"},
74
+ {"title": "Water Bill", "postbackText": "WATER"}
75
+ ]
76
+ },
77
+ "vehicle_bills": {
78
+ "title": "Vehicle Bills",
79
+ "subtitle": "Select vehicle related bill",
80
+ "options": [
81
+ {"title": "FASTag Recharge", "postbackText": "FAST"}
82
+ ]
83
+ }
84
+ },
85
+ "settings": {
86
+ "title": "Account Settings",
87
+ "body": "Please Select an Option",
88
+ "security": {
89
+ "title": "Security Settings",
90
+ "subtitle": "Manage your account security",
91
+ "options": [
92
+ {"title": "Logout", "postbackText": "FREEZE"},
93
+ {"title": "Reset PIN", "postbackText": "RESETPIN"}
94
+ ]
95
+ }
96
+ },
97
+ "language_menu": {
98
+ "title": "Please change the language",
99
+ "body": "Please Select the Options",
100
+ "languages": {
101
+ "title": "Languages",
102
+ "subtitle": "Please Select the Service",
103
+ "options": [
104
+ {"title": "ENGLISH", "postbackText": "xcd123"},
105
+ {"title": "ಕನ್ನಡ", "postbackText": "dtsi"},
106
+ {"title": "हिन्दी", "postbackText": "tracking123"}
107
+ ]
108
+ }
109
+ }
110
+ }
hindi.txt ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "welcome_message": "प्रिय {user_name}, नेशनल को-ऑपरेटिव बैंक में आपका स्वागत है",
3
+ "select_options": "कृपया विकल्प चुनें",
4
+ "menu": {
5
+ "account_services": {
6
+ "title": "खाता सेवाएं",
7
+ "subtitle": "कृपया नीचे दिए गए विकल्प का चयन करें",
8
+ "options": [
9
+ {"title": "बैलेंस", "postbackText": "BALENG"},
10
+ {"title": "हाल के 7 लेनदेन", "postbackText": "USER002"},
11
+ {"title": "खाता विवरण", "postbackText": "BILLS"}
12
+ ]
13
+ },
14
+ "loan_services": {
15
+ "title": "ऋण सेवा",
16
+ "subtitle": "कृपया सेवा का चयन करें",
17
+ "options": [
18
+ {"title": "EMI भुगतान", "postbackText": "DEL"},
19
+ {"title": "ऋण विवरण", "postbackText": "ADD"}
20
+ ]
21
+ },
22
+ "fd_bills": {
23
+ "title": "FD और बिल",
24
+ "subtitle": "कृपया सेवा का चयन करें",
25
+ "options": [
26
+ {"title": "FD के लिए आवेदन करें", "postbackText": "DooDu"},
27
+ {"title": "बिल भुगतान", "postbackText": "DANK"}
28
+ ]
29
+ },
30
+ "other_services": {
31
+ "title": "अन्य सेवाएं",
32
+ "subtitle": "कृपया सेवा का चयन करें",
33
+ "options": [
34
+ {"title": "चेक और पासबुक", "postbackText": "PERCIS"},
35
+ {"title": "भाषा बदलें", "postbackText": "WLANG"},
36
+ {"title": "कार्ड सेवाएं", "postbackText": "SETWET"}
37
+ ]
38
+ }
39
+ },
40
+ "messages": {
41
+ "registration": "कृपया अपने बैंक के साथ व्हाट्सएप सेवा के लिए पंजीकरण करें",
42
+ "balance": "आपके सक्रिय खाते AC0283XXX का विवरण - उपलब्ध शेष राशि INR {balance:.2f}",
43
+ "balance_error": "बैलेंस प्राप्त करने में असमर्थ। कृपया बाद में पुनः प्रयास करें।",
44
+ "recent_transactions": "आपके खाते के हाल के 7 लेनदेन",
45
+ "account_statement": "आपका खाता विवरण",
46
+ "emi_payment": "EMI भुगतान पृष्ठ",
47
+ "password_reset": "पासवर्ड रीसेट पृष्ठ",
48
+ "enter_bill": "बिल नंबर दर्ज करें",
49
+ "loan_statement": "ऋण विवरण",
50
+ "fd_scheme": "8.5% की पेशकश वाली फिक्स्ड डिपॉजिट योजना",
51
+ "fd_nominee": "डिफ़ॉल्ट नामांकित: पत्नी",
52
+ "request_sent": "अनुरोध भेजा गया",
53
+ "enter_cheque": "12 अंकों की संख्या दर्ज करें, उसके बाद STOP या ISSUE",
54
+ "outstanding_amount": "बकाया राशि Rs 597 है, कृपया भेजा गया OTP साझा करें",
55
+ "payment_success": "भुगतान सफल! Rs 597 काट लिए गए हैं। नई शेष राशि: Rs {new_balance:.2f}",
56
+ "insufficient_balance": "इस लेनदेन के लिए अपर्याप्त शेष राशि।",
57
+ "invalid_otp": "अमान्य OTP। कृपया पुनः प्रयास करें।",
58
+ "language_changed": {
59
+ "HINDI": "भाषा बदलकर हिंदी हो गई",
60
+ "ENGLISH": "Language changed to English",
61
+ "KANNADA": "ಭಾಷೆಯನ್ನು ಕನ್ನಡಕ್ಕೆ ಬದಲಾಯಿಸಲಾಗಿದೆ",
62
+ "MARATHI": "भाषा मराठी मध्ये बदलली"
63
+ },
64
+ "language_update_error": "भाषा अपडेट करने में विफल। कृपया पुनः प्रयास करें।"
65
+ },
66
+ "bill_payment": {
67
+ "title": "बिल भुगतान सेवाएं",
68
+ "body": "कृपया भुगतान करने के लिए बिल चुनें",
69
+ "utility_bills": {
70
+ "title": "उपयोगिता बिल",
71
+ "subtitle": "भुगतान करने के लिए उपयोगिता बिल चुनें",
72
+ "options": [
73
+ {"title": "बिज��ी बिल", "postbackText": "ELEC"},
74
+ {"title": "पानी का बिल", "postbackText": "WATER"}
75
+ ]
76
+ },
77
+ "vehicle_bills": {
78
+ "title": "वाहन बिल",
79
+ "subtitle": "वाहन संबंधित बिल चुनें",
80
+ "options": [
81
+ {"title": "फास्टैग रिचार्ज", "postbackText": "FAST"}
82
+ ]
83
+ }
84
+ },
85
+ "settings": {
86
+ "title": "खाता सेटिंग्स",
87
+ "body": "कृपया एक विकल्प चुनें",
88
+ "security": {
89
+ "title": "सेटिंग्स",
90
+ "subtitle": "अपनी खाता सुरक्षा प्रबंधित करें",
91
+ "options": [
92
+ {"title": "सेवा फ्रीज करें", "postbackText": "FREEZE"},
93
+ {"title": "पिन रीसेट करें", "postbackText": "RESETPIN"}
94
+ ]
95
+ }
96
+ },
97
+ "language_menu": {
98
+ "title": "कृपया भाषा बदलें",
99
+ "body": "कृपया विकल्प चुनें",
100
+ "languages": {
101
+ "title": "भाषाएं",
102
+ "subtitle": "कृपया सेवा का चयन करें",
103
+ "options": [
104
+ {"title": "ENGLISH", "postbackText": "xcd123"},
105
+ {"title": "ಕನ್ನಡ", "postbackText": "dtsi"},
106
+ {"title": "हिन्दी", "postbackText": "tracking123"}
107
+ ]
108
+ }
109
+ }
110
+ }
kannada.txt ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "welcome_message": "ಪ್ರಿಯ {user_name}, ನ್ಯಾಷನಲ್ ಕೋ-ಆಪರೇಟಿವ್ ಬ್ಯಾಂಕ್‌ಗೆ ಸ್ವಾಗತ",
3
+ "select_options": "ದಯವಿಟ್ಟು ಆಯ್ಕೆಗಳನ್ನು ಆರಿಸಿ",
4
+ "menu": {
5
+ "account_services": {
6
+ "title": "ಖಾತೆ ಸೇವೆಗಳು",
7
+ "subtitle": "ದಯವಿಟ್ಟು ಕೆಳಗಿನ ಆಯ್ಕೆಯನ್ನು ಆರಿಸಿ",
8
+ "options": [
9
+ {"title": "ಬ್ಯಾಲೆನ್ಸ್", "postbackText": "BALENG"},
10
+ {"title": "ಇತ್ತೀಚಿನ 7 ವಹಿವಾಟುಗಳು", "postbackText": "USER002"},
11
+ {"title": "ಖಾತೆ ವಿವರಣೆ", "postbackText": "BILLS"}
12
+ ]
13
+ },
14
+ "loan_services": {
15
+ "title": "ಸಾಲದ ಸೇವೆ",
16
+ "subtitle": "ದಯವಿಟ್ಟು ಸೇವೆಯನ್ನು ಆರಿಸಿ",
17
+ "options": [
18
+ {"title": "EMI ಪಾವತಿ", "postbackText": "DEL"},
19
+ {"title": "ಸಾಲದ ವಿವರಣೆ", "postbackText": "ADD"}
20
+ ]
21
+ },
22
+ "fd_bills": {
23
+ "title": "FD ಮತ್ತು ಬಿಲ್‌ಗಳು",
24
+ "subtitle": "ದಯವಿಟ್ಟು ಸೇವೆಯನ್ನು ಆರಿಸಿ",
25
+ "options": [
26
+ {"title": "FD ಗೆ ಅರ್ಜಿ ಸಲ್ಲಿಸಿ", "postbackText": "DooDu"},
27
+ {"title": "ಬಿಲ್ ಪಾವತಿಗಳು", "postbackText": "DANK"}
28
+ ]
29
+ },
30
+ "other_services": {
31
+ "title": "ಇತರ ಸೇವೆಗಳು",
32
+ "subtitle": "ದಯವಿಟ್ಟು ಸೇವೆಯನ್ನು ಆರಿಸಿ",
33
+ "options": [
34
+ {"title": "ಚೆಕ್ ಮತ್ತು ಪಾಸ್‌ಬುಕ್", "postbackText": "PERCIS"},
35
+ {"title": "ಭಾಷೆ ಬದಲಾಯಿಸಿ", "postbackText": "WLANG"},
36
+ {"title": "ಕಾರ್ಡ್ ಸೇವೆಗಳು", "postbackText": "SETWET"}
37
+ ]
38
+ }
39
+ },
40
+ "messages": {
41
+ "registration": "ದಯವಿಟ್ಟು ನಿಮ್ಮ ಬ್ಯಾಂಕ್‌ನೊಂದಿಗೆ ವಾಟ್ಸಾಪ್ ಸೇವೆಗೆ ನೋಂದಾಯಿಸಿಕೊಳ್ಳಿ",
42
+ "balance": "ನಿಮ್ಮ ಸಕ್ರಿಯ ಖಾತೆ AC0283XXX ವಿವರಗಳು - ಲಭ್ಯವಿರುವ ಬ್ಯಾಲೆನ್ಸ್ INR {balance:.2f}",
43
+ "balance_error": "ಬ್ಯಾಲೆನ್ಸ್ ಪಡೆಯಲು ಸಾಧ್ಯವಾಗಲಿಲ್ಲ. ದಯವಿಟ್ಟು ನಂತರ ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ.",
44
+ "recent_transactions": "ನಿಮ್ಮ ಖಾತೆಯ ಇತ್ತೀಚಿನ 7 ವಹಿವಾಟುಗಳು",
45
+ "account_statement": "ನಿಮ್ಮ ಖಾತೆ ವಿವರಣೆ",
46
+ "emi_payment": "EMI ಪಾವತಿ ಪುಟ",
47
+ "password_reset": "ಪಾಸ್‌ವರ್ಡ್ ರೀಸೆಟ್ ಪುಟ",
48
+ "enter_bill": "ಬಿಲ್ ಸಂಖ್ಯೆಯನ್ನು ನಮೂದಿಸಿ",
49
+ "loan_statement": "ಸಾಲದ ವಿವರಣೆ",
50
+ "fd_scheme": "8.5% ಆಫರ್ ಮಾಡುವ ಫಿಕ್ಸ್ಡ್ ಡಿಪಾಸಿಟ್ ಯೋಜನೆ",
51
+ "fd_nominee": "ಡೀಫಾಲ್ಟ್ ನಾಮಿನಿ: ಪತ್ನಿ",
52
+ "request_sent": "ವಿನಂತಿ ಕಳುಹಿಸಲಾಗಿದೆ",
53
+ "enter_cheque": "12 ಅಂಕಿಗಳ ಸಂಖ್ಯೆಯನ್ನು ನಮೂದಿಸಿ, ನಂತರ STOP ಅಥವಾ ISSUE",
54
+ "outstanding_amount": "ಬಾಕಿ ಮೊತ್ತ Rs 3000, ದಯವಿಟ್ಟು ಕಳುಹಿಸಿದ OTP ಯನ್ನು ಹಂಚಿಕೊಳ್ಳಿ",
55
+ "payment_success": "ಪಾವತಿ ಯಶಸ್ವಿ! Rs 3000 ಕಡಿತಗೊಳಿಸಲಾಗಿದೆ. ಹೊಸ ಬ್ಯಾಲೆನ್ಸ್: Rs {new_balance:.2f}",
56
+ "insufficient_balance": "ಈ ವಹಿವಾಟಿಗೆ ಅಪರ್ಯಾಪ್ತ ಬ್ಯಾಲೆನ್ಸ್.",
57
+ "invalid_otp": "ಅಮಾನ್ಯ OTP. ದಯವಿಟ್ಟು ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ.",
58
+ "language_changed": {
59
+ "HINDI": "भाषा बदलकर हिंदी हो गई",
60
+ "ENGLISH": "Language changed to English",
61
+ "KANNADA": "ಭಾಷೆಯನ್ನು ಕನ್ನಡಕ್ಕೆ ಬದಲಾಯಿಸಲಾಗಿದೆ",
62
+ "MARATHI": "भाषा मराठी मध्ये बदलली"
63
+ },
64
+ "language_update_error": "ಭಾಷೆಯನ್ನು ನವೀಕರಿಸಲು ವಿಫಲವಾಗಿದೆ. ದಯವಿಟ್ಟು ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ."
65
+ },
66
+ "bill_payment": {
67
+ "title": "ಬಿಲ್ ಪಾವತಿ ಸೇವೆಗಳು",
68
+ "body": "ದಯವ���ಟ್ಟು ಪಾವತಿಸಲು ಬಿಲ್ ಆಯ್ಕೆಮಾಡಿ",
69
+ "utility_bills": {
70
+ "title": "ಉಪಯುಕ್ತತೆ ಬಿಲ್‌ಗಳು",
71
+ "subtitle": "ಪಾವತಿಸಲು ಉಪಯುಕ್ತತೆ ಬಿಲ್ ಆಯ್ಕೆಮಾಡಿ",
72
+ "options": [
73
+ {"title": "ವಿದ್ಯುತ್ ಬಿಲ್", "postbackText": "ELEC"},
74
+ {"title": "ನೀರಿನ ಬಿಲ್", "postbackText": "WATER"}
75
+ ]
76
+ },
77
+ "vehicle_bills": {
78
+ "title": "ವಾಹನ ಬಿಲ್‌ಗಳು",
79
+ "subtitle": "ವಾಹನ ಸಂಬಂಧಿತ ಬಿಲ್ ಆಯ್ಕೆಮಾಡಿ",
80
+ "options": [
81
+ {"title": "ಫಾಸ್ಟ್‌ಟ್ಯಾಗ್ ರೀಚಾರ್ಜ್", "postbackText": "FAST"}
82
+ ]
83
+ }
84
+ },
85
+ "settings": {
86
+ "title": "ಖಾತೆ ಸೆಟ್ಟಿಂಗ್‌ಗಳು",
87
+ "body": "ದಯವಿಟ್ಟು ಒಂದು ಆಯ್ಕೆಯನ್ನು ಆರಿಸಿ",
88
+ "security": {
89
+ "title": "ಭದ್ರತಾ ಸೆಟ್ಟಿಂಗ್‌ಗಳು",
90
+ "subtitle": "ನಿಮ್ಮ ಖಾತೆ ಭದ್ರತೆಯನ್ನು ನಿರ್ವಹಿಸಿ",
91
+ "options": [
92
+ {"title": "ಸೇವೆಯನ್ನು ಫ್ರೀಜ್ ಮಾಡಿ", "postbackText": "FREEZE"},
93
+ {"title": "ಪಿನ್ ರೀಸೆಟ್ ಮಾಡಿ", "postbackText": "RESETPIN"}
94
+ ]
95
+ }
96
+ },
97
+ "language_menu": {
98
+ "title": "ದಯವಿಟ್ಟು ಭಾಷೆಯನ್ನು ಬದಲಾಯಿಸಿ",
99
+ "body": "ದಯವಿಟ್ಟು ಆಯ್ಕೆಗಳನ್ನು ಆರಿಸಿ",
100
+ "languages": {
101
+ "title": "ಭಾಷೆಗಳು",
102
+ "subtitle": "ದಯವಿಟ್ಟು ಸೇವೆಯನ್ನು ಆರಿಸಿ",
103
+ "options": [
104
+ {"title": "ENGLISH", "postbackText": "xcd123"},
105
+ {"title": "ಕನ್ನಡ", "postbackText": "dtsi"},
106
+ {"title": "हिन्दी", "postbackText": "tracking123"}
107
+ ]
108
+ }
109
+ }
110
+ }
marathi.txt ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "payment_success": "भरणा यशस्वी! Rs 3000 वजा केले आहेत. नवीन शिल्लक: Rs {new_balance:.2f}",
2
+ "insufficient_balance": "या व्यवहारासाठी अपुरी शिल्लक.",
3
+ "invalid_otp": "अवैध OTP. कृपया पुन्हा प्रयत्न करा.",
4
+ "language_changed": {
5
+ "HINDI": "भाषा बदलकर हिंदी हो गई",
6
+ "ENGLISH": "Language changed to English",
7
+ "KANNADA": "ಭಾಷೆಯನ್ನು ಕನ್ನಡಕ್ಕೆ ಬದಲಾಯಿಸಲಾಗಿದೆ",
8
+ "MARATHI": "भाषा मराठी मध्ये बदलली"
9
+ },
10
+ "language_update_error": "भाषा अपडेट करण्यात अयशस्वी. कृपया पुन्हा प्रयत्न करा."
11
+ },
12
+ "bill_payment": {
13
+ "title": "बिल भरणा सेवा",
14
+ "body": "कृपया भरण्यासाठी बिल निवडा",
15
+ "utility_bills": {
16
+ "title": "उपयोगिता बिले",
17
+ "subtitle": "भरण्यासाठी उपयोगिता बिल निवडा",
18
+ "options": [
19
+ {"title": "वीज बिल", "postbackText": "ELEC"},
20
+ {"title": "पाणी बिल", "postbackText": "WATER"}
21
+ ]
22
+ },
23
+ "vehicle_bills": {
24
+ "title": "वाहन बिले",
25
+ "subtitle": "वाहन संबंधित बिल निवडा",
26
+ "options": [
27
+ {"title": "फास्टॅग रिचार्ज", "postbackText": "FAST"}
28
+ ]
29
+ }
30
+ },
31
+ "settings": {
32
+ "title": "खाते सेटिंग्ज",
33
+ "body": "कृपया एक पर्याय निवडा",
34
+ "security": {
35
+ "title": "सुरक्षा सेटिंग्ज",
36
+ "subtitle": "आपले खाते सुरक्षा व्यवस्थापित करा",
37
+ "options": [
38
+ {"title": "सेवा फ्रीज करा", "postbackText": "FREEZE"},
39
+ {"title": "पिन रीसेट करा", "postbackText": "RESETPIN"},
40
+ {"title": "FD साठी अर्ज करा", "postbackText": "FD"}
41
+ ]
42
+ }
43
+ },
44
+ "language_menu": {
45
+ "title": "कृपया भाषा बदला",
46
+ "body": "कृपया पर्याय निवडा",
47
+ "languages": {
48
+ "title": "भाषा",
49
+ "subtitle": "कृपया सेवा निवडा",
50
+ "options": [
51
+ {"title": "ENGLISH", "postbackText": "xcd123"},
52
+ {"title": "ಕನ್ನಡ", "postbackText": "dtsi"},
53
+ {"title": "हिन्दी", "postbackText": "tracking123"},
54
+ {"title": "मराठी", "postbackText": "vlsi"}
55
+ ]
56
+ }
57
+ }
58
+ }
pass.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 4356
requirements.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ anyio==4.6.2.post1
2
+ beautifulsoup4==4.12.3
3
+ certifi==2024.8.30
4
+ cffi==1.17.1
5
+ charset-normalizer==3.4.0
6
+ cryptography==43.0.3
7
+ et_xmlfile==2.0.0
8
+ h11==0.14.0
9
+ httpcore==1.0.6
10
+ httpx==0.27.2
11
+ idna==3.10
12
+ openpyxl==3.1.5
13
+ packaging==24.1
14
+ pandas==2.2.3
15
+ plotly==5.24.1
16
+ pycparser==2.22
17
+ python-dateutil==2.9.0.post0
18
+ python-multipart==0.0.17
19
+ pytube==15.0.0
20
+ pytz==2024.2
21
+ requests==2.32.3
22
+ six==1.16.0
23
+ sniffio==1.3.1
24
+ soupsieve==2.6
25
+ tenacity==9.0.0
26
+ tzdata==2024.2
27
+ urllib3==2.2.3