-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBot.py
2302 lines (2139 loc) · 120 KB
/
Bot.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from telegram.ext import (Updater, InlineQueryHandler, CommandHandler, CallbackContext, MessageHandler, Filters)
import telegram
import requests
import re
import json
from datetime import date,datetime,timedelta
import logging
from functools import wraps
import numbers
import geocoder
import pyshorteners
from russia import region
from spain import regionES
from indianDistricts import districtIN
import pandas as pd
from franceRegion import regionFRA
from italy import regionIT
from usaStateCode import usaStateCode
from mexico import stateMX
from malaysiaState import state_malaysia
#from pyshorteners import Shorteners
import random
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import wget
import os
import xlrd
from matplotlib.ticker import (AutoMinorLocator, MultipleLocator)
import flag
import matplotlib.dates as mdates
import matplotlib.ticker as ticker
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
#today = date.today()
regex = re.compile('[@_!#$%^&*()<>?/\|}{~:]')
def dateToday():
today = date.today()
return today
def apiRequestsIndia():
r = requests.get('https://api.covid19india.org/data.json')
j = r.json()
r = requests.get('https://api.covid19india.org/v2/state_district_wise.json')
dist_data = r.json()
return j,dist_data
def apiZoneIndia():
r= requests.get('https://api.covid19india.org/zones.json')
zone = r.json()
return zone
def apiTestedIndia():
tr= requests.get('https://api.covid19india.org/state_test_data.json')
test_data = tr.json()
return test_data
def apiWorld():
rCountry1 = requests.get('https://disease.sh/v2/countries')
jCountry1 = rCountry1.json()
return jCountry1
def apiCountriesyday():
yCountry = requests.get('https://disease.sh/v2/countries?yesterday=1')
ydayC = yCountry.json()
return ydayC
def apiRequestUSA():
rUS = requests.get('https://covidtracking.com/api/states/info')
jstates = rUS.json()
rUS_states = requests.get('https://covidtracking.com/api/states')
states_us = rUS_states.json()
us_county = requests.get('https://disease.sh/v2/jhucsse/counties')
county_us = us_county.json()
return jstates,states_us,county_us
def apiUSAStates(stateName):
usaState = requests.get("https://disease.sh/v2/states/"+stateName)
states_us_new = usaState.json()
return states_us_new
def apiUSAStatesYday(stateName):
usaState_y = requests.get("https://disease.sh/v2/states/"+stateName+"?yesterday=true")
states_us_new_yday = usaState_y.json()
return states_us_new_yday
def apiRequestGermany():
germany = requests.get("https://rki-covid-api.now.sh/api/states")
statejson = germany.json()
return statejson
def apiWorldNew():
world = requests.get("https://disease.sh/v2/all").json()
return world
def apiWorldNewYday():
worldYday = requests.get("https://disease.sh/v2/all?yesterday=1").json()
return worldYday
def apiRequestJapan():
japan = requests.get("https://data.covid19japan.com/summary/latest.json")
japanProvince = japan.json()
return japanProvince
def apiRequestUK():
uk = requests.get("https://c19downloads.azureedge.net/downloads/json/coronavirus-cases_latest.json")
uk_ltla = uk.json()
return uk_ltla
def apiRequestNL():
nl = requests.get("https://opendata.arcgis.com/datasets/620c2ab925f64ed5979d251ba7753b7f_0.geojson")
nl_city = nl.json()
return nl_city
def apiRequestRU(code):
ru = requests.get("https://xn--80aesfpebagmfblc0a.xn--p1ai/covid_data.json?do=region_stats&code="+code)
ru_state = ru.json()
return ru_state
def apiRequestAUS():
aus = requests.get("https://interactive.guim.co.uk/docsdata/1q5gdePANXci8enuiS4oHUJxcxC13d6bjMRSicakychE.json")
aus_state = aus.json()
return aus_state
def apiRequestCAN():
can = requests.get("https://opendata.arcgis.com/datasets/3afa9ce11b8842cb889714611e6f3076_0.geojson")
can_province = can.json()
return can_province
def apiRequestBrazil():
bra = requests.get("https://covid19-brazil-api.now.sh/api/report/v1")
bra_states = bra.json()
return bra_states
def apiRequestES(dateToday):
spain = requests.get("https://api.covid19tracking.narrativa.com/api/"+dateToday+"/country/spain/region/all")
es_province = spain.json()
return es_province
def apiRequestFR(code):
fr = requests.get("https://coronavirusapi-france.now.sh/LiveDataByDepartement?Departement="+code)
fr_state = fr.json()
return fr_state
def apiRequestItaly():
ita = requests.get("https://disease.sh/v2/gov/Italy")
ita_states = ita.json()
return ita_states
def apiRequestMexStates():
mex = requests.get("https://api.apify.com/v2/key-value-stores/vpfkeiYLXPIDIea2T/records/LATEST?disableRedirect=true")
mex_states = mex.json()
return mex_states
def apiTravelAlert():
travel = requests.get("http://api.coronatracker.com/v1/travel-alert")
travel_country = travel.json()
return travel_country
APIKey_LQ = ""
API_key_M = ""
NewsAPIKey = ""
WORLD_MAP="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/COVID-19_Outbreak_World_Map_per_Capita.svg/1200px-COVID-19_Outbreak_World_Map_per_Capita.svg.png"
def _add_timestamp(url):
timestamp = datetime.utcnow().strftime("%Y%m%d%H")
return "{}?t={}".format(url, timestamp)
def cases_world_map():
return _add_timestamp(WORLD_MAP)
def get_count_world():
jsonContent = apiWorldNew()
TotalConfirmed = str(jsonContent["cases"])
NewConfirmed = str(jsonContent["todayCases"])
NewDeaths = str(jsonContent["todayDeaths"])
TotalDeaths = str(jsonContent["deaths"])
TotalRecovered = str(jsonContent["recovered"])
active = str(jsonContent["active"])
casesPerOneMillion = str(jsonContent["casesPerOneMillion"])
deathsPerOneMillion = str(jsonContent["deathsPerOneMillion"])
tests = str(jsonContent["tests"])
testsPerOneMillion = str(jsonContent["testsPerOneMillion"])
activePerOneMillion = str(jsonContent["activePerOneMillion"])
recoveredPerOneMillion = str(jsonContent["recoveredPerOneMillion"])
affectedCountries = str(jsonContent["affectedCountries"])
todayRecovered = str(jsonContent["todayRecovered"])
jsonContentYday = apiWorldNewYday()
TotalConfirmedYday = str(jsonContentYday["cases"])
NewConfirmedYday = str(jsonContentYday["todayCases"])
return TotalConfirmed,NewConfirmed,NewDeaths,TotalDeaths,TotalRecovered,affectedCountries,active,casesPerOneMillion,deathsPerOneMillion,tests,testsPerOneMillion,activePerOneMillion,recoveredPerOneMillion,todayRecovered,TotalConfirmedYday,NewConfirmedYday
def world(update, context):
response= requests.get('https://disease.sh/v2/all')
status= response.status_code
if status != 200:
context.bot.send_message(chat_id=update.effective_chat.id, text="*API down, Try later*",parse_mode=telegram.ParseMode.MARKDOWN)
else :
content = get_count_world()
print (content)
if content[0] == "0":
context.bot.send_message(chat_id=update.message.chat_id, text="The API is giving incorrect data")
else:
updatedTime = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
chat_id = update.message.chat_id
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=chat_id, text="Below are the stats for World, \
\n\
\nActive cases : *"+content[6]+"*\
\nConfirmed cases : *"+content[0]+"* *(↑"+content[1]+")*\
\nDeath cases : *"+content[3]+"* *(↑"+content[2]+")*\
\nRecovered cases : *"+content[4]+"* *(↑"+content[13]+")*\
\nCases Yesterday : *"+content[14]+"* *(↑"+content[15]+")*\
\nAffected countries : *"+content[5]+"*\
\nCases per million : *"+content[7]+"*\
\nDeaths per million : *"+content[8]+"*\
\nTotal Tests : *"+content[9]+"*\
\nTests per million : *"+content[10]+"*\
\nActive per million : *"+content[11]+"*\
\nRecovered per million : *"+content[12]+"*\
\nThis data was last updated at *"+str(updatedTime)+"*",parse_mode=telegram.ParseMode.MARKDOWN)
context.bot.send_photo(chat_id=update.message.chat_id, photo=cases_world_map(),parse_mode=telegram.ParseMode.MARKDOWN)
print("This User checked world :"+update.message.from_user.first_name)
logger.info("World handler used ", update.message.chat.id, update.message.from_user.first_name)
captureID(update)
def zones(update, context, districtIndia):
jsonContent = apiZoneIndia()
for each in jsonContent["zones"]:
if str(each["district"]) == districtIndia:
zone = str(each["zone"])
if zone == "Green":
zone = "GREEN ✅"
if zone == "Red":
zone = "RED 🔴"
if zone == "Orange":
zone = "ORANGE 🔶"
return zone
def testRate(stateName):
jsonContent = apiTestedIndia()
today = datetime.today()
tday = today.strftime('%d.%m.%Y')
yesterday = today - timedelta(days = 1)
yday = yesterday.strftime('%d/%m/%Y')
dayBeforeYday = today - timedelta(days = 2)
DYday = dayBeforeYday.strftime('%d/%m/%Y')
for each in jsonContent["states_tested_data"]:
if stateName == "Andaman and Nicobar Islands":
testpositivityrate= "0.45%"
totaltested = "7263"
lastUpdated = "22/05/2020"
if stateName == "Telangana":
testpositivityrate= "6.63%"
totaltested = "23388"
lastUpdated = "16/05/2020"
elif str(each["state"]) == stateName:
if str(each["updatedon"])==str(yday):
testpositivityrate = str(each["testpositivityrate"])
totaltested = int(each["totaltested"])
if testpositivityrate == "":
totaltested = int(each["totaltested"])
print(totaltested)
positive = int(each["positive"])
testpositivityrate = str(round((positive/totaltested)*100,2))+"%"
lastUpdated = str(each["updatedon"])
elif (str(each["updatedon"])==str(DYday)):
testpositivityrate = str(each["testpositivityrate"])
totaltested = int(each["totaltested"])
if testpositivityrate == "":
totaltested = int(each["totaltested"])
print(totaltested)
positive = int(each["positive"])
testpositivityrate = str(round((positive/totaltested)*100,2))+"%"
lastUpdated = str(each["updatedon"])
return testpositivityrate,str(totaltested),lastUpdated
def testRateIndia(cases):
print(cases)
jsonContent = apiRequestsIndia()
today = datetime.today()
tday = today.strftime('%d/%m/%Y')
yesterday = today - timedelta(days = 1)
yday = yesterday.strftime('%d/%m/%Y')
for each in jsonContent[0]["tested"]:
d = str(each["updatetimestamp"]).split(" ")
#print(d[0])
#print(str(tday))
#print(str(yday))
if(d[0]==str(tday)):
print(d[0])
testpositivityrate = str(each["testpositivityrate"])
totalsamplestested = int(each["totalsamplestested"])
if testpositivityrate == "":
totalsamplestested = int(each["totalsamplestested"])
positive = int(cases)
testpositivityrate = str(round((positive/totalsamplestested)*100,2))+"%"
elif(d[0]==str(yday)):
print(d[0])
testpositivityrate = str(each["testpositivityrate"])
totalsamplestested = int(each["totalsamplestested"])
if testpositivityrate == "":
totalsamplestested = int(each["totalsamplestested"])
positive = int(cases)
testpositivityrate = str(round((positive/totalsamplestested)*100,2))+"%"
return testpositivityrate,str(totalsamplestested)
def new_count_India():
jsonContent = apiRequestsIndia()
for each in jsonContent[0]["statewise"]:
if str(each["state"]) == "Total":
confirmed = str(each["confirmed"])
deaths = str(each["deaths"])
recovered = str(each["recovered"])
deltaconfirmed = str(each["deltaconfirmed"])
deltarecovered = str(each["deltarecovered"])
deltadeaths = str(each["deltadeaths"])
lastupdatedtime = str(each["lastupdatedtime"])
active = str(each["active"])
recoveryRate = str(round((int(each["recovered"])/(int(each["confirmed"]) - int(each["deaths"])))*100,2))+"%"
for each in jsonContent[0]["cases_time_series"]:
today = datetime.today()
yesterday = today - timedelta(days = 1)
yday = yesterday.strftime('%d %B')
#print(yday)
if str(each["date"]).strip() == str(yday):
totalconfirmedyday = str(each["totalconfirmed"])
dailyconfirmedyday = str(each["dailyconfirmed"])
totaldeathyday = str(each["totaldeceased"])
return confirmed,deaths,recovered,deltaconfirmed,lastupdatedtime,deltarecovered,deltadeaths,active,totalconfirmedyday,dailyconfirmedyday,totaldeathyday,recoveryRate
def india(update, context):
content = new_count_India()
tr = testRateIndia(content[0])
FlagIcon = flag.flag("IN")
chat_id = update.message.chat_id
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=chat_id, text="Below are the stats for *India* "+FlagIcon+":\
\n\
\nActive cases : *"+content[7]+"*\
\nConfirmed cases : *"+content[0]+"* *(↑"+content[3]+")*\
\nDeath cases : *"+content[1]+"* *(↑"+content[6]+")*\
\nRecovered cases : *"+content[2]+"* *(↑"+content[5]+")*\
\nRecovery Rate : *"+content[11]+"*\
\nCases Yesterday : *"+content[8]+"* *(↑"+content[9]+")*\
\nTest Positivity Rate : *"+tr[0]+"*\
\nTotal samples tested : *"+tr[1]+"*\
\nThis data was last updated at : *"+content[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,"IN",content[8],content[10],"India")
print("This User checked India: "+update.message.from_user.first_name)
logger.info("India handler used ", update.message.chat.id, update.message.from_user.first_name)
captureID(update)
return content[8],content[10]
def state_new_count_India(var):
jsonContent = apiRequestsIndia()
for each in jsonContent[0]["statewise"]:
if str(each["statecode"]) == var:
confirmed = str(each["confirmed"])
deaths = str(each["deaths"])
recovered = str(each["recovered"])
deltaconfirmed = str(each["deltaconfirmed"])
lastupdatedtime = str(each["lastupdatedtime"])
stateName = str(each["state"])
active = str(each["active"])
deltarecovered = str(each["deltarecovered"])
deltadeaths = str(each["deltadeaths"])
recoveryRate = str(round((int(each["recovered"])/(int(each["confirmed"]) - int(each["deaths"])))*100,2))+"%"
return confirmed,deaths,recovered,deltaconfirmed,lastupdatedtime,stateName,deltarecovered,deltadeaths,active,recoveryRate
def indianstate(update, context):
state_code = ' '.join(context.args).upper()
print(state_code)
if (state_code.isdigit()):
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a statecode, Ex: '/state KA'",parse_mode=telegram.ParseMode.MARKDOWN)
elif state_code == "":
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a statecode, Ex: '/state KA'",parse_mode=telegram.ParseMode.MARKDOWN)
elif(regex.search(state_code)) == None:
content_k = state_new_count_India(state_code)
testR = testRate(content_k[5])
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="Below are the stats for *"+content_k[5]+"* \
\n\
\nActive cases : *"+content_k[8]+"*\
\nConfirmed cases : *"+content_k[0]+"* *(↑"+content_k[3]+")*\
\nDeath cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered cases : *"+content_k[2]+"* *(↑"+content_k[6]+")*\
\nRecovery Rate : *"+content_k[9]+"*\
\nTest Positivity Rate : *"+testR[0]+"*\
\nTotal samples tested : *"+testR[1]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
else:
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a statecode correctly , Ex: '/state KA",parse_mode=telegram.ParseMode.MARKDOWN)
logger.info("State handler used ", update.message.chat.id, update.message.from_user.first_name)
print("This User checked "+ content_k[5] +":"+update.message.from_user.first_name)
def indian_state_code(update, context):
jsonContent = apiRequestsIndia()
state = []
code = []
for each in jsonContent[0]['statewise']:
state.append(each["state"])
code.append(each["statecode"])
StateName_StateCode = ' \n'.join(["For "+ str(a) +" use code "+ b for a,b in zip(state,code)])
chat_id = update.message.chat_id
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=chat_id, text="*"+StateName_StateCode+"*",parse_mode=telegram.ParseMode.MARKDOWN)
logger.info("State code handler used ", update.message.chat.id, update.message.from_user.first_name)
def country_code(update, context):
var = ' '.join(context.args)
print(var)
if var == "":
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a Letter to list the countries , Ex: '/countrycode N'",parse_mode=telegram.ParseMode.MARKDOWN)
elif (var.isdigit()):
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a Letter to list the countries , Ex: '/countrycode N'",parse_mode=telegram.ParseMode.MARKDOWN)
elif(regex.search(var)) == None:
letter = var.capitalize()
print(letter)
jsonContent = apiWorld()
country = []
country_code = []
for each in jsonContent:
countryName = str(each["country"])
if countryName.startswith(letter):
if str(each["country"])!="MS Zaandam":
country.append(each["country"])
print(each["country"])
if str(each["countryInfo"]["iso2"])!="None":
country_code.append(each["countryInfo"]["iso2"])
countryName_countryCode = ' \n'.join([str(a) +" use code : "+ b for a,b in zip(country,country_code)])
chat_id = update.message.chat_id
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=chat_id, text="List of Countries starting with letter *"+letter+"* :\n*"+countryName_countryCode+"*",parse_mode=telegram.ParseMode.MARKDOWN)
else:
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a Letter to list the countries , Ex: '/countrycode N",parse_mode=telegram.ParseMode.MARKDOWN)
logger.info("Country code handler used ", update.message.chat.id, update.message.from_user.first_name)
def countryWiseStatsCollect(var):
print(str(var).upper())
jsonContent = apiWorld()
jsonC = apiCountriesyday()
for each in jsonContent:
if str(each["countryInfo"]["iso2"]) == str(var).upper():
confirmed = str(each["cases"])
deaths = str(each["deaths"])
recovered = str(each["recovered"])
populationHere = str(each["population"]).strip()
lastupdatedtime = str(datetime.fromtimestamp((each["updated"])/1000).replace(microsecond=0))
countryName = str(each["country"])
new_case = str(each["todayCases"])
new_deaths = str(each["todayDeaths"])
new_recovered = str(each["todayRecovered"])
casesPerOneMillion = str(each["casesPerOneMillion"])
deathsPerOneMillion = str(each["deathsPerOneMillion"])
activePerOneMillion = str(each["activePerOneMillion"])
recoveredPerOneMillion = str(each["recoveredPerOneMillion"])
testsPerOneMillion = str(each["testsPerOneMillion"])
active = str((each["cases"])-(each["deaths"])-(each["recovered"]))
if int(each["tests"]) == 0:
testPositivityRate = "Not Known"
else:
testPositivityRate = str(round(((int(each["cases"]))/(int(each["tests"])))*100,2))+"%"
if int(each["recovered"]) == 0:
recoveryRate = "Not Known"
else:
recoveryRate = str(round((int(each["recovered"])/(int(each["cases"]) - int(each["deaths"])))*100,2))+"%"
for each in jsonC:
if str(each["countryInfo"]["iso2"]) == str(var).upper():
confirmed_yday = str(each["cases"])
new_case_yday = str(each["todayCases"])
deaths_yday = str(each["deaths"])
return confirmed,deaths,recovered,populationHere,lastupdatedtime,countryName,new_case,new_deaths,casesPerOneMillion,deathsPerOneMillion,activePerOneMillion,recoveredPerOneMillion,testsPerOneMillion,confirmed_yday,new_case_yday,deaths_yday,active,testPositivityRate,recoveryRate,new_recovered
def countryWiseData(update, context):
country_code = ' '.join(context.args)
letter = country_code.capitalize()
print(country_code)
if (country_code.isdigit()):
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a country code, Ex:'/country NL'",parse_mode=telegram.ParseMode.MARKDOWN)
elif country_code == "":
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a country code, Ex:'/country NL'",parse_mode=telegram.ParseMode.MARKDOWN)
else:
content_k = countryWiseStatsCollect(letter)
FlagIcon = flag.flag(letter)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The stats for country *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nCurrent Population : *"+content_k[3]+"*\
\nCases per million : *"+content_k[8]+"*\
\nDeath per million : *"+content_k[9]+"*\
\nActive per million : *"+content_k[10]+"*\
\nRecovered per million : *"+content_k[11]+"*\
\nTests per million : *"+content_k[12]+"*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
#context.bot.send_photo(chat_id=update.message.chat_id, photo=photo_file,parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,letter,content_k[13],content_k[1],content_k[5])
print("This User checked "+ content_k[5] +":"+update.message.from_user.first_name)
logger.info("Country handler used ", update.message.chat.id, update.message.from_user.first_name)
captureID(update)
def topC(update, context):
var = ' '.join(context.args)
#res = isinstance(var, str)
country = []
country_code = []
deaths = []
confirmed =[]
countryN = []
confirmedcountry = []
confirmedN = []
if var == "":
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a number after the handler to get the results, Ex: '/topC 10",parse_mode=telegram.ParseMode.MARKDOWN)
elif ((var>='a' and var<= 'z') or (var>='A' and var<='Z')):
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a number after the handler to get results, Ex: '/topC 10",parse_mode=telegram.ParseMode.MARKDOWN)
elif ((var >= '50')):
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a number below 50 with the handler to get results, Ex: '/topD 10",parse_mode=telegram.ParseMode.MARKDOWN)
elif(regex.search(var)) == None:
jsonContent = apiWorld()
for each in jsonContent:
confirmed.append(each["cases"])
country.append(str(each["country"]))
country_code.append(str(each["countryInfo"]["iso2"]))
deaths.append(str(each["deaths"]))
#print(confirmed)
confirmed.sort(reverse = True)
top = confirmed[0:int(var)]
#print("This is sorted:",confirmed)
#print(top)
j=0
for i in top:
for each in jsonContent:
confirmedN = each["cases"]
if (i == confirmedN):
confirmedcountry.append(str(each["cases"]))
countryN.append("No:"+str(j+1)+">> "+str(each["country"]))
j += 1
countryName_confirmed = ' \n'.join(["*"+str(a)+"*"+" has *"+ b +"* confirmed cases" for a,b in zip(countryN,confirmedcountry)])
else:
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a number below 50 with the handler to get results, Ex: '/topD 10",parse_mode=telegram.ParseMode.MARKDOWN)
chat_id = update.message.chat_id
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=chat_id, text="The *Top "+var+"* countries with max confirmed cases of Covid-19 are : \
\n\
\n"+countryName_confirmed+"",parse_mode=telegram.ParseMode.MARKDOWN)
print("This User checked TopC: "+update.message.from_user.first_name)
logger.info("TopC handler used ", update.message.chat.id, update.message.from_user.first_name)
captureID(update)
def topD(update, context):
var = ' '.join(context.args)
#res = isinstance(var, str)
country = []
deaths = []
countryN = []
deathCountry = []
jsonContent = apiWorld()
if var == "":
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a number after the handler to get the results, Ex: '/topD 10",parse_mode=telegram.ParseMode.MARKDOWN)
elif ((var>='a' and var<= 'z') or (var>='A' and var<='Z')):
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a number after the handler to get results, Ex: '/topD 10",parse_mode=telegram.ParseMode.MARKDOWN)
elif ((var >= '50')):
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a number below 50 with the handler to get results, Ex: '/topD 10",parse_mode=telegram.ParseMode.MARKDOWN)
elif(regex.search(var)) == None:
for each in jsonContent:
country.append(str(each["country"]))
deaths.append(each["deaths"])
#print(confirmed)
deaths.sort(reverse = True)
top = deaths[0:int(var)]
#print("This is sorted:",confirmed)
#print(top)
j=0
for i in top:
for each in jsonContent:
deathN = each["deaths"]
if (i == deathN):
deathCountry.append(str(each["deaths"]))
countryN.append("No:"+str(j+1)+">> "+str(each["country"]))
j += 1
countryName_death = ' \n'.join(["*"+str(a)+"*"+" has *"+ b +"* deaths from Covid-19" for a,b in zip(countryN,deathCountry)])
else:
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text="Add a number below 50 with the handler to get results, Ex: '/topD 10",parse_mode=telegram.ParseMode.MARKDOWN)
chat_id = update.message.chat_id
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=chat_id, text="The *Top "+var+"* countries with max death cases from Covid-19 are : \
\n\
\n"+countryName_death+"",parse_mode=telegram.ParseMode.MARKDOWN)
print("This User checked TopD: "+update.message.from_user.first_name)
logger.info("TopD handler used ", update.message.chat.id, update.message.from_user.first_name)
captureID(update)
def commands(update,context):
logger.info("help handler used ", update.message.chat.id, update.message.from_user.first_name)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text= "\
\n<b><u>Commands:</u></b> \n \
\n<b>/india</b> - Fetch stats of India \n\
\n<b>/statecode</b> - Fetch statewise code \n\
\n<b>/state</b> statecode - Fetch stats per state,\
\nNow for karnataka use <b>'/state KA'</b> without the single quotes\n \
\n<b>/districtwise</b> - Fetch stats district wise of a particular state using the state code \n\
\n<b>/world</b> - Fetch stats for the entire world \n\
\n<b>/countrycode</b> - Fetch country codes ,\
\nTo show all country names with starting letter I and thier resp. code use <b>'/countrycode I'</b> without the single quotes\n \
\n<b>/country</b> countrycode - Fetch country wise stats,\
\nNow for showing stats of Netherlands use <b>'/country NL'</b> without the single quotes\n\
\n<b>/topC</b> number - Fetch top countries with highest confirmed covid-19 cases,\
\nNow to show Top 10 countries use <b>'/topC 10'</b> \n\
\n<b>/topD</b> number - Fetch top countries with highest death due to covid-19,\
\nNow to show Top 10 countries use <b>'/topD 10'</b> without the single quotes\
\n\
\n<b>/ListUSAStates</b> \
\nTo show all state names with starting letter N and thier respective code use <b>'/ListUSAStates N'</b> \n \
\n<b>/USAState</b> statecode - Fetch stats per state,\
\nNow for NewYork use <b>'/USAState NY'</b> without the single quotes \n \
\n<b>/asia</b> - Fetch stats of Asia \
\n<b>/africa</b> - Fetch stats of Africa \
\n<b>/europe</b> - Fetch stats of Europe \
\n<b>/australia</b> - Fetch stats of Australia \
\n<b>/northamerica</b> - Fetch stats of North America \
\n<b>/southamerica</b> - Fetch stats of South America \
\n<b>/official_TC</b> to see official Telegram channels of other countries \
\n<b>/news</b> - Fetch random top news from worldwide related to Covid-19 \
\n<b>/travelAdvice</b> - Fetch travel alerts set by each countries due to Covid-19, \
\nNow for Netherlands use <b>'/travelAdvice NL'</b> without the single quotes \
",parse_mode=telegram.ParseMode.HTML,disable_web_page_preview=True)
print(update.message.from_user.username)
captureID(update)
def help(update,context):
logger.info("help handler used ", update.message.chat.id, update.message.from_user.first_name)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text= "\
\n \
\nYou can now <b>Share any location</b> and get the stats of any country,\
\nBelow are few countries where you get more detailed stats \
\n\
\nIf you share any location which inside \
\n\
\n<b>1)India</b> get statewise and district-wise stats,\
\n<b>2)USA</b> get statewise and county wise stats,\
\n<b>3)Germany</b> get statewise stats,\
\n<b>4)Netherlands</b> get statewise and Gementee wise stats,\
\n<b>5)Japan</b> get statewise stats,\
\n<b>6)Russia</b> get statewise stats,\
\n<b>7)UK</b> get statewise stats,\
\n<b>8)Spain</b> get statewise stats,\
\n<b>9)Australia</b> get statewise stats,\
\n<b>10)Canada</b> get statewise stats,\
\n<b>11)Brazil</b> get statewise stats,\
\n<b>12)France</b> get Département stats,\
\n<b>13)Italy</b> get statewise stats,\
\n<b>14)Mexico</b> get statewise stats,\
\n<b>15)Malaysia</b> get statewise stats,\
\nAll other countries get just country wise stats,\n\
\n<b>Just point the pin on the map and share it</b> \n \
\n /commands for listing all the available commands",parse_mode=telegram.ParseMode.HTML,disable_web_page_preview=True)
print(update.message.from_user.username)
captureID(update)
def start(update,context):
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat.id, text="<b>Welcome to The Covid-19 Tracker Bot! 🦠</b> \
\n \
\n<b><u>You can use these Commands:</u></b> \n \
\n<b>/help</b> \
\n<b>/commands</b> \
\n<b>/official_TC</b> \
\n \
\nStay Home, Stay Safe! 🏡 <b>"+ update.message.from_user.first_name+"</b>\
\n\
\nAbout: Bot created by https://twitter.com/ravindraten",parse_mode=telegram.ParseMode.HTML,disable_web_page_preview=True)
print(update.message.from_user.username)
print(update.message.from_user.first_name)
print(update.message.chat.id)
captureID(update)
logger.info("Start handler used ", update.message.chat.id, update.message.from_user.first_name)
def captureID(update):
f= open("userID.txt","w+")
f= open("guru99.txt", "a+")
f.write("\nUser is %d\r" % (update.message.chat.id)+": "+(update.message.from_user.first_name)+": "+str(dateToday()))
def officialTelegramChannels(update,context):
logger.info("officialTelegramChannels handler used ", update.message.chat.id, update.message.from_user.first_name)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.message.chat_id, text= """\
If you're looking for official news about the Novel Coronavirus and COVID-19, here are some examples of verified Telegram channels from health ministries around the world.\
🇨🇺 <a href="https://t.me/MINSAPCuba">Cuba</a>
🇬🇪 <a href="https://t.me/StopCoVge">Georgia</a>
🇩🇪 <a href="https://t.me/Corona_Infokanal_BMG">Germany</a>
🇭🇰 <a href="http://t.me/HKFIGHTCOVID19">Hong Kong</a>
🇮🇳 <a href="https://t.me/MyGovCoronaNewsdesk">India</a>
🇮🇹 <a href="https://t.me/MinisteroSalute">Italy</a>
🇮🇱 <a href="https://t.me/MOHreport">Israel</a>
🇰🇿 <a href="https://t.me/coronavirus2020_kz">Kazakhstan</a>
🇰🇬 <a href="https://t.me/RshKRCOV">Kyrgyzstan</a>
🇲🇾 <a href="https://t.me/cprckkm">Malaysia</a>
🇳🇬 <a href="http://t.me/ncdcgov">Nigeria</a>
🇷🇺 <a href="https://t.me/stopcoronavirusrussia">Russia</a>
🇸🇦 <a href="https://t.me/LiveWellMOH">Saudi Arabia</a>
🇸🇬 <a href="https://t.me/govsg">Singapore</a>
🇪🇸 <a href="https://t.me/sanidadgob">Spain</a>
🇹🇬 <a href="http://t.me/GouvTG">Togo</a>
🇺🇦 <a href="https://t.me/COVID19_Ukraine">Ukraine</a>
🇺🇿 <a href="https://t.me/koronavirusinfouz">Uzbekistan</a>
""",parse_mode=telegram.ParseMode.HTML,disable_web_page_preview=True)
print(update.message.from_user.username)
logger.info("officialTelegramChannels handler used ", update.message.chat.id, update.message.from_user.first_name)
captureID(update)
def getLocation(update,context):
message = None
if update.edited_message:
message = update.edited_message
else:
message = update.message
current_lat = str(message.location.latitude)
current_lon = str(message.location.longitude)
print(current_lat)
print(current_lon)
jsonContent = apiRequestsIndia()
contents = requests.get("https://locationiq.com/v1/reverse.php?key="+APIKey_LQ+"&lat="+current_lat+"&lon="+current_lon+"&format=json").json()
countryName = contents["address"]["country"]
country = contents["address"]["country_code"]
FlagIcon = flag.flag(country)
#print(contents)
if country == "in":
contentIN = india(update,context)
#countryTrend(update,context,country,contentIN[0],contentIN[1],countryName)
try:
state = contents["address"]["state"]
print(state)
testR = testRate(state)
except:
state_district = contents["address"]["state_district"]
if state_district == "North Goa":
state = "Goa"
if state_district == "South Goa":
state = "Goa"
for each in jsonContent[0]["statewise"]:
if str(each["state"]) == state:
confirmed = str(each["confirmed"])
deaths = str(each["deaths"])
recovered = str(each["recovered"])
deltaconfirmed = str(each["deltaconfirmed"])
deltarecovered = str(each["deltarecovered"])
deltadeaths = str(each["deltadeaths"])
lastupdatedtime = str(each["lastupdatedtime"])
active = str(each["active"])
recoveryRate = str(round((int(each["recovered"])/(int(each["confirmed"]) - int(each["deaths"])))*100,2))+"%"
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+state+"* \
\n\
\nActive cases : *"+active+"*\
\nConfirmed cases : *"+confirmed+"* *(↑"+deltaconfirmed+")*\
\nDeath cases : *"+deaths+"* *(↑"+deltadeaths+")*\
\nRecovered cases : *"+recovered+"* *(↑"+deltarecovered+")*\
\nRecovery Rate : *"+recoveryRate+"*\
\nTest Positivity Rate : *"+testR[0]+"*\
\nTest samples tested : *"+testR[1]+"*\
\nThis data was last updated at : *"+lastupdatedtime+"*",parse_mode=telegram.ParseMode.MARKDOWN)
getLocation1(update,context,current_lat,current_lon,lastupdatedtime)
#links(context,update,current_lat,current_lon)
elif country == "us":
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="You are currently located in or the Map location shared is in *"+content_k[5]+"* "+FlagIcon+" \
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nCurrent Population : *"+content_k[3]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,country,content_k[13],content_k[15],countryName)
state = contents["address"]["state"]
print(state)
jsonContentUS = apiUSAStates(state)
jsonContentUS_yday = apiUSAStatesYday(state)
#for each in jsonContentUS:
active = str(jsonContentUS["active"])
cases = str(jsonContentUS["cases"])
todayCases = str(jsonContentUS["todayCases"])
deaths = str(jsonContentUS["deaths"])
todayDeaths = str(jsonContentUS["todayDeaths"])
recovered = ((int(cases)) - (int(active)))
CasesYday = str(jsonContentUS_yday["cases"])
NewCasesYday = str(jsonContentUS_yday["todayCases"])
updated = str(datetime.fromtimestamp((jsonContentUS["updated"])/1000).replace(microsecond=0))
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+state+"*\
\n\
\nConfirmed Cases : *"+cases+"**(↑"+todayCases+")*\
\nDeath Cases : *"+deaths+"**(↑"+todayDeaths+")*\
\nActive Cases : *"+active+"*\
\nRecovered Cases : *"+str(recovered)+"*\
\nCases yesterday : *"+CasesYday+"**(↑"+NewCasesYday+")*\
\nThis data was last updated at : *"+updated+"*",parse_mode=telegram.ParseMode.MARKDOWN)
getLocation2(update,context,current_lat,current_lon)
#links(context,update,current_lat,current_lon)
captureID(update)
elif country == "de":
#state = contents["address"]["state"]
#print(state)
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nCurrent Population : *"+content_k[3]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,country,content_k[13],content_k[15],countryName)
getLocation3(update,context,current_lat,current_lon)
#links(context,update,current_lat,current_lon)
captureID(update)
elif country == "jp":
state_jp = contents["address"]["state"]
prefecture = str((state_jp.replace("Prefecture","")).strip())
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nCurrent Population : *"+content_k[3]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,country,content_k[13],content_k[15],countryName)
getLocationJP(update,context,prefecture)
#links(context,update,current_lat,current_lon)
captureID(update)
elif country == "gb":
regionUK = contents["address"]["state_district"]
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nCurrent Population : *"+content_k[3]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,country,content_k[13],content_k[15],countryName)
getLocationUK(update,context,regionUK)
#links(context,update,current_lat,current_lon)
captureID(update)
elif country == "nl":
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nCurrent Population : *"+content_k[3]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
#links(context,update,current_lat,current_lon)
countryTrend(update,context,country,content_k[13],content_k[15],countryName)
try:
cityNL = contents["address"]["city"]
except:
cityNL = contents["address"]["town"]
getLocationNL(update,context,cityNL)
print("This User checked "+ content_k[5] +":"+update.message.from_user.first_name)
captureID(update)
elif country == "ru":
stateRU = contents["address"]["state"]
print(stateRU)
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nCurrent Population : *"+content_k[3]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,country,content_k[13],content_k[15],countryName)
print(stateRU)
getLocationRU(update,context,stateRU)
print("This User checked this"+ content_k[5] +":"+update.message.from_user.first_name)
captureID(update)
elif country == "au":
stateAUS = str((contents["address"]["state"]).strip())
print(stateAUS)
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nCurrent Population : *"+content_k[3]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,country,content_k[13],content_k[15],countryName)
getLocationAUS(update,context,stateAUS)
print("This User checked this"+ content_k[5] +":"+update.message.from_user.first_name)
captureID(update)
elif country == "ca":
provinceCA = str(contents["address"]["state"]).upper()
print(provinceCA)
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\
\nConfirmed Cases : *"+content_k[0]+"* *(↑"+content_k[6]+")*\
\nDeath Cases : *"+content_k[1]+"* *(↑"+content_k[7]+")*\
\nRecovered Cases : *"+content_k[2]+"* *(↑"+content_k[19]+")*\
\nRecovery Rate : *"+content_k[18]+"*\
\nCases Yesterday : *"+content_k[13]+"* *(↑"+content_k[14]+")*\
\nTest Positivity Rate : *"+content_k[17]+"*\
\nCurrent Population : *"+content_k[3]+"*\
\nThis data was last updated at : *"+content_k[4]+"*",parse_mode=telegram.ParseMode.MARKDOWN)
countryTrend(update,context,country,content_k[13],content_k[15],countryName)
#links(context,update,current_lat,current_lon)
getLocationCA(update,context,provinceCA)
print("This User checked Now"+ content_k[5] +":"+update.message.from_user.first_name)
captureID(update)
elif country == "es":
provinceCA = str(contents["address"]["state"])
print(provinceCA)
content_k = countryWiseStatsCollect(country)
context.bot.sendChatAction(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
context.bot.send_message(chat_id=update.effective_chat.id, text="The location you shared is in *"+content_k[5]+"* "+FlagIcon+"\
\n\
\nActive Cases : *"+content_k[16]+"*\