forked from voussoir/reddit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot_template.py
More file actions
49 lines (40 loc) · 1010 Bytes
/
bot_template.py
File metadata and controls
49 lines (40 loc) · 1010 Bytes
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
# /u/GoldenSights
import praw
#import sqlite3
import time
import traceback
''' USER CONFIG '''
USERAGENT = ""
APP_ID = ""
APP_SECRET = ""
APP_URI = ""
APP_REFRESH = ""
# https://www.reddit.com/comments/3cm1p8/how_to_make_your_bot_use_oauth2/
WAIT = 60
# The number of seconds between each cycle. The bot is completely inactive during this time.
''' All done! '''
try:
import bot
USERAGENT = bot.aG
APP_ID = bot.oG_id
APP_SECRET = bot.oG_secret
APP_URI = bot.oG_uri
APP_REFRESH = bot.oG_scopes['all']
except ImportError:
pass
#sql = sqlite3.connect('filename.db')
#cur = sql.cursor()
#cur.execute('CREATE TABLE IF NOT EXISTS tablename(column TEXT)')
print('Logging in.')
r = praw.Reddit(USERAGENT)
r.set_oauth_app_info(APP_ID, APP_SECRET, APP_URI)
r.refresh_access_information(APP_REFRESH)
def main():
pass
while True:
try:
main()
except Exception as e:
traceback.print_exc()
print('Running again in %d seconds\n' % WAIT)
time.sleep(WAIT)