Skip to content

Commit

Permalink
antispam casino
Browse files Browse the repository at this point in the history
  • Loading branch information
Nftiger committed Apr 27, 2024
1 parent 610a880 commit db7c841
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions events/casino.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,55 @@

import time
import random
import asyncio
from vkbottle.bot import MessageEvent

import logging

import data
from bot import bot, user_api

first_clicks = {}
spam_count = {}
# Обработка команды "🎰 Казино"
async def message(event: MessageEvent):
user_id = event.object.peer_id
donut = await data.is_donut(user_id)
tm_last = await data.get_last_mine(user_id)
tm = int(time.time())
first_click = first_clicks.get(user_id, -1)
if first_click == -1:
first_clicks[user_id] = tm
first_click = tm

tm_diff = tm - tm_last
if tm_diff > 600:
first_clicks[user_id] = tm
first_click = tm

if donut:
time_ban_diff = 3600
else:
time_ban_diff = 1200
if tm - first_click > time_ban_diff:
spam_count[user_id] = spam_count.get(user_id, 0) + 1
if spam_count[user_id] > 50 and not donut:
await event.show_snackbar(f"⛔ {100-spam_count[user_id]} кликов до бана")
else:
await event.show_snackbar("⌛ Отвлекись на 10 минут")
if spam_count[user_id] > 99 and not donut:
await user_api.groups.ban(
group_id=225507433,
owner_id=user_id,
reason=0,
comment="Подозрительная активность. Обратитесь к администору.",
comment_visible=True
)
logging.info(f"[BAN] https://vk.com/gim225507433?sel={user_id}")
return
logging.info(f"[SPAM {spam_count[user_id]}/100] https://vk.com/gim225507433?sel={user_id}")
return

score = await data.get_score(user_id)
if score < 1000:
await event.show_snackbar("🛑 Недостаточно средств!")
Expand Down

0 comments on commit db7c841

Please sign in to comment.