Giter Club home page Giter Club logo

apraw's Introduction

Hi there ๐Ÿ‘‹

My name's RaviAnand. I'm an engineer experienced with front- and back-end technologies and frameworks, such as C# ASP.NET Core, React, Typescript, VueJS, and NestJS.

  • ๐Ÿ”ญ Iโ€™m currently working on Recog, a forum for Swiss schools and my own company - Jenyus Org!
  • ๐ŸŒฑ I love GraphQL and even made my own library for GraphQL APIs, graphql-utils.
  • ๐Ÿ“ซ You can reach out to me via Twitter @Dan6erbond or Discord Dan6erbond#2259.

apraw's People

Contributors

dan6erbond avatar h4cky54ck avatar iammanish17 avatar mandjevant avatar spyrosroum avatar trustyjaid 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

Watchers

 avatar  avatar  avatar  avatar

apraw's Issues

[ENDPOINT] Search Endpoint Issue Subbreddit.Search

Endpoint name: `` [e.g. subreddit_wiki]

Endpoint path: `` [e.g. /r/subreddit/api/wiki]

Expected model/function: `` [e.g. apraw.models.Submission.mod.delete()]

Additional context

Add any other context about the endpoint here.

[BUG] Streamable being set as Class Attributes

Describe the bug

A clear and concise description of what the bug is.

Using class Streamable based generators or iterables on multiple objects of the same type concurrently is not possible due to the class-based nature of descriptors.

Additional context

Add any other context about the problem here.

Presumably the implementation of a ProxyStreamable descriptor will be required to set the instance variables during runtime.

[FEATURE] Use of ReactivePy ReactiveProperties

Describe the solution you'd like

A clear and concise description of what you want to happen.

The usage of ReactivePy's class ReactiveProperty for class aPRAWBase members and an override of ReactiveOwner.on_change method to start a new thread on the event-loop (stored in class Reddit) which calls _fetch() (see issue #78) and can notify of changes.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Custom observable / observer interface similar to those implemented in Java frameworks to mimic the callback functionalities.

Additional context

Add any other context or screenshots about the feature request here.

class ReactiveProperty will require changes where booleans are used, as they are accessed via ReactiveProperty.value.

Manage Ratelimit

Keep track of X-Ratelimit-Used, X-Ratelimit-Remaining and X-Ratelimit-Reset response headers and manage future requests exceeding the rate limit in a queue.

[ENDPOINT] Subreddit Settings

Endpoint name: subreddit_settings [e.g. subreddit_wiki]

Endpoint path: /r/subreddit/about/edit [e.g. /r/subreddit/api/wiki]

Expected model/function: Subreddit.mod.settings() [e.g. apraw.models.Submission.mod.delete()]

Additional context

Add any other context about the endpoint here.

Use the class aPRAWBase to load the settings into a model. Add subreddit_settings_kind to class Reddit.

[ENDPOINT] Item Moderation Endpoints

Endpoint name: `` [e.g. subreddit_wiki]

  • mod_approve
  • mod_distinguish
  • mod_ignore_reports
  • mod_remove
  • mod_show_comment
  • mod_unignore_reports
  • mod_update_croud_control_level

Endpoint path: `` [e.g. /r/subreddit/api/wiki]

  • POST /api/approve
  • POST /api/distinguish
  • POST /api/ignore_reports
  • POST /api/remove
  • POST /api/show_comment
  • POST /api/unignore_reports
  • POST /api/update_crowd_control_level

Expected model/function: `` [e.g. apraw.models.Submission.mod.delete()]

  • apraw.models.Submission.mod.approve(), remove() etc. as well as for apraw.models.Comment.

[FEATURE] Add Support for Flair in PostModeration

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I'm always frustrated when Banhammer.py requires features aPRAW doesn't support yet.

Describe the solution you'd like

A clear and concise description of what you want to happen.

Add support for class Comment/class Submission mod.flair(text=TEXT).

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Using PRAW.

Additional context

Add any other context or screenshots about the feature request here.

if isinstance(item.item, Submission):
    if reaction.flair != "":
        await item.item.mod.flair(text=reaction.flair)
        payload.actions.append("flaired")

[BUG] Streams Not Returning Items

Describe the bug

A clear and concise description of what the bug is.

Streams don't return any items.

To Reproduce

The code with which the issue can be reproduced.

subreddit = await reddit.subreddit("askreddit")

async for submission in subreddit.comments.stream():
  print(submission)

Expected behavior

A clear and concise description of what you expected to happen.

New submissions are printed as they come in.

Environment

A clear and concise description of what your environment looks like.

  • OS: Windows 10 [e.g. Windows, Ubuntu]
  • Python version: 3.8.3 [e.g. 3.6, 3.8]
  • aPRAW version: 0.4.5-alpha [e.g. 0.2.0-alpha]

Additional context

Add any other context about the problem here.

Streams skipping all items due to skip_existing functionality.

[ENDPOINT] Fetch Modmail by ID

Endpoint name: modmail_conversation [e.g. subreddit_wiki]

Endpoint path: /api/mod/conversations/{conversation_id} [e.g. /r/subreddit/api/wiki]

Expected model/function: Subreddit.modmail(id) [e.g. apraw.models.Submission.mod.delete()]

Restructure Models

Move all the models related to Reddit (subreddit, comment, submission etc.) to a /apraw/models folder and import from there.

[FEATURE] Add Support to Ban Users on a Subreddit

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I'm always frustrated when Banhammer.py requires features aPRAW doesn't support yet.

Describe the solution you'd like

A clear and concise description of what you want to happen.

Calling await Subreddit.banned.add(REDDITOR_NAME, REASON, MESSAGE, NOTE) should ban the user and return an adequate response.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Using PRAW.

Additional context

Add any other context or screenshots about the feature request here.

if isinstance(reaction.ban, int):
    ban_message = item.subreddit.banhammer.message_builder.get_ban_message(item, reaction.ban)
    if reaction.ban == 0:
        subreddit = await item.item.subreddit()
        await subreddit.banned.add(item.item.author.name, ban_reason="Breaking Rules",
                                   ban_message=ban_message, note="Banhammer Ban")
        payload.actions.append("/u/" + item.item.author.name + " permanently banned")
    else:
        subreddit = await item.item.subreddit()
        await subreddit.banned.add(item.item.author.name, ban_reason="Breaking Rules",
                                   duration=reaction.ban, ban_message=ban_message,
                                   note="Banhammer Ban")
        payload.actions.append(f"/u/{item.item.author.name} banned for {reaction.ban} day(s)")```

[ENDPOINT] Replying to Submissions/Comments/Messages

Endpoint name: api_comment

Endpoint path: POST /api/comment

Expected model/function: submission.reply() for class Comment and class Message as well.

Additional context

Add any other context about the endpoint here.

Using a mixin and the aPRAWBase.fullname attribute for reusability.

[ENHANCEMENT] Make aPRAWBase Lazy

Description

Describe the enhancement to be made to the codebase.

class aPRAWBase should be lazy. Data is loaded via internal _fetch() method. This will allow for easier use of the ReactivePy package in the future and efficiently returning items after creation.

[ENDPOINT] /api/v1/me/karma

Endpoint name: `` [e.g. subreddit_wiki]

me_karma

Endpoint path: `` [e.g. /r/subreddit/api/wiki]

/api/v1/me/karma

Expected model/function: `` [e.g. apraw.models.Submission.mod.delete()]

Reddit.user.me().karma()

Additional context

Add any other context about the endpoint here.

Returns a list of dictionaries/objects containing information about where how much comment/link karma was obtained.

[BUG] AuthorMixin nonfunctional in Message Class

Describe the bug

A clear and concise description of what the bug is.

Trying to access a class Message author via the author() mixin method fails and results in the following traceback:

Traceback (most recent call last):
  File "D:\Programming\Mariavi\Reddify v2\venv\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
    ret = await coro(*args, **kwargs)
  File "d:\Programming\Mariavi\Reddify v2\cogs\user_cog.py", line 61, in verify
    author = await message.author()
  File "D:\Programming\Mariavi\Reddify v2\venv\lib\site-packages\apraw\models\mixins\author.py", line 21, in author
    if self._author is None:
AttributeError: 'Message' object has no attribute '_author'

To Reproduce

The code with which the issue can be reproduced.

auth_user = await self.reddit.user.me()
    async for message in auth_user.unread.stream(skip_existing=True):
        if isinstance(message, apraw.models.Message):
            author = await message.author()

Expected behavior

A clear and concise description of what you expected to happen.

The message's author to be returned as a class Redditor.

Environment

A clear and concise description of what your environment looks like.

  • OS: Windows 10 [e.g. Windows, Ubuntu]
  • Python version: 3.8.3 [e.g. 3.6, 3.8]
  • aPRAW version: 0.5.2-alpha [e.g. 0.2.0-alpha]

[BUG] Coroutine 'Reddit.post' was never awaited while removing a post.

Describe the bug
Error while adding a removal reason to a submission.

To Reproduce

The code with which the issue can be reproduced.

await submission.mod.remove(reason=removal_reason)

Expected behavior
A removal reason should be added to the submission.

Environment

A clear and concise description of what your environment looks like.

  • OS: Windows
  • Python version: 3.7
  • aPRAW version: 0.6.7a0

[BUG]

Describe the bug

A clear and concise description of what the bug is.

Possible missing await

C:\Users\kvgk2\AppData\Local\Programs\Python\Python37-32\lib\site-packages\apraw\reddit.py:190: RuntimeWarning: coroutine 'sleep' was never awaited
  asyncio.sleep(wait_time)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

To Reproduce

The code with which the issue can be reproduced.

import apraw
import asyncio

# instantiate a `Reddit` instance
# you can also supply a key to an entry within a praw.ini
# file, making your login compatible with praw as well
reddit = apraw.Reddit(....)


async def scan_posts():
    # get an instance of a subreddit
    subreddit = await reddit.subreddit("aprawtest")

    # loop through new posts
    async for submission in subreddit.new():
        print(submission.title)


if __name__ == "__main__":
    # get the asyncio event loop
    loop = asyncio.get_event_loop()

    # add scan_posts() to the queue and run it
    loop.run_until_complete(scan_posts())

Expected behavior

A clear and concise description of what you expected to happen.

Noticed a Runtimewarning

Environment

A clear and concise description of what your environment looks like.

  • OS: Windows
  • Python version: 3.6
  • aPRAW version: [e.g. 0.2.0-alpha]

Additional context

Add any other context about the problem here.

Rewrite Tests

Rewrite tests for the PyUnit implementation and use the /r/aPRAWTest testing subreddit to test the endpoints.

Extract Endpoints

Extract all the used endpoints in a separate file and use f-strings for variables that need to be filled in later.

[ENDPOINT] /message/where

Endpoint name: `` [e.g. subreddit_wiki]

  • message_inbox
  • message_unread
  • message_sent

Endpoint path: `` [e.g. /r/subreddit/api/wiki]

  • /message/inbox
  • /message/unread
  • /message/sent

Expected model/function: `` [e.g. apraw.models.Submission.mod.delete()]

AuthenticatedUser.inbox(), unread() and sent().

Additional context

Add any other context about the endpoint here.

Use ListingGenerator or make async generator for @streamable decorator.

[ENHANCEMENT] Add Typing

Description
Add suggested types in return values of functions, as well as expected types in parameters for improved tooling in IDEs such as PyCharm and VSCode, as well as self-documenting code.

[FEATURE] The addition of .search() and multireddits

As we had discussed on Discord, I would appreciate if multireddits and .search() features were added to apraw. For reference, here is my code:

def redditeer(text,number):
    reddit = praw.Reddit(redacted) 
    all = await reddit.subreddit("technology+tech+futurology+engineering+army+navy+airforce+geek+military+scifi+science")
    topics_dict = { "Text":[], "Date":[],"Score":[],"Upvote_Ratio":[]}
    async for submission in all.search(text, limit = number):
        topics_dict["Text"].append(submission.title)
        topics_dict["Date"].append(submission.created_utc)
        topics_dict["Score"].append(submission.score)
        topics_dict["Upvote_Ratio"].append(submission.upvote_ratio)
    topics_data = pd.DataFrame(topics_dict)
    topics_data['Date'] = (pd.to_datetime(topics_data['Date'], unit='s'))
    listeforlabel = ['Reddit Thread'] * number
    dflisteforlabel = pd.Series(listeforlabel)
    upnewdf = pd.concat([topics_data, dflisteforlabel], axis=1)
    return upnewdf

Thank you so much!

[FEATURE] Add Support for Read-Only Mode

Describe the solution you'd like

A clear and concise description of what you want to happen.

Support to launch a Reddit instance in read-only mode with stronger ratelimits and no user features.

[ENDPOINT] Subreddit Wiki

Name of the endpoint
GET /wiki/page
GET /wiki/pages etc.
POST /api/wiki/edit
POST /api/wiki/hide etc.

Expected model/function
All the functions should be found under apraw.models.Subreddit.wiki, with the base class being callable to grab all wiki pages at once. i.e. (await reddit.subreddit("aprawtest").wiki() and wiki.edit().

Additional context
Follow PRAW's design in async. All API endpoints related to subreddit settings can be found here.

[ENHANCEMENT] ExponentialCounter Base Argument

Description

Describe the enhancement to be made to the codebase.

Allow the class ExponentialCounter's starting value/base to be defined as an argument in cases where the lowest needs to be higher than 1.

[ENHANCEMENT] CommentForrest and Support for MoreComments

Description

Describe the enhancement to be made to the codebase.

  • Add a class CommentForrest and class MoreComments.
  • Use class CommentForrest for Submission.comments and Comment.replies.
  • Make class CommentForrest streamable.
  • Add support for class MoreComments in class Listing.

[FEATURE] Support for Code Auth Flow

Describe the solution you'd like

A clear and concise description of what you want to happen.

Support for Reddit's code flow for installed apps via a callback URL.

[BUG] Fetching ModAction Mod

Describe the bug

A clear and concise description of what the bug is.

Attempting to fetch the moderator that performed a mod action results in the KeyError: 'data'. This is caused by a name clash with the mod() method.

To Reproduce

The code with which the issue can be reproduced.

mod = await mod_action.mod()

Expected behavior

A clear and concise description of what you expected to happen.

A Redditor who performed the mod action to be returned.

Additional context

Add any other context about the problem here.

2020-07-26 12:41:42,813 - banhammer - ERROR - Failed to retrieve item author in <ModAction id='ModAction_97112e6e-cf2c-11ea-a78e-0ab89574135a'>: 'data'

[BUG] KeyError 'success' When Sending Messages

Describe the bug

A clear and concise description of what the bug is.

Sending messages to Redditors and other models using the class MessageMixin results in the following traceback:

Traceback (most recent call last):
  File "D:\Programming\Mariavi\Reddify v2\venv\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
    ret = await coro(*args, **kwargs)
  File "d:\Programming\Mariavi\Reddify v2\cogs\user_cog.py", line 39, in verify
    await redditor.message("Account Ownership Confirmation",
  File "D:\Programming\Mariavi\Reddify v2\venv\lib\site-packages\apraw\models\reddit\redditor.py", line 198, in message
    return await self.reddit.message(self.name, subject, text, from_sr)
  File "D:\Programming\Mariavi\Reddify v2\venv\lib\site-packages\apraw\reddit.py", line 313, in message
    return resp["success"]
KeyError: 'success'

To Reproduce

The code with which the issue can be reproduced.

redditor = await self.reddit.redditor(user)
await redditor.message("Account Ownership Confirmation",
                                       f"Please reply to this message with 'verify' to confirm that you are Discord user '{ctx.message.author}'.")

Expected behavior

A clear and concise description of what you expected to happen.

No errors in the case of a successfully sent message, otherwise a concise exception thrown.

Environment

A clear and concise description of what your environment looks like.

  • OS: Windows 10 [e.g. Windows, Ubuntu]
  • Python version: 3.8.3 [e.g. 3.6, 3.8]
  • aPRAW version: 0.5.2-alpha [e.g. 0.2.0-alpha]

[BUG] Streamable Decorator With Parameters

Describe the bug

A clear and concise description of what the bug is.

Using the @streamable with parameters such as max_wait and attribute_name isn't possible.

To Reproduce

The code with which the issue can be reproduced.

@streamable(max_wait=12)
async def async_generator():
    for i in items:
        yield i

Expected behavior

A clear and concise description of what you expected to happen.

The function to become a class streamable and be able to stream with a maximum wait time of 12 seconds.

Create aPRAWBase Class

Add an aPRAWBase class used in all the Reddit models such as comment, subreddit, submission etc. as logic such as the dynamic setvars is being reused. Also allows for better tooling if type-hinting is used.

[ENDPOINT] Comment Replies

Name of the endpoint
No clear endpoint, just use the full data of a comment from /{submission}/_/{comment}.json.

Expected model/function
apraw.models.Comment.replies()

[ENDPOINT] Quarantine Opt In/Out

Name of the endpoint
/api/quarantine_optin
/api/quarantine_optout

Expected model/function
apraw.models.Subreddit.quaran.opt_in() or opt_out().

[ENDPOINT] Subreddit Settings

Name of the endpoint
GET /r/{subreddit}/about
POST /r/{subreddit}/api/delete_sr_banner, /r/{subreddit}/api/delete_sr_header etc.

Expected model/function
Functions found in apraw.models.subreddits.SubredditModeration. settings() to view subreddit's settings, and sub functions to edit them.

Additional context Add any other context about the endpoint here.
Follow PRAW's design in async. All API endpoints related to subreddit settings can be found here.

[BUG] Reddit.redditor was never awaited in Comment

Describe the bug

A clear and concise description of what the bug is.

Attempting to access author() in class Comment seems to fail caused by ReactivePy.

To Reproduce

The code with which the issue can be reproduced.

comment = await reddit.comment("fuoew5r")
author= await comment.author()

>>> D:\Programming\Python\Discord\GTA Online\LesterCrestBot\venv\lib\site-packages\reactive\owner.py:16: RuntimeWarning: coroutine 'Reddit.redditor' was never awaited
  if hasattr(obj, '__get__'):

Expected behavior

A clear and concise description of what you expected to happen.

The class Redditor to be returned.

Environment

A clear and concise description of what your environment looks like.

  • OS: Windows [e.g. Windows, Ubuntu]
  • Python version: 3.8 [e.g. 3.6, 3.8]
  • aPRAW version: 0.6.6-alpha [e.g. 0.2.0-alpha]

[FEATURE] Add Support to Mute, Archive and Reply to Modmail.

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I'm always frustrated when Banhammer.py requires features that aPRAW does not support yet.

Describe the solution you'd like

A clear and concise description of what you want to happen.

await conversation.archive(), await conversation.mute() and await conversation.reply(REPLY) respectively need to be implemented and perform the functions according to their name.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Using PRAW.

Additional context

Add any other context or screenshots about the feature request here.

if isinstance(item.item, (ModmailConversation, ModmailMessage)):
    conversation = item.item.conversation if isinstance(item, ModmailMessage) else item.item
    if reaction.archive:
        await conversation.archive()
        payload.actions.append("archived")
    if reaction.mute:
        await conversation.mute()
        payload.actions.append("muted")
    if reaction.reply != "":
        await conversation.reply(reaction.reply)
        payload.actions.append("replied to")
    return payload

[TESTS] apraw.Reddit

The feature this tests covers.
apraw.Reddit.comment(), apraw.Reddit.submission() etc.

Type of tests.
Missing unit tests.

Mock/real data to be fed to the tests.

Describe the data in JSON or submit URLs from /r/aPRAWTest.

See data in from this post.

Expected results, describe what's expected of a feature.
Return mock objects with similar values as seen in the post, to mirror the integration tests.

[BUG] Fetching Submissions and Comments by URL

Describe the bug

A clear and concise description of what the bug is.

Fetching comments and submissions by URL results in varied errors depending on the usage. As comments use the internal fetch() method to retrieve the data, it will fail since RequestHandler.get() doesn't support an argument for URLs. Submissions use the info() endpoint which does not support direct URLs. Those need to be switched to using the internal fetch() method.

To Reproduce

The code with which the issue can be reproduced.

item = await reddit.comment(url=url)
item = await reddit.submission(url=url)

Expected behavior

A clear and concise description of what you expected to happen.

The methods should return class Submission or class Comment respectively.

Environment

A clear and concise description of what your environment looks like.

  • OS: Windows [e.g. Windows, Ubuntu]
  • Python version: Python 3.8 [e.g. 3.6, 3.8]
  • aPRAW version: 0.6.3-alpha [e.g. 0.2.0-alpha]

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.