Jakub Koziol
Jakub Koziol

Reputation: 1

Getting no attribute reply when running praw on Python Everywhere

I am trying to run a bot on pythoneverywhere, I currently run it on my pc but I want to move it to the cloud. When it tries to comment on a post I get the error,

AttributeError: 'class 'praw.objects.Submission'' has no attribute 'reply'

I have looked at the official praw documentation online and the code I use should work, it works on by pc.

#!/usr/bin/python
import praw
import pdb
import re
import os
import threading
import time




# Create the Reddit instance

#
# and login
#reddit.login(REDDIT_USERNAME, REDDIT_PASS)

reddit = praw.Reddit(Private INfo)



soccer_array = ['Keyword']
soccer_link = [
"comment",
]
def soccer():
    subreddit = reddit.get_subreddit('sub')
    print("Checking Soccer")
    for submission in subreddit.get_new(limit=40):
        #print(submission.title)
        i = 0


        while i <= (len(soccer_array) - 1):

        # If we havent replied to this post before

            # Do a case insensitive search
            if re.search(soccer_array[i], submission.title, re.IGNORECASE):
                 # Reply to the post
                submission.reply(soccer_link[i])
                print('')
                print("Bot replying to: ", submission.title)
                print('')
                del soccer_array[i]
                del soccer_link[i]
                time.sleep(1000)

            else:
                i += 1
        else:
                i += 1



def should_reset_timer():
  pass


def main():
  soccer()
  timer = 0
  while True:
    time.sleep(1)
    timer+=1
    if should_reset_timer():
      timer = 0
    if timer == 10*60:
      soccer()
      timer = 0













main()

Upvotes: 0

Views: 161

Answers (1)

jarhill0
jarhill0

Reputation: 1629

You need to update PRAW on your server. On your PC, you have PRAW>=4, but the version installed on your server is <4.

I know this because your traceback mentions praw.objects.Submission, but current versions of PRAW have praw.models.Submission. PRAW 3, on the other hand, had praw.objects.Submission.

Upvotes: 1

Related Questions