import praw import time import datetime import os def bot_login(): print("Çalıştırılıyor...") r = praw.Reddit(username = os.environ["reddit kullanıcı adı"], password = os.environ["şifre"], client_id = os.environ["client id"], client_secret = os.environ["client secret"], user_agent = "Rez Alıcı") print("Başlatıldı!") return r def run_bot(r, log): print("Aranıyor...") for comment in r.subreddit('KGBTR').comments(limit=100): time_now = datetime.datetime.utcnow() comment_time = datetime.datetime.utcfromtimestamp(comment.created_utc) time_since = int((time_now - comment_time).total_seconds()) if comment.id not in log and time_since < 54000 and "u/HerSeyeRezAlanAdam" in comment.body and comment.author != r.user.me(): print("Buludu") comment.reply("rez") print("Rez Alındı") log.append(comment.id) with open ("log.txt", "a") as f: f.write(comment.id + "\n") print("10 Saniyeliğine Duruluyor...") time.sleep(10) def get_saved_comments(): if not os.path.isfile("log.txt"): log = [] else: with open("log.txt", "r") as f: log = f.read() log = log.split("\n") log = filter(None, log) log = list(filter(None, log)) return log r = bot_login() log = get_saved_comments() print(log) while True: run_bot(r, log)