update
This commit is contained in:
parent
fa629f27e5
commit
7aa517ac25
4
bot.py
4
bot.py
|
@ -5,6 +5,7 @@ import functions.get_newest_count
|
|||
from functions.send_message import send_message
|
||||
from functions.scan_posts import scan_posts
|
||||
from functions.check_chat import check_chat
|
||||
from functions.check_users import check_users
|
||||
import var
|
||||
from beloved_logger import logger
|
||||
from functions.update_display_name import update_display_name
|
||||
|
@ -12,7 +13,7 @@ from functions.update_display_name import update_display_name
|
|||
|
||||
async def main_loop():
|
||||
await check_chat()
|
||||
|
||||
await check_users()
|
||||
if var.text_scanning_is_running or var.image_scanning_is_running:
|
||||
await scan_posts()
|
||||
|
||||
|
@ -20,7 +21,6 @@ async def main_loop():
|
|||
async def startup():
|
||||
var.current_posts_at_start_time = await functions.get_newest_count.get_newest_count()
|
||||
var.bot_started_at = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
logger.info(f"Started bot with values:\n "
|
||||
f"bot start time: {var.bot_started_at}\n"
|
||||
f"logging start time: {var.log_startup_time}\n"
|
||||
|
|
|
@ -18,4 +18,9 @@ niggr
|
|||
|
||||
|
||||
yahir
|
||||
wintendo
|
||||
|
||||
|
||||
|
||||
sjb95
|
||||
escort
|
||||
kirbyfan
|
||||
|
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
@ -0,0 +1 @@
|
|||
9
|
|
@ -0,0 +1,53 @@
|
|||
import aiohttp
|
||||
import var
|
||||
import requests
|
||||
from beloved_logger import logger
|
||||
from functions.roll_token import roll_token
|
||||
|
||||
|
||||
|
||||
async def check_ip_tracker():
|
||||
with open('data/tracked-users.txt', 'r') as file:
|
||||
reader = csv.reader(file)
|
||||
user_ids = [row[0] for row in reader]
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
tasks = [fetch_data(session, user_id) for user_id in user_ids]
|
||||
results = await asyncio.gather(*tasks)
|
||||
|
||||
for user_id, log_times in results:
|
||||
all_results.append((user_id, log_times))
|
||||
|
||||
print("Results stored in memory.")
|
||||
print(all_results)
|
||||
|
||||
|
||||
async def get_user_ip(user_id):
|
||||
await roll_token()
|
||||
|
||||
url = f"https://sketchersunited.org/admin/ip_tracker?profile_id={user_id}"
|
||||
|
||||
cookies = {
|
||||
var.cookie_name: var.cookie_value,
|
||||
'sketchers_united_session': var.session,
|
||||
'XSRF-TOKEN': var.xsrf_token
|
||||
}
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'automod',
|
||||
'Accept': 'application/json, */*'
|
||||
}
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.get(url, cookies=cookies, headers=headers) as response:
|
||||
if response.status != 200:
|
||||
logger.info(f"Failed to fetch data for user {user_id}: {response.status}")
|
||||
return None
|
||||
|
||||
data = await response.json()
|
||||
logger.info(f"Data for user {user_id}: {data}")
|
||||
return data
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching data for user {user_id}: {e}")
|
||||
return None
|
|
@ -0,0 +1,49 @@
|
|||
from functions.get_user_details import get_user_details
|
||||
from functions.suspend_user import suspend_user_with_reason
|
||||
from functions.send_message import send_message
|
||||
import var
|
||||
from beloved_logger import logger
|
||||
import logging
|
||||
|
||||
|
||||
forbidden_strings = [
|
||||
'[mod]',
|
||||
'[moderator]',
|
||||
'[admin]',
|
||||
'[administrator]',
|
||||
'[chat mod]',
|
||||
'[chat moderator]',
|
||||
'yahir'
|
||||
]
|
||||
|
||||
forbidden_strings_username = [
|
||||
'ken',
|
||||
'rack',
|
||||
'sjb',
|
||||
'yahir'
|
||||
]
|
||||
|
||||
async def check_users():
|
||||
user_details = await get_user_details(var.current_user_id+1)
|
||||
|
||||
if user_details is None:
|
||||
return
|
||||
|
||||
var.current_user_id = var.current_user_id+1
|
||||
|
||||
if 'username' in user_details['data']:
|
||||
username = user_details['data']['username'].lower()
|
||||
|
||||
if any(forbidden in username for forbidden in forbidden_strings_username):
|
||||
await suspend_user_with_reason(var.current_user_id, "detected forbidden name text")
|
||||
await send_message(f"User with forbidden username @{username} detected and banned for 24 hours. users/{var.current_user_id}")
|
||||
|
||||
if 'name' in user_details['data']:
|
||||
if user_details['data']['name'] is None:
|
||||
return
|
||||
|
||||
name = user_details['data']['name'].lower()
|
||||
|
||||
if any(forbidden in name for forbidden in forbidden_strings):
|
||||
await suspend_user_with_reason(var.current_user_id, "detected forbidden name text")
|
||||
await send_message(f"User with forbidden display name '{name}' detected and banned for 24 hours. users/{var.current_user_id}")
|
|
@ -0,0 +1,19 @@
|
|||
import aiohttp
|
||||
|
||||
|
||||
async def get_user_details(user_id):
|
||||
url = f"https://sketchersunited.org/users/{user_id}"
|
||||
|
||||
headers = {
|
||||
"Accept": "application/json",
|
||||
"User-Agent": "automod by username"
|
||||
}
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url, headers=headers) as response:
|
||||
if response.status != 200:
|
||||
print(f"Failed to fetch data: {response.status}")
|
||||
return None
|
||||
|
||||
data = await response.json()
|
||||
return data
|
|
@ -44,3 +44,43 @@ async def suspend_user_for_post(post):
|
|||
|
||||
response = requests.post(f'https://{var.site}/admin/blocks', cookies=cookies, headers=headers, data=data)
|
||||
logger.info(f"Suspending user {post.user_id} occurred with: {response.status_code}")
|
||||
|
||||
|
||||
async def suspend_user_with_reason(user, reason):
|
||||
await roll_token()
|
||||
|
||||
cookies = {
|
||||
var.cookie_name: var.cookie_value,
|
||||
'sketchers_united_session': var.session,
|
||||
'XSRF-TOKEN': var.xsrf_token
|
||||
}
|
||||
|
||||
logging.debug(f"Suspending user with cookies {cookies}")
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'automod',
|
||||
'Content-Type': 'multipart/form-data; boundary=---------------------------33943441651739618973055574259',
|
||||
}
|
||||
|
||||
data = ('-----------------------------33943441651739618973055574259\r\n'
|
||||
'Content-Disposition: form-data; name="_method"\r\n'
|
||||
'\r\nPOST\r\n'
|
||||
'-----------------------------33943441651739618973055574259\r\n'
|
||||
'Content-Disposition: form-data; name="_token"\r\n'
|
||||
f'\r\n{var.csrf_token}\r\n'
|
||||
'-----------------------------33943441651739618973055574259'
|
||||
'\r\nContent-Disposition: form-data; name="blocked_id"\r\n'
|
||||
f'\r\n{user}\r\n'
|
||||
f'-----------------------------33943441651739618973055574259\r\n'
|
||||
'Content-Disposition: form-data; name="days"\r\n'
|
||||
'\r\n1\r\n'
|
||||
'-----------------------------33943441651739618973055574259\r\n'
|
||||
'Content-Disposition: form-data; name="reason"\r\n'
|
||||
'\r\nother\r\n'
|
||||
'-----------------------------33943441651739618973055574259'
|
||||
'\r\nContent-Disposition: form-data; name="note"\r\n'
|
||||
f'\r\nautomated ban with {reason}\r\n'
|
||||
f'-----------------------------33943441651739618973055574259--\r\n').encode()
|
||||
|
||||
response = requests.post(f'https://{var.site}/admin/blocks', cookies=cookies, headers=headers, data=data)
|
||||
logger.info(f"Suspending user occurred with: {response.status_code}")
|
||||
|
|
|
@ -2,4 +2,5 @@ boto3~=1.28.39
|
|||
requests~=2.31.0
|
||||
python-dotenv~=1.0.0
|
||||
websockets~=11.0.3
|
||||
beautifulsoup4~=4.12.2
|
||||
beautifulsoup4~=4.12.2
|
||||
aiohttp
|
||||
|
|
4
var.py
4
var.py
|
@ -13,10 +13,12 @@ cookie_value = os.getenv("COOKIE_VALUE")
|
|||
chat_number = os.getenv("CHAT_NUMBER")
|
||||
filter_file = os.getenv("FILTER_FILE")
|
||||
websocket_url = os.getenv("WEBSOCKET_URL")
|
||||
users_file = os.getenv("USERS_FILE")
|
||||
labels_file = os.getenv("LABELS_FILE")
|
||||
session = os.getenv("STARTUP_SESSION_VALUE")
|
||||
bot_user_number = os.getenv("USER_NUMBER")
|
||||
aws_region = os.getenv("AWS_REGION")
|
||||
current_user_id = int(os.getenv("CURRENT_USER_ID"))
|
||||
|
||||
old_chat = {}
|
||||
scan_new_users_only = True
|
||||
|
@ -30,6 +32,8 @@ scanning_since = None
|
|||
user_timeout = None
|
||||
xsrf_token = None
|
||||
csrf_token = None
|
||||
old_results = []
|
||||
users_file = os.getenv("USERS_FILE")
|
||||
|
||||
filters_list = asyncio.run(get_filters_from_text(filter_file))
|
||||
log_startup_time = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||
|
|
Loading…
Reference in New Issue