Esempio n. 1
0
def run(usuario, url, password, repeticiones):
    click.secho("Cargando credenciales", fg="blue")
    click.secho(
        "Agregar nombres de usuario al users.txt sin arroba ANTES DE EJECUTAR EL BOT",
        fg="red")
    bot.username = usuario
    bot.url = url
    bot.password = password
    time.sleep(5)
    load_users()
    bot.login()
    for x in range(repeticiones):
        bot.comment_post()
Esempio n. 2
0
def run(usr, passw, srv):
    sess = bot.login(usr, passw, srv)
    print("\nLog into " + usr + " , " + srv + " server")
    bot.train(sess, srv)
    print("\tTraining...")
    bot.work(sess, srv)
    print("\tWorking...")
    sess.close()
    print("\tExit\n")
    return
Esempio n. 3
0
def get_contacts():
    # try:
    if bot.login():
        bot.contacts = bot.get_contacts()
        if id_last_contact:
            index_last_contact = next(
                (index for index, contact in enumerate(bot.contacts)
                 if contact.id == id_last_contact), None)
            bot.contacts = bot.contacts[
                index_last_contact:] if index_last_contact else bot.contacts
    return render_template('contacts.html', total_contacts=len(bot.contacts))
Esempio n. 4
0
import bot, config

for login in config.logins:
    bot.login(login)
while True:
    msg = raw_input("> ")
    for client in bot.clients():
        bot.command(client, msg)

Esempio n. 5
0
def login():
    global r
    log.debug('Logging in to reddit.')
    r = bot.login(r)
Esempio n. 6
0
import bot, config

for login in config.logins:
    bot.login(login)
while True:
    msg = raw_input("> ")
    for client in bot.clients():
        bot.command(client, msg)
Esempio n. 7
0
from json import load
import logging

last_day = localtime().tm_mday
with open("info/time.txt") as file:
    last_scan = load(file)

def save_scan_time():
    global last_scan
    last_scan = time()
    with open("info/time.txt", 'w') as file:
        file.write(str(last_scan))
        # another approach would be to save newest submission id
        # r.get_subreddit("name",place_holder=id) to get content newer than id

bot.login("Python:episodeInfo:v2.0 (by /u/Almenon)")

while True:
    try:
        # scan posts / mentions / messages / replies
        bot.scan(last_scan)
        save_scan_time()

        # reset post limits each new day
        if localtime().tm_mday != last_day:
            for key in bot.num_posts: bot.num_posts[key] = 0
            last_day = localtime().tm_mday

    except praw.errors.PRAWException as e:
        logging.exception(e)
        logging.info("see http://praw.readthedocs.org/en/stable/pages/exceptions.html")
Esempio n. 8
0
SUBMISSION_TYPE = {
    'any': 0,
    'link': 1,
    'self': 2,
    None: 3,
}
SUBREDDIT_TYPE_REVERSE = {v: k for (k, v) in SUBREDDIT_TYPE.items()}
SUBMISSION_TYPE_REVERSE = {v: k for (k, v) in SUBMISSION_TYPE.items()}

SUBMISSION_OBJ = praw.objects.Submission
SUBREDDIT_OBJ = praw.objects.Subreddit
COMMENT_OBJ = praw.objects.Comment

print('Logging in.')
r = praw.Reddit(USERAGENT)
bot.login(r)


def base36encode(number, alphabet='0123456789abcdefghijklmnopqrstuvwxyz'):
    """Converts an integer to a base36 string."""
    if not isinstance(number, (int)):
        raise TypeError('number must be an integer')
    base36 = ''
    sign = ''
    if number < 0:
        sign = '-'
        number = -number
    if 0 <= number < len(alphabet):
        return sign + alphabet[number]
    while number != 0:
        number, i = divmod(number, len(alphabet))
Esempio n. 9
0
from time import time, sleep, localtime
import bot
from requests.exceptions import ConnectionError
from requests.exceptions import ReadTimeout
import logging
from pymongo import MongoClient
from os import environ

client = MongoClient(environ['mongodb_uri'])
db = client.heroku_m17k26m5
saved_time = db.last_time  # type: collection
last_time = saved_time.find_one()['time']

last_day = localtime().tm_mday
bot.login("Python:episodeInfo:v2.0 (by /u/Almenon)")

while True:
    try:
        # scan posts / mentions / messages / replies
        bot.scan(last_time)

        # save time
        last_time = time()
        saved_time.update_one({}, {'$set': {'time': last_time}})

        # reset post limits each new day
        if localtime().tm_mday != last_day:
            for key in bot.num_posts:
                bot.num_posts[key] = 0
            last_day = localtime().tm_mday
Esempio n. 10
0
HEADER_BRIEF = '      LAST SCANNED       |   NAME'

MEMBERFORMAT_FULL = '{id:>6} {created} {username:<20} {link_karma:>9} {comment_karma:>9} ({total_karma:>10}) | {lastscan}'
MEMBERFORMAT_BRIEF = '{lastscan} | {username}'

MIN_LASTSCAN_DIFF = 86400 * 2000
# Don't rescan a name if we scanned it this many days ago

VALID_CHARS = string.ascii_letters + string.digits + '_-'

# If True, print the name of the user we're about to fetch.
# Good for debugging problematic users.
PREPRINT = False

print('Logging in.')
r = bot.login()
r3 = bot3.login(bot3.praw.Reddit(USERAGENT))


def base36encode(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
    """Converts an integer to a base36 string."""
    if not isinstance(number, (int)):
        raise TypeError('number must be an integer')
    base36 = ''
    sign = ''
    if number < 0:
        sign = '-'
        number = -number
    if 0 <= number < len(alphabet):
        return sign + alphabet[number]
    while number != 0:
Esempio n. 11
0
def init(webdriver, tag):
    constantes.init()
    bot.login(webdriver, tag)
Esempio n. 12
0
    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    if (args.createMissingPages or args.updateStatsPages
            or args.updateLanguagePage) and not (args.loginName
                                                 and args.password):
        parser.error(
            '--login and --password required with --createMissingPages, --updateStatsPages and --updateLanguagePage'
        )

    if args.createMissingPages or args.updateStatsPages or args.updateLanguagePage:
        from bot import login, getPage, editPage, getToken, updatePairStatsSection, getPairCounts, addCategory, createStatsSection, getFileLocs
        authToken = login(args.loginName, args.password)
        moveToken = getToken('move', 'info')
        editToken = getToken('edit', 'info|revisions')
        if not all([authToken, moveToken, editToken]):
            logging.critical('Failed to obtain required token')
            sys.exit(-1)

    primaryPairs, secondaryPairs = {}, {}
    allLangs = []

    for inputLangOrPage in args.languages:
        if len(inputLangOrPage) > 3:
            inputPage = inputLangOrPage
            from bot import getPage
            logging.info('Getting wiki page %s' % inputPage)
            pageContent = getPage(inputPage)
Esempio n. 13
0
MEMBERFORMAT_FULL = '{id:>6} {created} {username:<20} {link_karma:>9} {comment_karma:>9} ({total_karma:>10}) | {lastscan}'
MEMBERFORMAT_BRIEF = '{lastscan} | {username}'

MIN_LASTSCAN_DIFF = 86400 * 2000
# Don't rescan a name if we scanned it this many days ago

VALID_CHARS = string.ascii_letters + string.digits + '_-'

# If True, print the name of the user we're about to fetch.
# Good for debugging problematic users.
PREPRINT = False


print('Logging in.')
r = praw.Reddit(USERAGENT)
bot.login(r)


def allpossiblefromset(characters, length=None, minlength=None, maxlength=None):
    '''
    Given an iterable of characters, return a generator that creates every
    permutation of length `length`.

    If `minlength` and `maxlength` are both provided, all values of intermediate
    lengths will be generated
    '''

    if not (minlength is None or maxlength is None):
        for x in range(minlength, maxlength+1):
            for item in allpossiblefromset(characters, x):
                yield item
Esempio n. 14
0
import bot
import praw
import sys
import time

subreddits = []
reddit = bot.login()
#username=reddit.config.custom['username']


class PostListener(bot.Bot):
    def __init__(self, subreddit=all):
        subreddits.append(subreddit)

    def listen(self):  #subreddit to listen to by user input
        firstPost = True
        old = []

        while True:
            try:
                for s in subreddits:
                    for post in reddit.subreddit(s).new(limit=10):
                        if firstPost is True:
                            old.append(post.id)
                        if post.id not in old:
                            self.redditMessage(post)
                            old.append(post.id)

                time.sleep(5)
                firstPost = False