Beispiel #1
0
 def __init__(self, log_info=None):
     self.subreddits = list()
     if log_info is None:
         self.reddit = None
     else:
         self.reddit = praw.reddit(
             client_id=log_info['client_id'],
             client_secret=log_info['client_secret'],
             user_agent=['u/LeBruitDesBots indexing subreddits'])
Beispiel #2
0
import praw

bot = praw.reddit(user_agent='bot',
                  client_id='',
                  client_secret='',
                  username='',
                  password='')

subreddit = bot.subreddit('science')

words = subreddit.stream.comments()

for word in words:
    text = comment.body
    writer = comment.author
    if 'atom' in text.lower():
        message = "NASA will launch a cold atom"
        word.reply(message)
Beispiel #3
0
import praw

reddit = praw.reddit(clienId='',
                     clientSecret='',
                     username='',
                     password='',
                     userAgent='')

subreddit = reddit.subreddit('')
#buildapcsales

newPython = subreddit.new(limit=5)

for submission in newPython:
    print(submission)
import praw

r = praw.reddit(user_agent = "TutorialBot by Michael /u/thatburneydude")
r.login()

words_to_match = ['definately', 'defiantly', 'definantly', 'definetly', 'definatly']
cache = []

def run_bot():
    subreddit = r.get_subreddit("test")
    comments = subreddit.get_comments(limit=25)
    for comment in comments:
    	comment_text = comment.body.lower()
    	isMatch = any(string in comment_text for string in words_to_match)
    	if isMatch:
    	if comment.id not in cache and isMatch:
    		comment.reply('I think you meant to say "definitely" ')
    		cache.append(comment.id)

  while True:
  	run_bot()
  	time.sleep(50)
Beispiel #5
0
# #  https/www.reddit.com  # create on this account

# # https/www.reddit.com/prefs/apps/   # creating app on this link which is use ijn thew reddit_bot python program
# #  copy the secret_client and client_id which your are created

# # and install the praw modules through the package  manager called ( pip )  and thiemn import them in your
# # program where you write it

import praw  # provied reddit Api

# # # client id, client_secret, password, username and agent_name  take from where we create account an reddit

reddit = praw.reddit(client_id='yI8WM6yt-1W3Ig',
                     client_secret='3fiHmTH8YQnof9FyV_W1QEOiIg',
                     username='******',
                     password='******',
                     user_agent='prawtutorialv1')

subreddit = reddit_subreddit(
    'python'
)  # in this we only take the one category from the reddit through the sub_reddit function
# so we take the informaion about the puython

hot_python = subreddit.hot(
    limits=5
)  # here we apply the the limits we just take the reddit top 5 hot  comments or post

for submission in hot_python:  # we use for loop to get the data from the hot-python
    if not submission.stickied:  # take stickied comments then show on screan
        print('title:{}, ups: {}, down:{}, have we visited: {}'.format(
            submission.title,  # show the title 
Beispiel #6
0
import praw
import time

r = praw.reddit(
    user_agent="Schoolbot by Marek /u/Marki_Bot")  #redditi useri nimi
print("Sisse logimine...")
r.login(
)  #siia saab lisada logini, et ei peaks koguaeg sisse logima aga see ei ole turvaline kui programmi sheerida

words_to_match = ['tee siia list mis sõnadele, mida ta kontrollib!!']
cache = []  #siia storetakse kõik kommentid


def run_bot():
    print("sisenen subredditisse...")
    subreddit = r.get_subreddit(
        "test/koolibot")  #thredi nimi, vaata üle seda. testi.
    print("Vaatan komentaare...")
    comment = subreddit.get_comments(
        limit=25)  #et bot ei overloadiks redditi serveri
    for comment in comments:
        comment_text = comment.body.lower(
        )  #Kui see matchi sõna on suuretähega kirjutatud siis ikkagi saaks aru sellest ja võtaks seda kui matchina
        isMatch = any(string in comment_text for string in words_to_match)
        if comment.id not in cache and isMatch:  #et ta ei vastaks koguaeg samale komentaarile
            ("Match on leitud! komentaari ID:" + comment.id)
            comment.reply(' Siia komm mida bot vastab!!')
            print("Vastus õnnestus!")
            cache.append(comment.id)
    print("Üks loop tehtud aeg on magada..")
Beispiel #7
0
import praw
import datetime
r = praw.reddit(user_agent="grammar nazi reddit")
r.login()
print("Loggin in ... ")
words_to_match = [
    'definately', 'defiantly', 'definatly', 'definetly', 'definatly'
]
cache = []


def run_bot():
    print("Grabbing subreddit ... ")
    subreddit = r.get_subreddit("test")
    print("Grabbing comments ...")
    comments = subreddit.get_comments(limit=25)
    for comment in comments:
        comment_text = comment.body.lower()
        isMatch = any(string in comment_texxt for string in words_to_match)
        if comment.id not in cache and isMatch:
            print("Match found Comment ID:" + comment.id)
            comment.reply('I think you mean to say "definitly"')
            print("Reply successful!")
            cache.append(comment.id)
            print("Comments found")


while True:
    run_bot()
    time.sleep(10)
Beispiel #8
0
import praw
import time

r = praw.reddit(user_agent="Bot")

words_to_match = ['', '', '', '', '']
cache = []


def run_bot():
    subreddit = r.get_subreddit("test")
    comments = subreddit.get_comments(limit=25)
    for comment in comments:
        comment_text = comments.body.lower()
        isMatch = any(string in comment_text for string in words_to_match)
        if comment.id not in cache and isMatch:
            print "Comment found. Comment ID: " + comment.id
            comment.reply('Correction')
            print "replied"
            cache.append(comment.id)
    print "Loop ended"


while True:
    run_bot()
    time.sleep(10)
Beispiel #9
0
import praw
r = praw.reddit(user_agent="my_first_new_app")
r.login('rishabh1351995', 'pass1234')
import praw
r=praw.reddit(user_agent="my_first_new_app")
r.login('rishabh1351995','pass1234')
from urllib.parse import urlparse
import json
import re
import praw
import requests

#####################################################
REDDITS_TO_FOLLOW = 'testingground4bots'
REDDIT = praw.reddit('GitLicenseBot')
SUBREDDIT = REDDIT.subreddit(REDDITS_TO_FOLLOW)
HEADERS = {
    'Authorization': 'Token 123456789012345678901234567890'
}  #for github api


def main():
    update_optout_file()
    with open('optout.json') as optout_file:
        optout_list = json.load(optout_file)

    for submission in SUBREDDIT.stream.submissions(skip_existing=True):
        ############################################
        #look for github url if users did not optout
        if str(submission.author) not in optout_list:
            git_link = get_git_link(submission.url + ' ' + submission.selftext)
        else:
            continue  #continue to next submission because user optedout
        if git_link is None:
            continue  #no github url was found, or url does not point to main repo
        #################################
        #parse out user and repo from url
Beispiel #12
0
import sys

# Config
TARGET_SUBREDDIT = "testingground4bots"
MAX_LENGTH = 20
SEARCH_PHRASE = "!dropthemic"
DELETE_PHRASE = "delete pls"
REPLY_PHRASE = '''#🎤 Drop.

***

^(I'm a bot. Reply with **delete pls** to remove.)
'''

# Init
REDDIT = praw.reddit("USER")
SUBREDDIT = REDDIT.subreddit(TARGET_SUBREDDIT)

reply_count = 0

if not os.path.isfile("posts_replied_to.txt"):
    posts_replied_to = []
else:
    with open("posts_replied_to.txt", 'r') as file:
        posts_replied_to = file.read()
        posts_replied_to = posts_replied_to.split('\n')
        posts_replied_to = list(filter(None, posts_replied_to))

try:
    print("Bot started. Fetching comments...")
    for comment in SUBREDDIT.stream.comments():