Code Monkey home page Code Monkey logo

replit-bot's Introduction

copied from replapi-it from PikachB2005 since this is just the python implmentation (changed examples)

At the moment, you cannot do repl interactions with this


Replit's API is constantly changing, which means this will as well. I will try to keep it easy to use but be aware that your project may stop working at any point.


Install

pip install replit-bot

Usage

Main API

import os
from replit_bot import Bot, Param

bot = Bot(os.environ["TOKEN"]) # add secret TOKEN

# your code here

bot.run()

or

import os
from replit_bot import Bot, Param

bot = Bot()

# your code here

bot.run(os.environ["TOKEN"]) # add secret TOKEN

If you don't know how to find your connect.sid cookie, look here

Example

Logs the number of followers a user has

import os
from replit_bot import Client

client = Client(os.environ["TOKEN"])

def func(*args, **kwargs):
    user = client.users.fetch("bigminiboss")
    print(user.followerCount)

client.on("ready", func)

Client

  • <Client>.user: a CurrentUser object of the logged in user
  • <Client>.repl: a Repl object of the current repl, if any
  • <Client>.users: a UserManager object
  • <Client>.repls: a ReplManager object
  • <Client>.posts: a PostManager object
  • <Client>.comments: a CommentManager object
  • <Client>.on('notification', callback): notifications event listener * callback: a callback function

Bot

  • Bot is a super set of client able to preform all functions. Any application with Client class could replace it with the Bot class and have it function the same

User

  • <User>.repls: a ReplManager object
  • <User>.followers: a FollowerManager object
  • <User>.follows: a FollowingManager object
  • <User>.posts: a PostManager object
  • <User>.id: the user's id
  • <User>.username: the user's username
  • <User>.firstName: the user's first name
  • <User>.lastName: the user's last name
  • <User>.locale: the user's language
  • <User>.isVerified: if the user is verified or not
  • <User>.displayName: the user's display name
  • <User>.fullName: the user's full name
  • <User>.url: the url to the user's profile
  • <User>.bio: the user's bio
  • <User>.socials: the user's social media urls
  • <User>.roles: the user's roles
  • <User>.isFollowedByCurrentUser: if you are following the user
  • <User>.isFollowingCurrentUser: if you're following the user
  • <User>.isBlockedByCurrentUser: if you've blocked the user
  • <User>.isBlockingCurrentUser: if the user blocked you
  • <User>.isLoggedIn: if the user is logged in (<User>.isOnline is recommended)
  • <User>.isSubscribed: no clue
  • <User>.followerCount: how many followers the user has
  • <User>.followCount: how many people the user is following
  • <User>.isHacker: if the user has Hacker plan
  • <User>.image: the url to the user's profile picture
  • <User>.coverImage: the url and offset to the user's profile banner image
  • <User>.timeCreated: when the user's account was created
  • <User>.lastSeen: when the user was last online
  • <User>.isOnline: if the user is online
  • <User>.setFollowing(boolean): follow or unfollow the user
  • <User>.setBlocking(boolean): block or unblock the user

CurrentUser

Also contains most User properties and methods, excluding follow / block values

  • <CurrentUser>.notifications: a NotificationManager object
  • <CurrentUser>.email: the user's email
  • <CurrentUser>.emailNotifications: if the user should be emailed notifications
  • <CurrentUser>.hasRepl: if the user has any repls
  • <CurrentUser>.hasPrivacyRole: no clue
  • <CurrentUser>.warnings: any warnings the user has recieved
  • <CurrentUser>.isBannedFromBoards: if the user is banned from boards
  • <CurrentUser>.canUpdateEmail: if the user can change their email
  • <CurrentUser>.canUpdateUsername: if the user can change their username
  • <CurrentUser>.device: if the user is using a mobile or mac device
  • <CurrentUser>.sidebarClosed: if the user's sidebar is closed
  • <CurrentUser>.hasProfileImage: if the user has a profile image
  • <CurrentUser>.socialSignup: no clue
  • <CurrentUser>.githubInfo: the user's github info
  • <CurrentUser>.usernameRepl: the user's repl whose title matches their username
  • <CurrentUser>.daysSinceSignup: how many days since the user signed up
  • <CurrentUser>.storage: the user's storage limit and usage
  • <CurrentUser>.editorPreferences: the user's editor preferences
  • <CurrentUser>.countryCode: the user's country code
  • <CurrentUser>.auth: google / github / facebook auth
  • <CurrentUser>.change(options): updates the current user's settings
    • options:
      • image: a path to an image file to set your profile picture
      • firstName: changes your first name
      • lastName: changes your last name
      • bio: changes your bio
      • emailNotifications: if you should recieve email notifications

Repl

  • <Repl>.threads: a list of Thread objects
  • <Repl>.multiplayers: a MultiplayerManager object
  • <Repl>.comments: a CommentManager object
  • <Repl>.id: the repl's id
  • <Repl>.isProject: no clue
  • <Repl>.isPrivate: if the repl is private
  • <Repl>.isStarred: if the repl is starred
  • <Repl>.title: the repl's title
  • <Repl>.slug: the repl's title slug
  • <Repl>.imageUrl: the url to the repl's image
  • <Repl>.folderId: the folder the repl is in
  • <Repl>.isRenamed: if the repl is renamed
  • <Repl>.commentCount: how many comments the user has
  • <Repl>.likeCount: how many likes the repl has
  • <Repl>.currentUserDidLike: if you liked the repl
  • <Repl>.templateCategory: the category of the template used to create the repl
  • <Repl>.wasPosted: if the repl was posted
  • <Repl>.wasPublished: if the repl was published
  • <Repl>.language: the id of the repl's language (you're probably looking for <Repl>.templateInfo.label)
  • <Repl>.lang: the repls language (you're probably looking for <Repl>.templateInfo.label)
  • <Repl>.iconUrl: the url of the repl's icon
  • <Repl>.templateLabel: label of the repl's template repl
  • <Repl>.url: the repl's url
  • <Repl>.inviteUrl: the url to invite users to the repl
  • <Repl>.multiplayerInvites: invites to the repl
  • <Repl>.historyUrl: the repl's history url
  • <Repl>.analyticsUrl: the repl's analytics url
  • <Repl>.rootOriginReplUrl: the url to the repl's origin repl
  • <Repl>.isOwner: if you are the owner of the repl
  • <Repl>.config: the repl's config data
  • <Repl>.pinnedToProfile: if the repl is pinned to your profile
  • <Repl>.sizeMB: the repl's size, in megabytes.
  • <Repl>.hostedUrl: the repl's hosted url, used for iframes
  • <Repl>.terminalUrl: the repl's terminal url
  • <Repl>.database: data about the repl's database
  • <Repl>.template: the repl's template
  • <Repl>.isProjectFork: if the repl is a fork
  • <Repl>.publicForkCount: how many public forks the repl has
  • <Repl>.runCount: how many times the repl has been run
  • <Repl>.isAlwaysOn: if the repl is always on
  • <Repl>.isBoosted: if the repl is boosted
  • <Repl>.tags: the repl's tags
  • <Repl>.lastPublishedAt: when the repl was last published
  • <Repl>.multiplayers: a <Collection> of User objects of people invited to the repl
  • <Repl>.nixedLanguage: if the repl was nixed
  • <Repl>.publishedAs: no clue
  • <Repl>.attachments: no clue
  • <Repl>.description: the repl's description
  • <Repl>.markdownDescription: the repl's description, with markdown
  • <Repl>.hasExplainCode: if the repl has explain code
  • <Repl>.hasGenerateCode: if the repl has generate code
  • <Repl>.templateInfo: info about the repl's template
  • <Repl>.domains: no clue
  • <Repl>.apexProxy: the ip of the repl's apex proxy
  • <Repl>.replViewSettings: the repl's view settings
  • <Repl>.powerUpCosts: the repl's power up costs
  • <Repl>.isTutorial:if the repl is a tutorial
  • <Repl>.owner: a User object of the repl's owner
  • <Repl>.timeCreated: when the repl was created
  • <Repl>.timeUpdated: when the repl was updated
  • <Repl>.currentUserPermissions: your permissions for the repl
  • <Repl>.fetchThreads(options): returns the repls'd threads
  • <Repl>.database: A Repl Database object
  • <Repl>.fork(options): forks the repl
    • options:
      • cache: cache the result(s). default: true
      • title: the repl's title
      • description: the repl's description
      • isPrivate: if the repl should be private
  • <Repl>.delete(): deletes the repl
  • <Repl>.change(options): updates the repl
    • options:
      • title: the repl's title
      • description: the repl's description
      • isPrivate: if the repl should be private
  • <Repl>.comment(body): comments on the repl
  • <Repl>.connect(): Connect to the repl The following require you to be connected to the repl:
  • <Repl>.env: the repl's environmental variables (secrets)
  • <Repl>.files: a FileManager object
  • <Repl>.console: a Console object
  • <Repl>.disconnect(): disconnects from the repl

UserManager

  • <Usermanager>.cache: a Collection of User objects
  • <Usermanager>.fetch(userResolvable, options): a Promise of a User object
    • userResolvable: A username, id, or User
    • options:
      • force: doesn't check the cache. default: false
      • cache: cache the result(s). default: true
  • <Usermanager>.search(query, options): a Collection of User objects
    • query: what to search
    • options:
      • cache: cache the result(s). default: true
    • limit: the maximum number of results. default: 10

ReplManager

  • <Replmanager>.cache: a Collection of Repl objects
  • <Client>.<Replmanager>.fetch(replResolvable, options): a User object
    • replResolvable: A url, id, or Repl
    • options:
      • force: doesn't check the cache. default: false
      • cache: cache the result(s). default: true
  • <Replmanager>.generateTitle(): a randomly generated repl title
  • <Client>.<ReplManager>.create(options): creates a new repl
    • options:
      • title: the repl's title
    • description: the repl's description
    • language: the repl's language
      • isPrivate: if the repl is private

Collection

A Map object with extra methods. Meant to be like discord.js's Collection

PostManager

  • <PostManager>.cache a Collection
  • <PostManager>.trending(options): a Collection of trending posts
    • options:
      • force: doesn't check the cache. default: false
      • cache: cache the result(s). default: true
      • limit: the maximum number of results
      • tags: tags included in the results

CommentManager

  • <Client>.<CommentManager>.fetch(commentResolvable, options): returns a Comment object
    • commentResolvable: a comment id
    • options:
      • cache: cache the result(s). default: true
  • <Repl>.<CommentManager>.fetch(options): returns a Collection of Comment objects
    • options:
      • cache: cache the result(s). default: true
      • limit: the maximum number of results
  • <User>.<CommentManager>.fetch(options): returns a Collection of Comment objects
    • options:
      • cache: cache the result(s). default: true
      • limit: the maximum number of results

Post

  • <Post>.id: the post's id
  • <Post>.title: the post's title
  • <Post>.commentCount: how many replies the post has
  • <Post>.body: the body of the post
  • <Post>.user: a User object
  • <Post>.repl: a Repl object
  • <Post>.comment: a Comment object
  • <Post>.timeCreated: when the post was created
  • <Post>.timeUpdated: when the post was last updated

Comment

  • <Comment>.comments: an array of Comment objects
  • <Comment>.id: the comment's id
  • <Comment>.body: the comment's body
  • <Comment>.bodyNoMarkdown: the comment's body without markdown
  • <Comment>.curretUserPermissions: your current permissions for the comment
  • <Comment>.timeCreated: when the comment was created
  • <Comment>.timeUpdated: when the comment was last updated
  • <Comment>.user: a User object
  • <Comment>.repl: a Repl object
  • <Comment>.reply(body): reply to the comment

FollowerManager

  • <FollowerManager>.fetch(options): a Collection of User objects
    • options:
      • cache: cache the result(s). default: true
      • limit: the maximum number of results

FollowingManager

  • <FollowingManager>.fetch(options): a Collection of User objects
    • options:
      • cache: cache the result(s). default: true
      • limit: the maximum number of results
  • <FollowingManager>.events: a UserEventManager

MultiplayerManager

  • <MultiplayerManager>.cache: a Collection of User objects
  • <MultiplayerManager>.invite(userResolvable): invite a user to the repl
  • <MultiplayerManager>.remove(userResolvable): remove a user from the repl

FileManager

  • <FileManager>.persisting: if the manager is currently persisting
  • <FileManager>.read(path): returns the contents of a file
  • <FileManager>.write(path, content): writes to a file
  • <FileManager>.mkdir(path): makes a directory
  • <FileManager>.remove(path): removes a file / directory
  • <FileManager>.move(oldPath, newPath): moves a file/directory
  • <FileManager>.readdir(path): get an array of files in a directory
  • <FileManager>.recursedir(path): get an array of recursed files in a directory
  • <FileManager>.presist(): makes the files update when edited
  • <FileManager>.snapshot(): updates the files to what they are currently

Console

  • <Console>.send(input): sends something to the console
  • <Console>.run(): runs the repl
  • <Console>.stop(): stops the repl

UserEventManager

  • <UserEventManager>.cache: a Collection of UserEvent objects
  • <UserEventManager>.fetch(options): a Collection of UserEvent objects
    • options:
      • cache: cache the result(s). default: true
      • limit: the maximum number of results

UserEvent

  • <UserEvent>.id: the id of the event
  • <UserEvent>.eventType: the type of the event
  • <UserEvent>.post: a Post object
  • <UserEvent>.timeUpdated: when the event was last updated
  • <UserEvent>.user: a User object
  • <UserEvent>.repl: a Repl object
  • <UserEvent>.comment: a Comment object

NotificationManager

  • <NotificationManager>.cache: a Collection of Notification objects
  • <NotificationManager>.fetch(options): a Collection of Notification objects
    • options:
      • cache: cache the result(s). default: true
      • limit: the maximum number of results
      • seen: if the notifications have been seen or not. default: false
  • <NotificationManager>.markAsRead(): marks your notifications as read
  • <NotificationManager>.startEvents(): starts sending notification events for new notifications
  • <NotificationManager>.stopEvents(): stops the sending of notification events

replit-bot's People

Contributors

bigminiboss avatar f1repup650 avatar thatrandomperson5 avatar

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.