A library to simplify the https://photop.live REST api.

Overview

Photop.js

Thanks a lot to stalicites (qa#1337) for writing the documentation...


Photop.js is a library created by IMPixel, and used to accomplish creating bots on [Photop](https://photop.live)
The library is written in Javascript and only supports Javascript currently.

This documentation requires knowledge of async functions. If you don't know what those are, read up on them here

Initializing a bot instance

Initializing a bot instance requires account credentials, i.e a username and password

const session = await signIn(process.env["username"], process.env["password"])

Note that a sign in only supports a username and password. An account token is not allowed.

The signIn function returns a user session, which can then be used to peform certain actions on Photop as the bot.

Creating a post

After initializing your bot instance, you can perform actions on Photop as the bot.
Creating a post is as simple as:

session.createPost(postText, attachedImages)
// postText is the text content of the post
// attachedImages is an array of readable streams, each representing an attachment.

Listening to new posts

To listen to posts, you need to import appendEventListener from the library.

import { appendEventListener } from "photop.js"

After you've imported appendEventListener:

appendEventListener("newPost", (post) => {
    console.log("A new post!")
    // You can access the new post via the post object passed through the function.
    // The post object is an instance from the post class.  
})

To get the post data:

appendEventListener("newPost", async (post) => {
    console.log("A new post!")
    let postData = await post.getData();
    /*
    postData returns:
    {
        id: The ID of the post,
        userId: The user ID of the author of the post,
        text: The text content of the post,
        timestamp: The creation date of the post,
    }
    */
})

Modifying posts

To like post, run post.like(), and to unlike a post, run post.unlike() on a post instance.
To send a chat:

await post.sendChat(textContent, replyID)

The first parameter (textContent) is required, and represents the content of the chat.
The second parameter (replyID) is optional, but if provided, should represent an ID of the chat being replied to.


To report a post:
await post.report(reason, desc)

A reason is required, but a description is optional.
The reason must be any of:

Inappropriate Content
Inappropriate Username
Threats or Endangerment
Hate Speech, Harassment, or Abuse
Evading Bans, Mutes, or Blocks
Spamming
Spreading Rumors or False Information
Posting Malicious Content or Links
May be Inflicting Physical Harm
Other

Listening to a post for chats:

// This code has the bot reply "purr" to every chat whenever someone says "meow" in a post. 
// Please don't actually make a bot like this
appendEventListener("newPost", (post) => {
    let postData = await post.getData();  
    if (postData.text == "meow") {
        // connect to the post
        post.onChat((chat) => {
            post.sendChat("purr", chat.id); // replies to every chat with purr
        });
     }
})
You might also like...

Simplify the installation of a Silverstripe Dev Environment.

silverstripe docker starter Simplify the installation of a Silverstripe Dev Environment. The silverstripe docker starter is based on the silverstripe/

Jul 7, 2022

A command line application to simplify the git workflow on committing, pushing and others commands.

Git-Suite A command line application to simplify the git workflow on committing, pushing and others commands. Prerequisites Install Node Package Manag

Aug 10, 2022

Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Dec 24, 2022

Webb-tracker-api - James Webb Space Telescope (JWST) tracking REST API

Webb-tracker-api - James Webb Space Telescope (JWST) tracking REST API

James Webb Telescope tracking REST API Public REST API to track JWST's current status API data source: https://www.jwst.nasa.gov/content/webbLaunch/wh

Nov 22, 2022

Lolis-rest - RESTful API for lolis-api

Lolis REST RESTful + Website for Lolis API. Introduction This is a RESTful API which will be used on Lolis API Website and Wrapper. This API uses Imgu

Aug 11, 2022

A base API template for a REST API using express.

A base API template for a REST API using express.

express-api-template A base API template for a REST API using express. Philosophy Setting up a new project can be a long and tedious process, especial

May 29, 2022

An Amazon Kendra REST API CDK example with an API Gateway, including authentication with AWS Cognito and AWS X-Ray Tracing

An Amazon Kendra REST API CDK example with an API Gateway, including authentication with AWS Cognito and AWS X-Ray Tracing

Amazon Kendra Web Service CDK Sample Amazon Kendra has a robust JSON API for use with the AWS SDK (software development kit), but does not expose endp

Nov 28, 2022

Deno client library for Bitwarden CLI's local REST API.

Bweno Think outside the bun 🌮 Bweno is a client library for Bitwarden CLI's local REST API. Pronounced as Spanish 'bueno', meaning 'good'. Requiremen

May 26, 2022

https://www.captchaai.io/ - simple captchaai API (next 2captcha) tasks handler for node

captchaai.io api 🧠 task handler Want you to get captcha verified tokens with a simple function call in you node application? Just install axios and r

Dec 9, 2022
Owner
null
The Remix version of the fakebooks app demonstrated on https://remix.run. Check out the CRA version: https://github.com/kentcdodds/fakebooks-cra

Remix Fakebooks App This is a (very) simple implementation of the fakebooks mock app demonstrated on remix.run. There is no database, but there is an

Kent C. Dodds 61 Dec 22, 2022
nest연습용 (w. https://github.com/seuiggi, https://github.com/okysky1121)

A progressive Node.js framework for building efficient and scalable server-side applications. Description Nest framework TypeScript starter repository

이름 2 Oct 5, 2022
'event-driven' library aims to simplify building backends in an event driven style

'event-driven' library aims to simplify building backends in an event driven style(event driven architecture). For message broker, light weight Redis Stream is used and for event store, the well known NoSQL database, MongoDB, is used.

Sihoon Kim 11 Jan 4, 2023
Wen? Now! A library to simplify your Web3 data fetching.

Wen Connect? Now! Minimalistic library for Web3 user interfaces. Seamless connection flows to Metamask. Stateless sessions that work anywhere (client,

Guillaume Bibeau-laviolette 20 Jul 20, 2022
LunaSec - Open Source Security Software built by Security Engineers. Scan your dependencies for Log4Shell, or add Data Tokenization to prevent data leaks. Try our live Tokenizer demo: https://app.lunasec.dev

Our Software We're a team of Security Engineers on a mission to make awesome Open Source Application Security tooling. It all lives in this repo. Here

LunaSec 1.2k Jan 7, 2023
A tool to simplify importing custom assets in Minecraft

BAMO - Block And Move On A tool to simplify importing custom assets in Minecraft Currently only allows you to quickly prototype models in-game, but fu

Tom Mudway 3 Jul 15, 2022
A browser extension to simplify web pages and hide distracting things like hide cookie banners, auto-playing videos, sidebars, etc

Unclutter Browser Extension A browser extension to simplify web pages and hide distracting things like hide cookie banners, auto-playing videos, sideb

null 849 Jan 9, 2023
It's a javascript Class which contains utility methods that simplify working with google maps web SDK

About GoogleMapsJSHelper It's a javascript Class which contains utility methods that simplify working with google maps web SDK Note: i used ES7 Class

Sami Alateya 6 Jul 23, 2022
🛫 TypeScript Starter template to simplify creating your next npm package.

TypeScript Starter Kit This is an opinionated TypeScript Starter kit to help kick-start development of your next npm package. ?? Get Started Luckily,

Open Web 7 Sep 27, 2022
🛫 TypeScript Starter template to simplify creating your next npm package.

TypeScript Starter Kit This is an opinionated TypeScript Starter kit to help kick-start development of your next npm package. ?? Get Started Luckily,

Open Web Foundation 5 May 19, 2022