Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import requests
- import json
- bot = praw.Reddit(client_id='-----------',
- client_secret='----------------------',
- user_agent='User-Agent: Python/PRAW:firstdoge:v0.0.1 (by /u/FirstDogecoin)',
- password='-------------',
- username='FirstDogecoin')
- subreddit = bot.subreddit('firstdogecss')
- moderators = []
- workingstate = True
- approve = '!a'
- toggle = '!t'
- ban = '!b'
- report = '!r'
- response = 'This is a test message that actually tips'
- for moderator in subreddit.moderator():
- moderators.append(moderator.name)
- print(moderators)
- try:
- for comment in subreddit.stream.comments():
- if (not comment.is_root and
- approve in comment.body.lower() and
- comment.author.name in moderators):
- try:
- if (workingstate == True):
- replied = 0
- parent = comment.parent()
- parent.refresh()
- for counter in range(0, len(parent.replies.list()) - 1):
- if (parent.replies.list()[counter].author.name == 'FirstDogecoin'):
- replied = 1
- if replied == 0:
- parent.reply(response)
- comment.mod.remove()
- try:
- connection = requests.get("https://api.blockcypher.com/v1/doge/main/addrs/DN8oRmALs2VDn21uqCGMC1tTZTaEDbyWdC")
- if connection.status_code == 200:
- j = json.loads(connection.text)
- balance = j['final_balance']/100000000
- subreddit.flair.set('FirstDogecoin', "Fund balance: " + str(balance) + "Ð")
- except Exception as e:
- print(e)
- print('Error getting balance')
- except Exception as e:
- print(e)
- elif (toggle in comment.body.lower() and
- comment.author.name in moderators):
- try:
- replied = 0
- parent = comment.parent()
- parent.refresh()
- for counter in range(0, len(parent.replies.list()) - 1):
- if (parent.replies.list()[counter].author.name == 'FirstDogecoin'):
- replied = 1
- if replied == 0:
- workingstate = not workingstate
- if (workingstate == False):
- parent.reply('Approval commands disabled on moderator request.')
- elif (workingstate == True):
- parent.reply('Approval commands re-enabled on moderator request.')
- comment.mod.remove()
- except Exception as e:
- print(e)
- elif (ban in comment.body.lower() and
- comment.author.name in moderators):
- try:
- replied = 0
- parent = comment.parent()
- parent.refresh()
- for counter in range(0, len(parent.replies.list()) - 1):
- if (parent.replies.list()[counter].author.name == 'FirstDogecoin'):
- replied = 1
- if replied == 0:
- reason = comment.body.replace('!b', '')
- subreddit.banned.add(parent.redditor, ban_reason = reason)
- parent.reply('User banned on moderator request. Reason: .' + reason)
- comment.mod.remove()
- except Exception as e:
- print(e)
- except Exception as e:
- print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement