-
Notifications
You must be signed in to change notification settings - Fork 0
/
s.py
54 lines (43 loc) · 1.92 KB
/
s.py
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
# coding: utf-8
import os
import praw
import json
import time
import requests
callText = "!gaumutra"
url = "https://api.pushshift.io/reddit/search/comment/?q="+callText
subreddits = ["bakchodi", "nepal", "india", "indiaspeaks", "ioe", "chutyapa"]
RepTxt = "**बंधू /u/{}, you have been blessed with पवित्र [gaumutra 🍶](https://i.imgur.com/1LZfLRq.jpg) from [गौमातृ 🐄](https://i.imgur.com/SB97oql.jpg)**\n\n卐 requested by /u/{}"
reddit = praw.Reddit(username = os.environ["username"],
password = os.environ["password"],
client_id = os.environ["client_id"],
client_secret = os.environ["client_secret"],
user_agent = "GauMatri by /u/Gaumatri")
print("Authorized: ", reddit.user.me())
def function(before, after):
data = requests.get(url).text
for _ in range(25):
tmp_data = json.loads(data)["data"][_]
time_uploaded = now = tmp_data["created_utc"]
if time_uploaded>=before and time_uploaded<after:
if callText in tmp_data["body"].lower():
if tmp_data["subreddit"].lower() in subreddits or True: #Remove or true to limit subreddits
# Gifter and Gifted
son = tmp_data["author"]
father = reddit.comment(tmp_data["id"]).parent().author.name
tmp_RepTxt = RepTxt.format(father, son)
print(tmp_data["body"], end="\n")
submission = reddit.comment(tmp_data["id"])
submission.reply(tmp_RepTxt)
else:
break
while True:
data = int(time.time())
after = data - data%30
before = after - 30
time_uploaded = (before+ after)/2
if (data - after)>=0 and (data - after)<5:
function(before, after)
time.sleep(5)
else:
time.sleep(5)