randydev commited on
Commit
12160f5
·
verified ·
1 Parent(s): 2f36524
Files changed (1) hide show
  1. database.py +4 -634
database.py CHANGED
@@ -24,34 +24,16 @@ class Database:
24
  self.client: AgnosticClient = motor_asyncio.AsyncIOMotorClient(uri)
25
  self.db = self.client["Akeno"]
26
 
27
- self.afk = self.db["afk"]
28
- self.antiflood = self.db["antiflood"]
29
- self.autopost = self.db["autopost"]
30
- self.blacklist = self.db["blacklist"]
31
- self.echo = self.db["echo"]
32
- self.env = self.db["env"]
33
- self.filter = self.db["filter"]
34
- self.forcesub = self.db["forcesub"]
35
- self.gachabots = self.db["gachabots"]
36
- self.cohere = self.db["cohere"]
37
- self.chatbot = self.db["chatbot"]
38
- self.gemini_plan = self.db["gemini_plan"]
39
  self.backup_chatbot = self.db["google_genai"]
40
- self.antiarabic = self.db["antiarabic"]
41
- self.antinsfw = self.db["antinsfw"]
42
- self.gban = self.db["gban"]
43
- self.gmute = self.db["gmute"]
44
- self.greetings = self.db["greetings"]
45
- self.mute = self.db["mute"]
46
- self.pmpermit = self.db["pmpermit"]
47
- self.session = self.db["session"]
48
- self.snips = self.db["snips"]
49
- self.stan_users = self.db["stan_users"]
50
 
51
  async def connect(self):
52
  try:
53
  await self.client.admin.command("ping")
54
  LOGS.info(f"Database Connection Established!")
 
 
 
55
  except Exception as e:
56
  LOGS.info(f"DatabaseErr: {e} ")
57
  quit(1)
@@ -62,604 +44,6 @@ class Database:
62
  def get_datetime(self) -> str:
63
  return datetime.datetime.now().strftime("%d/%m/%Y - %H:%M")
64
 
65
- async def set_env(self, name: str, value: str) -> None:
66
- await self.env.update_one(
67
- {"name": name}, {"$set": {"value": value}}, upsert=True
68
- )
69
-
70
- async def get_env(self, name: str) -> str | None:
71
- if await self.is_env(name):
72
- data = await self.env.find_one({"name": name})
73
- return data["value"]
74
- return None
75
-
76
- async def rm_env(self, name: str) -> None:
77
- await self.env.delete_one({"name": name})
78
-
79
- async def is_env(self, name: str) -> bool:
80
- if await self.env.find_one({"name": name}):
81
- return True
82
- return False
83
-
84
- async def get_all_env(self) -> list:
85
- return [i async for i in self.env.find({})]
86
-
87
- async def is_stan(self, client: int, user_id: int) -> bool:
88
- if await self.stan_users.find_one({"client": client, "user_id": user_id}):
89
- return True
90
- return False
91
-
92
- async def add_stan(self, client: int, user_id: int) -> bool:
93
- if await self.is_stan(client, user_id):
94
- return False
95
- await self.stan_users.insert_one(
96
- {"client": client, "user_id": user_id, "date": self.get_datetime()}
97
- )
98
- return True
99
-
100
- async def rm_stan(self, client: int, user_id: int) -> bool:
101
- if not await self.is_stan(client, user_id):
102
- return False
103
- await self.stan_users.delete_one({"client": client, "user_id": user_id})
104
- return True
105
-
106
- async def get_stans(self, client: int) -> list:
107
- return [i async for i in self.stan_users.find({"client": client})]
108
-
109
- async def get_all_stans(self) -> list:
110
- return [i async for i in self.stan_users.find({})]
111
-
112
- async def is_session(self, user_id: int) -> bool:
113
- if await self.session.find_one({"user_id": user_id}):
114
- return True
115
- return False
116
-
117
- async def update_session(self, user_id: int, session: str) -> None:
118
- await self.session.update_one(
119
- {"user_id": user_id},
120
- {"$set": {"session": session, "date": self.get_datetime()}},
121
- upsert=True,
122
- )
123
-
124
- async def rm_session(self, user_id: int) -> None:
125
- await self.session.delete_one({"user_id": user_id})
126
-
127
- async def get_session(self, user_id: int):
128
- if not await self.is_session(user_id):
129
- return False
130
- data = await self.session.find_one({"user_id": user_id})
131
- return data
132
-
133
- async def get_all_sessions(self) -> list:
134
- return [i async for i in self.session.find({})]
135
-
136
- async def is_gbanned(self, user_id: int) -> bool:
137
- if await self.gban.find_one({"user_id": user_id}):
138
- return True
139
- return False
140
-
141
- async def add_gban(self, user_id: int, reason: str) -> bool:
142
- if await self.is_gbanned(user_id):
143
- return False
144
- await self.gban.insert_one(
145
- {"user_id": user_id, "reason": reason, "date": self.get_datetime()}
146
- )
147
- return True
148
-
149
- async def rm_gban(self, user_id: int):
150
- if not await self.is_gbanned(user_id):
151
- return None
152
- reason = (await self.gban.find_one({"user_id": user_id}))["reason"]
153
- await self.gban.delete_one({"user_id": user_id})
154
- return reason
155
-
156
- async def get_gban(self) -> list:
157
- return [i async for i in self.gban.find({})]
158
-
159
- async def get_gban_user(self, user_id: int) -> dict | None:
160
- if not await self.is_gbanned(user_id):
161
- return None
162
- return await self.gban.find_one({"user_id": user_id})
163
-
164
- async def is_gmuted(self, user_id: int) -> bool:
165
- if await self.gmute.find_one({"user_id": user_id}):
166
- return True
167
- return False
168
-
169
- async def add_gmute(self, user_id: int, reason: str) -> bool:
170
- if await self.is_gmuted(user_id):
171
- return False
172
- await self.gmute.insert_one(
173
- {"user_id": user_id, "reason": reason, "date": self.get_datetime()}
174
- )
175
- return True
176
-
177
- async def rm_gmute(self, user_id: int):
178
- if not await self.is_gmuted(user_id):
179
- return None
180
- reason = (await self.gmute.find_one({"user_id": user_id}))["reason"]
181
- await self.gmute.delete_one({"user_id": user_id})
182
- return reason
183
-
184
- async def get_gmute(self) -> list:
185
- return [i async for i in self.gmute.find({})]
186
-
187
- async def add_mute(self, client: int, user_id: int, chat_id: int, reason: str):
188
- await self.mute.update_one(
189
- {"client": client, "user_id": user_id, "chat_id": chat_id},
190
- {"$set": {"reason": reason, "date": self.get_datetime()}},
191
- upsert=True,
192
- )
193
-
194
- async def rm_mute(self, client: int, user_id: int, chat_id: int) -> str:
195
- reason = (await self.get_mute(client, user_id, chat_id))["reason"]
196
- await self.mute.delete_one({"client": client, "user_id": user_id, "chat_id": chat_id})
197
- return reason
198
-
199
- async def is_muted(self, client: int, user_id: int, chat_id: int) -> bool:
200
- if await self.get_mute(client, user_id, chat_id):
201
- return True
202
- return False
203
-
204
- async def get_mute(self, client: int, user_id: int, chat_id: int):
205
- data = await self.mute.find_one({"client": client, "user_id": user_id, "chat_id": chat_id})
206
- return data
207
-
208
- async def set_afk(
209
- self, user_id: int, reason: str, media: int, media_type: str
210
- ) -> None:
211
- await self.afk.update_one(
212
- {"user_id": user_id},
213
- {
214
- "$set": {
215
- "reason": reason,
216
- "time": time.time(),
217
- "media": media,
218
- "media_type": media_type,
219
- }
220
- },
221
- upsert=True,
222
- )
223
-
224
- async def get_afk(self, user_id: int):
225
- data = await self.afk.find_one({"user_id": user_id})
226
- return data
227
-
228
- async def is_afk(self, user_id: int) -> bool:
229
- if await self.afk.find_one({"user_id": user_id}):
230
- return True
231
- return False
232
-
233
- async def rm_afk(self, user_id: int) -> None:
234
- await self.afk.delete_one({"user_id": user_id})
235
-
236
- async def set_flood(self, client_chat: tuple[int, int], settings: dict):
237
- await self.antiflood.update_one(
238
- {"client": client_chat[0], "chat": client_chat[1]},
239
- {"$set": settings},
240
- upsert=True,
241
- )
242
-
243
- async def get_flood(self, client_chat: tuple[int, int]):
244
- data = await self.antiflood.find_one(
245
- {"client": client_chat[0], "chat": client_chat[1]}
246
- )
247
- return data or {}
248
-
249
- async def is_flood(self, client_chat: tuple[int, int]) -> bool:
250
- data = await self.get_flood(client_chat)
251
-
252
- if not data:
253
- return False
254
-
255
- if data["limit"] == 0:
256
- return False
257
-
258
- return True
259
-
260
- async def get_all_floods(self) -> list:
261
- return [i async for i in self.antiflood.find({})]
262
-
263
- async def set_autopost(self, client: int, from_channel: int, to_channel: int):
264
- await self.autopost.update_one(
265
- {"client": client},
266
- {
267
- "$push": {
268
- "autopost": {
269
- "from_channel": from_channel,
270
- "to_channel": to_channel,
271
- "date": self.get_datetime(),
272
- }
273
- }
274
- },
275
- upsert=True,
276
- )
277
-
278
- async def get_autopost(self, client: int, from_channel: int):
279
- data = await self.autopost.find_one(
280
- {
281
- "client": client,
282
- "autopost": {"$elemMatch": {"from_channel": from_channel}},
283
- }
284
- )
285
- return data
286
-
287
- async def is_autopost(
288
- self, client: int, from_channel: int, to_channel: int = None
289
- ) -> bool:
290
- if to_channel:
291
- data = await self.autopost.find_one(
292
- {
293
- "client": client,
294
- "autopost": {
295
- "$elemMatch": {
296
- "from_channel": from_channel,
297
- "to_channel": to_channel,
298
- }
299
- },
300
- }
301
- )
302
- else:
303
- data = await self.autopost.find_one(
304
- {
305
- "client": client,
306
- "autopost": {"$elemMatch": {"from_channel": from_channel}},
307
- }
308
- )
309
- return True if data else False
310
-
311
- async def rm_autopost(self, client: int, from_channel: int, to_channel: int):
312
- await self.autopost.update_one(
313
- {"client": client},
314
- {
315
- "$pull": {
316
- "autopost": {
317
- "from_channel": from_channel,
318
- "to_channel": to_channel,
319
- }
320
- }
321
- },
322
- )
323
-
324
- async def get_all_autoposts(self, client: int) -> list:
325
- return [i async for i in self.autopost.find({"client": client})]
326
-
327
- async def add_blacklist(self, client: int, chat: int, blacklist: str):
328
- await self.blacklist.update_one(
329
- {"client": client, "chat": chat},
330
- {"$push": {"blacklist": blacklist}},
331
- upsert=True,
332
- )
333
-
334
- async def rm_blacklist(self, client: int, chat: int, blacklist: str):
335
- await self.blacklist.update_one(
336
- {"client": client, "chat": chat},
337
- {"$pull": {"blacklist": blacklist}},
338
- )
339
-
340
- async def is_blacklist(self, client: int, chat: int, blacklist: str) -> bool:
341
- blacklists = await self.get_all_blacklists(client, chat)
342
- if blacklist in blacklists:
343
- return True
344
- return False
345
-
346
- async def get_all_blacklists(self, client: int, chat: int) -> list:
347
- data = await self.blacklist.find_one({"client": client, "chat": chat})
348
-
349
- if not data:
350
- return []
351
-
352
- return data["blacklist"]
353
-
354
- async def get_blacklist_clients(self) -> list:
355
- return [i async for i in self.blacklist.find({})]
356
-
357
- async def set_echo(self, client: int, chat: int, user: int):
358
- await self.echo.update_one(
359
- {"client": client, "chat": chat},
360
- {"$push": {"echo": user}},
361
- upsert=True,
362
- )
363
-
364
- async def rm_echo(self, client: int, chat: int, user: int):
365
- await self.echo.update_one(
366
- {"client": client, "chat": chat},
367
- {"$pull": {"echo": user}},
368
- )
369
-
370
- async def is_echo(self, client: int, chat: int, user: int) -> bool:
371
- data = await self.get_all_echo(client, chat)
372
- if user in data:
373
- return True
374
- return False
375
-
376
- async def get_all_echo(self, client: int, chat: int) -> list:
377
- data = await self.echo.find_one({"client": client, "chat": chat})
378
-
379
- if not data:
380
- return []
381
-
382
- return data["echo"]
383
-
384
- async def set_filter(self, client: int, chat: int, keyword: str, msgid: int):
385
- await self.filter.update_one(
386
- {"client": client, "chat": chat},
387
- {"$push": {"filter": {"keyword": keyword, "msgid": msgid}}},
388
- upsert=True,
389
- )
390
-
391
- async def rm_filter(self, client: int, chat: int, keyword: str):
392
- await self.filter.update_one(
393
- {"client": client, "chat": chat},
394
- {"$pull": {"filter": {"keyword": keyword}}},
395
- )
396
-
397
- async def rm_all_filters(self, client: int, chat: int):
398
- await self.filter.delete_one({"client": client, "chat": chat})
399
-
400
- async def is_filter(self, client: int, chat: int, keyword: str) -> bool:
401
- data = await self.get_filter(client, chat, keyword)
402
- return True if data else False
403
-
404
- async def get_filter(self, client: int, chat: int, keyword: str):
405
- data = await self.filter.find_one(
406
- {
407
- "client": client,
408
- "chat": chat,
409
- "filter": {"$elemMatch": {"keyword": keyword}},
410
- }
411
- )
412
- return data
413
-
414
- async def get_all_filters(self, client: int, chat: int) -> list:
415
- data = await self.filter.find_one({"client": client, "chat": chat})
416
-
417
- if not data:
418
- return []
419
-
420
- return data["filter"]
421
-
422
- async def set_snip(self, client: int, chat: int, keyword: str, msgid: int):
423
- await self.snips.update_one(
424
- {"client": client, "chat": chat},
425
- {"$push": {"snips": {"keyword": keyword, "msgid": msgid}}},
426
- upsert=True,
427
- )
428
-
429
- async def rm_snip(self, client: int, chat: int, keyword: str):
430
- await self.snips.update_one(
431
- {"client": client, "chat": chat},
432
- {"$pull": {"snips": {"keyword": keyword}}},
433
- )
434
-
435
- async def rm_all_snips(self, client: int, chat: int):
436
- await self.snips.delete_one({"client": client, "chat": chat})
437
-
438
- async def is_snip(self, client: int, chat: int, keyword: str) -> bool:
439
- data = await self.get_snip(client, chat, keyword)
440
- return True if data else False
441
-
442
- async def get_snip(self, client: int, chat: int, keyword: str):
443
- data = await self.snips.find_one(
444
- {
445
- "client": client,
446
- "chat": chat,
447
- "snips": {"$elemMatch": {"keyword": keyword}},
448
- }
449
- )
450
- return data
451
-
452
- async def get_all_snips(self, client: int, chat: int) -> list:
453
- data = await self.snips.find_one({"client": client, "chat": chat})
454
-
455
- if not data:
456
- return []
457
-
458
- return data["snips"]
459
-
460
- async def add_pmpermit(self, client: int, user: int):
461
- await self.pmpermit.update_one(
462
- {"client": client, "user": user},
463
- {"$set": {"date": self.get_datetime()}},
464
- upsert=True,
465
- )
466
-
467
- async def rm_pmpermit(self, client: int, user: int):
468
- await self.pmpermit.delete_one({"client": client, "user": user})
469
-
470
- async def is_pmpermit(self, client: int, user: int) -> bool:
471
- data = await self.get_pmpermit(client, user)
472
- return True if data else False
473
-
474
- async def get_pmpermit(self, client: int, user: int):
475
- data = await self.pmpermit.find_one({"client": client, "user": user})
476
- return data
477
-
478
- async def get_all_pmpermits(self, client: int) -> list:
479
- return [i async for i in self.pmpermit.find({"client": client})]
480
-
481
- async def set_welcome(self, client: int, chat: int, message: int):
482
- await self.greetings.update_one(
483
- {"client": client, "chat": chat, "welcome": True},
484
- {"$set": {"message": message}},
485
- upsert=True,
486
- )
487
-
488
- async def rm_welcome(self, client: int, chat: int):
489
- await self.greetings.delete_one(
490
- {"client": client, "chat": chat, "welcome": True}
491
- )
492
-
493
- async def is_welcome(self, client: int, chat: int) -> bool:
494
- data = await self.get_welcome(client, chat)
495
- return True if data else False
496
-
497
- async def get_welcome(self, client: int, chat: int):
498
- data = await self.greetings.find_one(
499
- {"client": client, "chat": chat, "welcome": True}
500
- )
501
- return data
502
-
503
- async def set_goodbye(self, client: int, chat: int, message: int):
504
- await self.greetings.update_one(
505
- {"client": client, "chat": chat, "welcome": False},
506
- {"$set": {"message": message}},
507
- upsert=True,
508
- )
509
-
510
- async def rm_goodbye(self, client: int, chat: int):
511
- await self.greetings.delete_one(
512
- {"client": client, "chat": chat, "welcome": False}
513
- )
514
-
515
- async def is_goodbye(self, client: int, chat: int) -> bool:
516
- data = await self.get_goodbye(client, chat)
517
- return True if data else False
518
-
519
- async def get_goodbye(self, client: int, chat: int):
520
- data = await self.greetings.find_one(
521
- {"client": client, "chat": chat, "welcome": False}
522
- )
523
- return data
524
-
525
- async def get_all_greetings(self, client: int) -> list:
526
- return [i async for i in self.greetings.find({"client": client})]
527
-
528
- async def add_forcesub(self, chat: int, must_join: int):
529
- await self.forcesub.update_one(
530
- {"chat": chat},
531
- {"$push": {"must_join": must_join}},
532
- upsert=True,
533
- )
534
-
535
- async def rm_forcesub(self, chat: int, must_join: int) -> int:
536
- await self.forcesub.update_one(
537
- {"chat": chat},
538
- {"$pull": {"must_join": must_join}},
539
- )
540
- data = await self.forcesub.find_one({"chat": chat})
541
- return len(data["must_join"])
542
-
543
- async def rm_all_forcesub(self, in_chat: int):
544
- await self.forcesub.delete_one({"chat": in_chat})
545
-
546
- async def is_forcesub(self, chat: int, must_join: int) -> bool:
547
- data = await self.get_forcesub(chat)
548
- if must_join in data["must_join"]:
549
- return True
550
- return False
551
-
552
- async def get_forcesub(self, in_chat: int):
553
- data = await self.forcesub.find_one({"chat": in_chat})
554
- return data
555
-
556
- async def get_all_forcesubs(self) -> list:
557
- return [i async for i in self.forcesub.find({})]
558
-
559
- async def add_gachabot(
560
- self, client: int, bot: tuple[int, str], catch_command: str, chat_id: int
561
- ):
562
- await self.gachabots.update_one(
563
- {"client": client, "bot": bot[0]},
564
- {
565
- "$set": {
566
- "username": bot[1],
567
- "catch_command": catch_command,
568
- "chat_id": chat_id,
569
- "date": self.get_datetime(),
570
- }
571
- },
572
- upsert=True,
573
- )
574
-
575
- async def rm_gachabot(self, client: int, bot: int, chat_id: int = None):
576
- if chat_id:
577
- await self.gachabots.delete_one(
578
- {"client": client, "bot": bot, "chat_id": chat_id}
579
- )
580
- else:
581
- await self.gachabots.delete_one({"client": client, "bot": bot})
582
-
583
- async def is_gachabot(self, client: int, bot: int, chat_id: int) -> bool:
584
- data = await self.get_gachabot(client, bot, chat_id)
585
- return True if data else False
586
-
587
- async def get_gachabot(self, client: int, bot: int, chat_id: int):
588
- data = await self.gachabots.find_one(
589
- {"client": client, "bot": bot, "chat_id": chat_id}
590
- )
591
-
592
- return data
593
-
594
- async def get_all_gachabots(self, client: int) -> list:
595
- return [i async for i in self.gachabots.find({"client": client})]
596
-
597
- async def get_all_gachabots_id(self) -> list:
598
- data = await self.gachabots.distinct("bot")
599
- return data
600
-
601
- async def _get_cohere_chat_from_db(self, user_id):
602
- user_data = await self.cohere.find_one({"user_id": user_id})
603
- return user_data.get("cohere_chat", []) if user_data else []
604
-
605
- async def _update_cohere_chat_in_db(self, user_id, cohere_chat):
606
- await self.cohere.update_one(
607
- {"user_id": user_id},
608
- {"$set": {"cohere_chat": cohere_chat}},
609
- upsert=True
610
- )
611
-
612
- async def _clear_history_in_db(self, user_id):
613
- unset_clear = {"cohere_chat": None}
614
- return await self.cohere.update_one({"user_id": user_id}, {"$unset": unset_clear})
615
-
616
- async def clear_database(self, user_id):
617
- """Clear the cohere history for the current user."""
618
- result = await self._clear_history_in_db(user_id)
619
- if result.modified_count > 0:
620
- return "Chat history cleared successfully."
621
- else:
622
- return "No chat history found to clear."
623
-
624
- async def set_chat_setting(self, chat_id, isboolean):
625
- await self.antiarabic.update_one(
626
- {"chat_id": chat_id},
627
- {"$set": {"arabic": isboolean}},
628
- upsert=True
629
- )
630
-
631
- async def chat_antiarabic(self, chat_id):
632
- user_data = await self.antiarabic.find_one({"chat_id": chat_id})
633
- if user_data:
634
- return user_data.get("arabic", False)
635
- return False
636
-
637
- async def add_chatbot(self, chat_id, user_id):
638
- await self.chatbot.update_one(
639
- {"chat_id": chat_id},
640
- {"$set": {"user_id": user_id}},
641
- upsert=True
642
- )
643
-
644
- async def get_chatbot(self, chat_id):
645
- user_data = await self.chatbot.find_one({"chat_id": chat_id})
646
- return user_data.get("user_id") if user_data else None
647
-
648
- async def add_gemini_plan(self, user_id):
649
- await self.gemini_plan.update_one(
650
- {"user_id": user_id},
651
- {"$set": {"is_plan": True}},
652
- upsert=True
653
- )
654
-
655
- async def is_gemini_plan(self, user_id):
656
- user_data = await self.gemini_plan.find_one({"user_id": user_id})
657
- return user_data.get("is_plan", False) if user_data else None
658
-
659
- async def remove_chatbot(self, chat_id):
660
- unset_data = {"user_id": None}
661
- return await self.chatbot.update_one({"chat_id": chat_id}, {"$unset": unset_data})
662
-
663
  async def _update_chatbot_chat_in_db(self, user_id, chatbot_chat):
664
  await self.backup_chatbot.update_one(
665
  {"user_id": user_id},
@@ -682,18 +66,4 @@ class Database:
682
  else:
683
  return "No chat history found to clear."
684
 
685
- async def set_chat_setting_antinsfw(self, chat_id, isboolean):
686
- await self.antinsfw.update_one(
687
- {"chat_id": chat_id},
688
- {"$set": {"antinsfw": isboolean}},
689
- upsert=True
690
- )
691
-
692
- async def chat_antinsfw(self, chat_id):
693
- user_data = await self.antinsfw.find_one({"chat_id": chat_id})
694
- if user_data:
695
- return user_data.get("antinsfw", False)
696
- return False
697
-
698
-
699
  db = Database(MONGO_URL)
 
24
  self.client: AgnosticClient = motor_asyncio.AsyncIOMotorClient(uri)
25
  self.db = self.client["Akeno"]
26
 
27
+ self.user_blacklists = self.db["user_blacklist"]
 
 
 
 
 
 
 
 
 
 
 
28
  self.backup_chatbot = self.db["google_genai"]
 
 
 
 
 
 
 
 
 
 
29
 
30
  async def connect(self):
31
  try:
32
  await self.client.admin.command("ping")
33
  LOGS.info(f"Database Connection Established!")
34
+ await self.user_blacklists.create_index("unfreeze_at")
35
+ await self.user_blacklists.create_index("is_frozen")
36
+ LOGS.info(f"Database Create index Connected!")
37
  except Exception as e:
38
  LOGS.info(f"DatabaseErr: {e} ")
39
  quit(1)
 
44
  def get_datetime(self) -> str:
45
  return datetime.datetime.now().strftime("%d/%m/%Y - %H:%M")
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  async def _update_chatbot_chat_in_db(self, user_id, chatbot_chat):
48
  await self.backup_chatbot.update_one(
49
  {"user_id": user_id},
 
66
  else:
67
  return "No chat history found to clear."
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  db = Database(MONGO_URL)