diff options
-rw-r--r-- | Dockerfile | 2 | ||||
-rwxr-xr-x | database.py | 3 | ||||
-rwxr-xr-x | exampleconfig.json | 19 | ||||
-rwxr-xr-x | onceaday.py | 13 | ||||
-rwxr-xr-x | requirements.txt | 2 | ||||
-rwxr-xr-x | runprog.py | 2 | ||||
-rwxr-xr-x | subreddit.py | 15 |
7 files changed, 30 insertions, 26 deletions
@@ -6,4 +6,4 @@ COPY . /app WORKDIR /app RUN pip3 install -r requirements.txt ENTRYPOINT ["python3"] -CMD ["runprog.py"] +CMD ["subreddit.py"] diff --git a/database.py b/database.py index 2491c08..6eaddbb 100755 --- a/database.py +++ b/database.py @@ -280,9 +280,10 @@ def migrate(sqlitefile): db.migrate(sqlitefile) if __name__ == "__main__": - migrate("SmallYTChannelDatabase.db") + #migrate("SmallYTChannelDatabase.db") # with Database() as db: # #db.give_lambda("floofleberries", "https://www.reddit.com/r/SmallYTChannel/comments/ho5b5p/new_video_advice_would_help_but_even_just_a_watch/") # print(db.id_in_blacklist("hyy6v0")) + print(subreddit.format_monthly_leaderboard()) diff --git a/exampleconfig.json b/exampleconfig.json index 3a8879c..0e517df 100755 --- a/exampleconfig.json +++ b/exampleconfig.json @@ -2,21 +2,21 @@ "redditapi": { "client_id": "xxxxxxxxxxxxxxx", - "client_secret": "xxxxxxxxxxxxxxxxxxxx", + "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxx", "user_agent": "SmallYTChannelBot", - "username": "xxxxxxxxxxxxxxxxx", - "password": "xxxxxxxxxxxxxxxxxxxxx" + "username": "SmallYTChannelBot", + "password": "xxxxxxxxxxxxxxxxxxxxxxxxxxx" }, "imgurapi": { - "client_id": "xxxxxxxxxxxxxxxxxxxx", - "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "client_id": "xxxxxxxxxxxxxxxx", + "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, "youtubeapi": { - "developer_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "developer_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, - "subreddit": "jwnskanzkwktest", + "subreddit": "SmallYTChannel", "comment_tail": "\n\n\n ^/u/SmallYTChannelBot ^*made* ^*by* ^/u/jwnskanzkwk. ^*PM* ^*for* ^*bug* ^*reports.* ^*For* ^*more* ^*information,* ^*read* ^*the* ^[FAQ.](https://www.reddit.com/user/SmallYTChannelBot/comments/a4u7qj/smallytchannelbot_faq/)", "free_flairs": [ @@ -29,7 +29,8 @@ "host": "localhost", "port": 3306, "user": "root", - "passwd": "xxxxxxxxxxxxxxxxx", + "passwd": "xxxxxxxxxxxxxxxx", "database": "SmallYTChannel" - } + }, + "min_comment_len": 120 } diff --git a/onceaday.py b/onceaday.py index 0be0c2f..d2f750a 100755 --- a/onceaday.py +++ b/onceaday.py @@ -1,10 +1,7 @@ -import subreddit -from time import sleep +import os +os.chdir("/root/SmallYTChannelBotSubmissions") -SECONDS_IN_DAY = 24 * 60 * 60 +import subreddit -while True: - #sleep(60 * 60 * 13) - subreddit.every_day() - print("Called @ %s" % subreddit.get_time()) - sleep(60 * 60 * 24) +subreddit.every_day() +subreddit.logging.info("Called OAD prog @ %s" % subreddit.get_time()) diff --git a/requirements.txt b/requirements.txt index 7f1d56a..20e1539 100755 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ google_api_python_client imgurpython js2py -praw +praw>=7.1.0 sqlite3-to-mysql pymysql @@ -16,7 +16,7 @@ while True: pid = file.readlines()[0] file.close() - subprocess.run(["kill", pid]) + # subprocess.run(["kill", pid]) thread.terminate() print("killed ", pid) diff --git a/subreddit.py b/subreddit.py index c5c9265..5f6c906 100755 --- a/subreddit.py +++ b/subreddit.py @@ -115,13 +115,13 @@ def update_tables(scores, data): REDDIT.subreddit("u_SmallYTChannelBot").submit("/r/SmallYTChannel Statistics: %s" % date, url = imageurl).reply(content).mod.distinguish(sticky = True) - SUBREDDIT.wiki["lambdatables"].edit(content, reason = "Update: %s" % date) - SUBREDDIT.wiki[date].edit(content, reason = "Update: %s" % date) + #SUBREDDIT.wiki["lambdatables"].edit(content, reason = "Update: %s" % date) + #SUBREDDIT.wiki[date].edit(content, reason = "Update: %s" % date) - currentdata = SUBREDDIT.wiki["index"].content_md - currentdata += "\n\n* [%s](/r/SmallYTChannel/wiki/%s)" % (date, date) + #currentdata = SUBREDDIT.wiki["index"].content_md + #currentdata += "\n\n* [%s](/r/SmallYTChannel/wiki/%s)" % (date, date) - SUBREDDIT.wiki["index"].edit(currentdata, reason = "Update: %s" % date) + #SUBREDDIT.wiki["index"].edit(currentdata, reason = "Update: %s" % date) def upload_image(path, date): config = { @@ -195,10 +195,15 @@ def handle_givelambda(comment): display(text, concerning=comment.permalink) elif submission.link_flair_text in FREE_FLAIRS: text = "You cannot give lambda in free posts anymore." + display("Giving lambda was rejected due to being a free post", concerning=comment.permalink) elif op != str(submission.author): text = "Only the OP can give λ." elif db.user_given_lambda(parentauthour, str(submission.permalink)): text = "You have already given /u/%s λ for this submission. Why not give λ to another user instead?" % parentauthour + display("Giving lambda was rejected for being the same user", concerning=comment.permalink) + elif len(comment.parent().body) < CONFIG["min_comment_len"]: + text = "You can no longer give λ to comments that are fewer than %i characters in length. This is to encourage specific, detailed feedback." % CONFIG["min_comment_len"] + display("Giving lambda was rejected due to insufficient length", concerning=comment.permalink) else: display("'/u/%s' has given '/u/%s' lambda!" % (op, parentauthour), concerning=comment.permalink) text = "You have given /u/%s 1λ. /u/%s now has %iλ" % (parentauthour, parentauthour, db.get_lambda(parentauthour)[0] + 1) |