Git Product home page Git Product logo

redditbots's Introduction

RedditBots

Reddit Bots by /u/SmBe19

To run any of those bots you need:

  • Python
  • PRAW (pip install praw)
  • OAuth2Util (pip install praw-oauth2util)

You need PRAW 3 for the bots. They don't work anymore with PRAW 4 and PRAW 5. Due to missing time they won't be ported to new versions of PRAW, sorry.

If the bot uses OAuth2 you have to register an app on Reddit, using script as app type and http://127.0.0.1:65010/authorize_callback as redirect uri. You then have to copy the file called oauthtemplate.txt to oauth.ini and enter the app id and app secret at the corresponding places. On first start up a webbrowser will be started where Reddit asks for permission. Make sure you are logged in with the user you want the bot to be run with when you click accept. If you want to run it on a server where you don't have a graphical browser you can try server mode of OAuth2Util. Or you can run the bot the first time locally and then copy the oauth.ini file (which now contains all necessary tokens) to your server.

In the source code of the bots you will find at the top the USER CONFIGURATION and sometimes the BOT CONFIGURATION. In the USER CONFIGURATION section you should fill out every variable as they describe detailed what and where the bot should do (e.g. User Name, Subreddit to operate in, duration of sleep). The BOT CONFIGURATION section defines variables that you don't really have to change, but if you really have to, they are there. They are mostly constants for the bot (e.g. Name of config files).

You can set the variables set in the USER CONFIGURATION / BOT CONFIGURATION also in a separate file called bot.py, just use key = value (e.g. username = "SmBe19"). This way you don't have to edit the source directly (so it's easier to update) and you can exclude this file from git. Btw. it's a normal Python file, that get's executed, so you can use code as for example password = getpass.getpass().

redditbots's People

Contributors

smbe19 avatar spedwards avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redditbots's Issues

OAuth2 Still not working on pythoneverywhere

python3.5 ~/WIKI/UserListKeeper.py :0: UserWarning: The keywordbotin your user_agent may be problematic. Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/praw/internal.py", line 213, in _raise_response_exceptions response.raise_for_status() # These should all be directly mapped File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 840, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.reddit.com/api/v1/access_token/ During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 345, in refresh new_token = self.r.refresh_access_information(self._get_value(CONFIGKEY_REFRESH_TOKEN)) File "/usr/local/lib/python3.5/dist-packages/praw/__init__.py", line 1492, in refresh_access_information refresh_token=refresh_token or self.refresh_token) File "<decorator-gen-11>", line 2, in refresh_access_information File "/usr/local/lib/python3.5/dist-packages/praw/decorators.py", line 288, in require_oauth return function(*args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/praw/__init__.py", line 735, in refresh_access_information retval = self._handle_oauth_request(data) File "/usr/local/lib/python3.5/dist-packages/praw/__init__.py", line 659, in _handle_oauth_request response = self._request(url, auth=auth, data=data, raw_response=True) File "/usr/local/lib/python3.5/dist-packages/praw/__init__.py", line 454, in _request _raise_response_exceptions(response) File "/usr/local/lib/python3.5/dist-packages/praw/internal.py", line 215, in _raise_response_exceptions raise HTTPException(_raw=exc.response) praw.errors.HTTPException: HTTP error During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/Syndrogo/WIKI/UserListKeeper.py", line 228, in <module> run_bot() File "/home/Syndrogo/WIKI/UserListKeeper.py", line 190, in run_bot o = OAuth2Util.OAuth2Util(r) File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 157, in __init__ self.refresh() File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 356, in refresh self._get_new_access_information() File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 254, in _get_new_access_information self._start_webserver(url) File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 227, in _start_webserver self.server = HTTPServer(server_address, OAuth2UtilRequestHandler) File "/usr/lib/python3.5/socketserver.py", line 443, in __init__ self.server_bind() File "/usr/lib/python3.5/http/server.py", line 138, in server_bind socketserver.TCPServer.server_bind(self) File "/usr/lib/python3.5/socketserver.py", line 457, in server_bind self.socket.bind(self.server_address) OSError: [Errno 99] Cannot assign requested address

(RSSBot) Error caused by useragent in new versions of PRAW: configparser.NoSectionError

Hello, I tried to get the RSS bot to work but when I run it with the latest version of PRAW(5.2.1), it throws an error.

Output of running RSSBot.py

Traceback (most recent call last):                                                                                                    
  File "/usr/lib/python3.5/configparser.py", line 843, in items                                                                       
    d.update(self._sections[section])                                                                                                 
KeyError: 'AusBills RSS bot'                                                                                                          
                                                                                                                                      
During handling of the above exception, another exception occurred:                                                                   
                                                                                                                                      
Traceback (most recent call last):                                                                                                    
  File "./RSSBot.py", line 152, in <module>                                                                                           
    run_bot()                                                                                                                         
  File "./RSSBot.py", line 102, in run_bot                                                                                            
    r = praw.Reddit(USERAGENT)                                                                                                        
  File "/usr/local/lib/python3.5/dist-packages/praw/reddit.py", line 129, in __init__                                                 
    self.config = Config(config_section, **config_settings)                                                                           
  File "/usr/local/lib/python3.5/dist-packages/praw/config.py", line 66, in __init__                                                  
    self.custom = dict(Config.CONFIG.items(site_name), **settings)                                                                    
  File "/usr/lib/python3.5/configparser.py", line 846, in items                                                                       
    raise NoSectionError(section)                                                                                                     
configparser.NoSectionError: No section: 'AusBills RSS bot'                                                                           
You provided the name of a praw.ini configuration which does not exist.                                                               
                                                                                                                                      
For help with creating a Reddit instance, visit                                                                                       
https://praw.readthedocs.io/en/latest/code_overview/reddit_instance.html                                                              
                                                                                                                                      
For help on configuring PRAW, visit                                                                                                   
https://praw.readthedocs.io/en/latest/getting_started/configuration.html 

'AusBills RSS bot' is what I put in the USERAGENT variable.

When looking for a solution to this error I found this:
https://www.reddit.com/r/redditdev/comments/5fxbna/useragent_errorreplybot/

I tried it with an older version of PRAW(3.6.0) and that seemed to resolve the initial issue. I don't know what version of PRAW the script was written for, so it would be helpful if the scripts were updated to the current version of PRAW(5.2), or if the README was edited to include the version of PRAW required.

Cheers :)

AttributeError when posting comments - RSSBot

I know the info for this bot is kinda outdated, but I wanted to give it a shot.
I'm using Python 3 and PRAW 3.6.2. The bot itself runs fine, posts the RSS, keeping track of what it's done. However the one error I'm still receiving and not able to overcome is the error when it attempts to make a comment on each post.
Thanks in advance for any advice you have.

INFO: check sources
ERROR: Exception 'str' object has no attribute 'add_comment'
Traceback (most recent call last):
File "RSSBot.py", line 123, in run_bot
submission.add_comment(DESCRIPTION_FORMAT.format(article[2]))
AttributeError: 'str' object has no attribute 'add_comment'
INFO: sleep for 300 s

RSSBOT not working

So i am running the RSSbot on python everywhere. I have loaded the RSSBot.py file and it opens up lynx panel. I dont know what to do from here. I know its not pulling from the RSS (nothing posted in the reddit.

Error: Forbidden with specific RSS feed, but feed works from browser

I'm trying to use this feed: http://www.metoffice.gov.uk/public/data/PWSCache/WarningsRSS/Region/UK but get the following: "Error: Forbidden" on my console.

The feed format checks out ok using the W3C RSS validation tool: https://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fwww.metoffice.gov.uk%2Fpublic%2Fdata%2FPWSCache%2FWarningsRSS%2FRegion%2FUK

It appears to be the following line in the RSSReader.py that causes the problem:

response = urllib.request.urlopen(source)

If I use a different RSS feed (for example the BBC News feed: http://feeds.bbci.co.uk/news/england/rss.xml?edition=uk) the script works as expected. I can read the Met Office feed fine from a browser, with no authentication required.

I'm afraid I'm new to Python so debugging this any further is beyond me. Any suggestions?

N.B. The Met Office feed will only have content during or shortly after a 'severe weather warning' has been issued, so depending on when you see this, there may not be anything there.

Thanks :)

RSSBOT

Traceback (most recent call last):
File "/usr/lib/python3.4/configparser.py", line 824, in items
d.update(self._sections[section])
KeyError: 'token'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "RSSBot.py", line 125, in
run_bot()
File "RSSBot.py", line 76, in run_bot
o = OAuth2Util.OAuth2Util(r)
File "/home/bl0m1/bot/RedditBots-master/RSSBot/OAuth2Util.py", line 162, in init
self.refresh()
File "/home/bl0m1/bot/RedditBots-master/RSSBot/OAuth2Util.py", line 334, in refresh
self._check_token_present()
File "/home/bl0m1/bot/RedditBots-master/RSSBot/OAuth2Util.py", line 282, in _check_token_present
options = self.config.items(CONFIGKEY_TOKEN[0])
File "/usr/lib/python3.4/configparser.py", line 827, in items
raise NoSectionError(section)
configparser.NoSectionError: No section: 'token'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.