-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasedBot.py
More file actions
84 lines (66 loc) · 2.24 KB
/
BasedBot.py
File metadata and controls
84 lines (66 loc) · 2.24 KB
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
import requests
import os
from get_messages import check_for_messages, last_message, message_id, last_message_text, sender_pfp_image, message_sender
from send_based_message import send_based_message, get_id
from wrappers import command
from getsol import getsol
import time
import pymongo
from pymongo import MongoClient
from update_message import update_message
#SETTING DB
mongo_password = os.environ['dbpass']
# Replace the uri string with your MongoDB deployment's connection string.
uri = f"mongodb+srv://MD20M:{mongo_password}@baseddb.ukb0vd2.mongodb.net/?retryWrites=true&w=majority"
try:
cluster = MongoClient(uri)
print("connected")
except:
print("error")
db = cluster["BasedDB"]
def get_receivertype(receiver):
post = {}
collection = db["users"]
collection.find(post)
item_details = collection.find(post)
for item in item_details:
if (item['name'] == receiver):
return "user"
collection = db["groups"]
collection.find(post)
item_details = collection.find(post)
for item in item_details:
if (item['name'] == receiver):
return "user"
def get_chattype(receiver):
post = {}
collection = db["users"]
collection.find(post)
item_details = collection.find(post)
for item in item_details:
if (item['name'] == receiver):
return "users"
collection = db["groups"]
collection.find(post)
item_details = collection.find(post)
for item in item_details:
if (item['name'] == receiver):
return "groups"
class BasedBot:
def send(self, receiver, message):
sent_data = send_based_message(get_receivertype(receiver), receiver, message)
#class edit():
#update_message(sent_data["data"]["id"])
def message_text(self, chat):
return last_message_text(get_id(chat, get_chattype(chat)),
get_chattype(chat))
def message_sender_pfp(self, chat):
return sender_pfp_image(get_id(chat, get_chattype(chat)),
get_chattype(chat))
def message_sender_name(self, chat):
return message_sender(get_id(chat, get_chattype(chat)), get_chattype(chat))
def message_id(self, chat):
return message_id(get_id(chat, get_chattype(chat)), get_chattype(chat))
#bot = BasedBot()
#bot.send("kriyos", "test")
#get_receivertype("kriyos")