How to use the praw.models.Redditor function in praw

To help you get started, we’ve selected a few praw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github praw-dev / praw / tests / unit / models / reddit / test_redditor.py View on Github external
def test_hash(self):
        redditor1 = Redditor(self.reddit, _data={"name": "dummy1", "n": 1})
        redditor2 = Redditor(self.reddit, _data={"name": "Dummy1", "n": 2})
        redditor3 = Redditor(self.reddit, _data={"name": "dummy3", "n": 2})
        assert hash(redditor1) == hash(redditor1)
        assert hash(redditor2) == hash(redditor2)
        assert hash(redditor3) == hash(redditor3)
        assert hash(redditor1) == hash(redditor2)
        assert hash(redditor2) != hash(redditor3)
        assert hash(redditor1) != hash(redditor3)
github praw-dev / praw / tests / integration / models / reddit / test_live.py View on Github external
def test_remove__redditor(self):
        self.reddit.read_only = False
        thread = LiveThread(self.reddit, "xyu8kmjvfrww")
        redditor = Redditor(
            self.reddit, _data={"name": "nmtake", "id": "ll32z"}
        )
        with self.recorder.use_cassette(
            "TestLiveContributorRelationship_test_remove__redditor"
        ):
            thread.contributor.remove(redditor)
github praw-dev / praw / tests / integration / models / reddit / test_message.py View on Github external
def test_attributes(self, _):
        self.reddit.read_only = False
        with self.recorder.use_cassette("TestMessage.test_attributes"):
            messages = list(self.reddit.inbox.messages())
            count = len(messages)
            while messages:
                message = messages.pop(0)
                messages.extend(message.replies)
                count -= 1
                try:
                    assert message.author is None or isinstance(
                        message.author, Redditor
                    )
                    assert isinstance(message.dest, (Redditor, Subreddit))
                    assert isinstance(message.replies, list)
                    assert message.subreddit is None or isinstance(
                        message.subreddit, Subreddit
                    )
                except Exception:
                    import pprint

                    pprint.pprint(vars(message))
                    raise
        assert count < 0
github praw-dev / praw / tests / unit / models / reddit / test_redditor.py View on Github external
def test_equality(self):
        redditor1 = Redditor(self.reddit, _data={"name": "dummy1", "n": 1})
        redditor2 = Redditor(self.reddit, _data={"name": "Dummy1", "n": 2})
        redditor3 = Redditor(self.reddit, _data={"name": "dummy3", "n": 2})
        assert redditor1 == redditor1
        assert redditor2 == redditor2
        assert redditor3 == redditor3
        assert redditor1 == redditor2
        assert redditor2 != redditor3
        assert redditor1 != redditor3
        assert "dummy1" == redditor1
        assert redditor2 == "dummy1"
github praw-dev / praw / tests / unit / models / reddit / test_redditor.py View on Github external
def test_hash(self):
        redditor1 = Redditor(self.reddit, _data={"name": "dummy1", "n": 1})
        redditor2 = Redditor(self.reddit, _data={"name": "Dummy1", "n": 2})
        redditor3 = Redditor(self.reddit, _data={"name": "dummy3", "n": 2})
        assert hash(redditor1) == hash(redditor1)
        assert hash(redditor2) == hash(redditor2)
        assert hash(redditor3) == hash(redditor3)
        assert hash(redditor1) == hash(redditor2)
        assert hash(redditor2) != hash(redditor3)
        assert hash(redditor1) != hash(redditor3)
github paramt / trackarma / src / collect_data.py View on Github external
def main(usePreset: bool, reddit_name=constants.reddit_name):
    if(usePreset):
        reddit = praw.Reddit('Bot')
    else:
        reddit = praw.Reddit(client_id=os.environ['CLIENT_ID'],
                             client_secret=os.environ['CLIENT_SECRET'],
                             user_agent=os.environ['USER_AGENT'])

    redditor = praw.models.Redditor(reddit, name=reddit_name)
    now = datetime.datetime.now()
    karma_total = redditor.link_karma + redditor.comment_karma

    # Add datetime to dates.txt
    with open("data/dates.txt", "r") as file:
        dates = file.read().splitlines()

    dates.append(str(now))

    with open("data/dates.txt", "w") as file:
        for date in dates:
            file.write(date + "\n")

    # Add line to karma-delta.txt
    with open('data/karma-total.txt', 'r') as file:
        karma_totals = file.read().splitlines()
github Pragmatismo / Pigrow / scripts / autorun / reddit_settings_ear.py View on Github external
#determine local ip - apparently this works on macs if you change the 0 to a 1 but i don't buy apple products so...
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('8.8.8.8', 0))  # connecting to a UDP address doesn't send packets
        local_ip_address = s.getsockname()[0]
        page_text += 'Current local network IP ' + str(local_ip_address)
    except:
        page_text += 'Local IP not deduced, sorry...'

    print("writing " + str(len(page_text)) + " characters to reddit")
    if whereto == 'wiki':
        praw.models.WikiPage(reddit, subreddit, wiki_title).edit(page_text[0:524288])
    else:
        try:
            whereto = praw.models.Redditor(reddit, name=whereto, _data=None)
            whereto.message('Pigrow Settings', page_text[0:10000])   #, from_subreddit=subreddit)
        except:
            pigrow_defs.write_log(script, "couldn't contact redditor, wrong naem?", loc_dic['err_log'])
github praw-dev / praw / praw / reddit.py View on Github external
def redditor(self, name=None, fullname=None):
        """Return a lazy instance of :class:`~.Redditor`.

        :param name: The name of the redditor.
        :param fullname: The fullname of the redditor, starting with ``t2_``.

        Either ``name`` or ``fullname`` can be provided, but not both.

        """
        return models.Redditor(self, name=name, fullname=fullname)