-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBotzilla.py.txt
94 lines (79 loc) · 3.43 KB
/
Botzilla.py.txt
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
import zoom
import time
import os
import getpass
from dotenv import load_dotenv
# Function to securely prompt for input
def get_secure_input(prompt):
return getpass.getpass(prompt)
# Load API key and secret from environment variables or configuration file
def load_api_keys():
# Example of loading API keys from environment variables
# api_key = os.getenv("ZOOM_API_KEY")
# api_secret = os.getenv("ZOOM_API_SECRET")
# Example of loading API keys from a configuration file
# with open('config.txt', 'r') as f:
# api_key = f.readline().strip()
# api_secret = f.readline().strip()
# For demonstration purposes, use secure input:
api_key = get_secure_input("Enter Zoom API Key: ")
api_secret = get_secure_input("Enter Zoom API Secret: ")
return api_key, api_secret
# Initialize the Zoom client
def initialize_zoom_client(api_key, api_secret):
client = zoom.ZoomClient(api_key=api_key, api_secret=api_secret)
return client
class Botzillah:
def __init__(self, api_key, api_secret):
self.client = initialize_zoom_client(api_key, api_secret)
self.blacklist = [] # Add inappropriate names or usernames here
self.spam_threshold = 3
self.spam_counts = {}
self.last_entry_times = {}
self.banned_users = {}
self.inappropriate_words = [
"satan", "satanic", "pedo", "perv", "pervert", "no limits",
"pedophile", "cannibalism", "bestiality", "scat", "CP",
"child pornography", "satanism", "devil worship"
]
def join_meeting(self):
# Example: Auto-join using Personal Meeting ID (PMI)
self.meeting = self.client.meeting.join(name="Botzillah")
def monitor_chat(self):
while True:
messages = self.meeting.get_chat_messages()
for message in messages:
sender = message.get('sender_name').lower()
text = message.get('text').lower()
# Check for inappropriate usernames or spam
if sender in self.blacklist or self.is_inappropriate(sender, text):
self.remove_user(sender)
else:
self.spam_counts[sender] = self.spam_counts.get(sender, 0) + 1
time.sleep(1)
def is_inappropriate(self, sender, text):
# Increment spam count and check threshold
if sender in self.spam_counts and self.spam_counts[sender] >= self.spam_threshold:
return True
# Check for inappropriate content in username or text
if any(word in sender for word in self.inappropriate_words) or \
any(word in text for word in self.inappropriate_words):
return True
# Check for frequent re-entry
if sender in self.last_entry_times and time.time() - self.last_entry_times[sender] < 60:
return True
self.last_entry_times[sender] = time.time()
return False
def remove_user(self, sender):
self.meeting.remove_user(sender)
self.blacklist.append(sender)
print(f"User {sender} removed and added to blacklist.")
def run(self):
self.join_meeting()
self.monitor_chat()
if __name__ == "__main__":
# Load API keys
api_key, api_secret = load_api_keys()
# Initialize and run the bot
botzillah = Botzillah(api_key, api_secret)
botzillah.run()