-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathdb.py
More file actions
35 lines (26 loc) · 896 Bytes
/
db.py
File metadata and controls
35 lines (26 loc) · 896 Bytes
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
# -*- encoding: utf-8 -*-
import requests
import pymongo
import result
my_client = pymongo.MongoClient("mongodb://localhost:27017/")
my_db = my_client["CHERBIM"]
IP_Port = my_db["IP_Port"]
# 数据库保存,查询和删除
def ip_saved(info_json, i):
_id = info_json["result"][i]["update_id"]
chat_id = info_json["result"][i]["message"]["from"]["id"]
username = info_json["result"][i]["message"]["from"]["username"]
ip_port = info_json["result"][i]["message"]["text"].replace("&ip_check ", "")
data = {"_id": _id, "chat_id": chat_id, "username": username, "ip_port": ip_port}
try:
IP_Port.insert_one(data, bypass_document_validation=True)
try:
result.check_result(chat_id, ip_port)
except IndexError:
pass
except pymongo.errors.DuplicateKeyError:
pass
def ip_check():
pass
def ip_delete():
pass