Coder Social home page Coder Social logo

mat-1 / repl-talk-api Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 6.0 216 KB

Allows you to do various things with the slightly unofficial Repl.it Repl Talk API

Home Page: https://pypi.org/project/repltalk/

License: MIT License

Python 100.00%
repl-talk replit

repl-talk-api's Issues

get_comments() not working as expected

The get_comments() function for a user object doesn't work and returns a Traceback error stating that 'type' object is not iterable.

Traceback:

  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/__init__.py", line 814, in get_comments
    _comments = await client._get_user_comments(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/__init__.py", line 1182, in _get_user_comments
    return await self.perform_graphql(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/__init__.py", line 966, in perform_graphql
    'query': str(query)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 89, in __str__
    output = 'query ' + str(self.field)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 67, in __str__
    value = builtin_to_graphql(value)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 7, in builtin_to_graphql
    value = str(item)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 72, in __str__
    output += str(value)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 53, in __str__
    output += str(item)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 72, in __str__
    output += str(value)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 67, in __str__
    value = builtin_to_graphql(value)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 7, in builtin_to_graphql
    value = str(item)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/graphql.py", line 65, in __str__
    for field in item:
TypeError: 'type' object is not iterable

Code snippet that led to error:

replit = repltalk.Client()
try:
	user = await replit.get_user(name)
	posts = await user.get_posts(limit=5, order='new')
	comments = await user.get_posts(limit=5, order='new')
except Exception as e:
        print(e)

Repl Spotlight/Apps Support

Add support for

  • Reading/writing comments on spotlight

  • Reading/adding reactions on spotlight

  • Getting repl description, maybe cover image

  • Read hashtags on spotlight

  • View all repls in a specific topic (hashtag)

  • Get the list of "Replit Picks"

Also will whitelisted_bots be fixed?

get_user failing

I had this code working for some time to get the avatar of the repl owner (for which my repl is running in)

from repltalk import Client
import asyncio


async def get_repl_avatar(user_name):
    user = await Client().get_user(user_name)
    return user.avatar


def main():
    # replit avatar
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    global repl_avatar
    repl_avatar = loop.run_until_complete(get_repl_avatar(os.environ['REPL_OWNER']))

Essentially await Client().get_user(user_name) never completes.

Today it stopped working. Any idea why or do know a better way to get the avatar url?

Error in get_all_comments()

I have the code:

import repltalk, asyncio

client = repltalk.Client()

async def getComments():
	for comment in await client.get_all_comments(order='new'):
		print(comment)

print(asyncio.run(getComments()))

And when i run it, I get the error:

Traceback (most recent call last):
  File "main.py", line 9, in <module>
    print(asyncio.run(getComments()))
  File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "main.py", line 6, in getComments
    for comment in await client.get_all_comments(order='new'):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/repltalk/__init__.py", line 1232
, in get_all_comments
    for c in _comments['items']:
TypeError: list indices must be integers or slices, not str

I don't know if I am just doing it wrong or it is an error on your end. Can you have a look please.

get_reports() ReportList not getting reset before loop

When doing async for report in await client.get_reports(resolved=False): multiple times, the get_reports() does not reset its list of reports for each loop, this results in an outdated and duplicated reports list being returned.

This is what I'm talking about:
image
As you can see, for each loop, the length of the list being returned by get_reports() increases by 4 (the number of actual unresolved reports). Btw the lst variable is getting reset correctly each loop.

docstring + type hinting

Add doc strings + type hinting,

I can do this sometime

REEEEEE

checklist:

  • docstring main classes + functions
  • add type hinting
  • add docstring to custom exceptions

Support for the AMA board

Even though it isn't known if the AMA board will stay up/active forever, it would be nice for it to be accessible through the API.

Feature Request: Get Upvotes On Post

Feature Request: Get Upvotes On Post

So, this isn't an issue more like a feature request. There should be a async function on posts to get the people that upvoted the post and it should return like an array of people that upvoted. I will try to make a pull request for this if I can get it to work but do you think you can add this to the repl-talk-api? @mat-1

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.