import random
import datetime
from ai import get_ai_response
import logger

last_post_time = None
post_chance = None

def setup(settings):
    global last_post_time, post_chance
    last_post_time = datetime.datetime.utcnow()
    post_chance = settings.get("start_chance", 0.05)

def should_post(settings):
    global post_chance
    if random.random() < post_chance:
        return True
    post_chance += settings.get("increase_per_interval", 0.05)
    return False

def on_post(settings):
    global post_chance, last_post_time
    post_chance -= settings.get("decay_on_post", 0.02)
    post_chance = max(post_chance, 0.01)
    last_post_time = datetime.datetime.utcnow()
