Automate Replit

Automate replit

is an async api wrapper for replit. It currently features:

  • A working replit client
  • A User object wrapper
  • A Presence update function
  • Basic notification collection
  • A raw gql interface

Installation

pip install automate-replit -U

Docs

Docs can be found here

Examples

The ethan getter:

from autoreplit import ReplitClient

client = ReplitClient()

async def getEthan():
    ethan = await client.getUserByName("not-ethan")
    print(f"Ethan's id: {ethan.id}")
    print(f"Ethan's follower count: {ethan.followerCount}")
    if ethan.isOnline:
        print("Ethan is online!")
    else:
        print(f"Ethan was last seen {ethan.lastSeen}")
    print(f"Ethan's roles: {ethan.roles}")
    print(f"All of ethan: {ethan}")

client.run(getEthan())

And, because it is async, it also works with discord.py:

from discord.ext import commands
import discord
from autoreplit import ReplitClient
from os import getenv

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix=commands.when_mentioned_or("mybot"), intents=intents)
client = ReplitClient(getenv("sid"))

@bot.event
async def on_ready():
    await client.start()

@bot.event
async def on_close():
    await client.close()

bot.run(getenv("TOKEN"))

A full discord.py bot example can be found here

Feedback

Feedback is very much appreciated, but here are some notes

  • Queries will be prioritized over mutations
  • I am already planning on making an easy comment bot module
  • I am already planning on wrapping repl getting
4 Likes

mmm, I already made a comment bot module so please don’t :sob:

1 Like

Is it async tho? Also pls link it.

it’s replit-bot and I’m gonna try to make it async but it’s not at the moment

1 Like

Flask is to make an auto gen doc

1 Like

Wow, it has been a long time since i have posted a update here, but I decided to come back to the project.

Version 0.1.4

Includes a repl API: Replit Projects - automate-replit 0.1 documentation
Includes a half unfinished notification wrapper: Notifications - automate-replit 0.1 documentation

What’s next?

Well, It is kind of pain to wrap all these API’s, and the method I am using right now is relatively inefficient. This means, I will be completely re-working the structure in 0.2.0, and deprecating the 0.1.0.

What this means for 0.1

Plans for 0.2.0

The client core will be the same, but I will completely re-work the wrapper to use graphql to it’s fullest. It will only get you what you want and what you need, the docs essentially being your schema, and you write python instead of graphql. I am also planning on making a tool (schemagen) that will write the wrappers for me :slight_smile:

Hope you guys enjoy the lib!

3 Likes

Wait, so you can automate a Replit client?

2 Likes

I think they mean API wrapper, but correct me if I’m wrong.

Yes, it is a automatic replit client w/ an api wrapper. They are kind of the same thing, but api wrapper specifies that I made the graphql stuff easier to use by “wrapping” it in python, and the client suggests it sends working requests to replit.

1 Like

Is there a way to find out how many people have viewed your Repl? (And thus limit it from running so as to save Egress and make a visitor-counter)

pip install git+https://github.com/thatrandomperson5/automate-replit

Does not work, use pip install automate-replit instead.

1 Like

Does run work? run count docs

Unless the people are running your repl, no egress should be consumed afaik.

9 posts were split to a new topic: Camel Case vs Snake case

@OmegaOrbitals just tested and it installs fine using git. The only hurtle is that replit’s git version was outdated, causing a GLIB_C error. (Ig you pretty much expect replit to be outdated in some parts)
You would fix this by adding pkgs.git to replit.nix

Woah, that’s nice. I wish this was on Node.js. BTW nice job!

The first ever replit graphql lib that almost all the others were based off was made in node, so…
(Also, if you know me, you will know I am not a node.js person)

@doxr: replapi-it - npm

lastSeen returns None even if the user is offline.

Did you read the note in the docs?

Always None if no SID is provided.

(The docs for User are actually good, the ones for repl are not)

2 Likes