Giter Site home page Giter Site logo

engineerisaac / discord2vrc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from acertainbluecat/discord2vrc

0.0 1.0 0.0 158 KB

Discord bot and Web server for dynamically loading images uploaded to discord into VRChat worlds.

Home Page: https://discord2vrc.nyanpa.su/docs

License: MIT License

Python 100.00%

discord2vrc's Introduction

Discord2VRC

A simple Discord bot and a web server that allows you to load images that have been uploaded to select discord channels into VRChat worlds directly.

As this was primarily a project I started for personal use, the way it has been set up is mainly catered to what was convenient for me, which may not neccessarily be the case for others. I may not have used the best practices for the sake of convenience, so keep that in mind if you are interested in using this.

If you're looking for a simple drag and drop prefab please be aware that this is not one of them and requires some technical knowledge as well as your own server to set this up on.

This is only for SDK2 worlds for now until Udon receives support for loading remote images. Once that happens I will likely make proper Udon slideshow prefabs that make full use of the web endpoints. The provided sdk2 prefab is just a minimal example.

demo

Requirements

MongoDB

Python 3.7+

Discord Bot Permissions

  • Send Messages
  • Manage Messages
  • Read Message History
  • Add Reactions
  • View Channels

Installation

Make sure python 3.7+ and MongoDB are installed first

git clone https://github.com/acertainbluecat/Discord2VRC.git
cd Discord2VRC
python3 -m pip install -r requirements.txt
cd app

Fill up config.ini with the relevant information before running

python3 migrate.py

Create a placeholder.png and put it in your static dir or use the one from app/static (Used to display when VRC endpoints return a 404)

Start the bot and web server

python3 bot.py
uvicorn web:app --port 80

Ideally, consider running behind nginx with gunicorn to manage uvicorn workers

How to use

The bot is currently configured to only listen to owners defined in config.ini.
I may in future add a simple ACL to replace this behaviour instead.

Invite the bot to your discord server.
Use the following command in the respective channel to subscribe to it.

!subscribe [alias]

Where [alias] is an optional parameter, if omitted the alias will be set to the channel name. The alias is used to load images specifically from this channel from the web url endpoints. The bot will now listen to the channel and upload image attachments posted. Images uploaded will be converted to jpg with quality at 80.

To upload images that were posted before, call the following command in the respective channel.

!rescan [limit]

Where [limit] is an optional parameter, refers to how many messages back the bot will check for images. Defaults to 100, adjust as neccessary, though higher numbers will take longer.

To clear images from a respective channel.

!purge

Will mark all images in the channel as deleted, and they will not show up in the vrc web endpoints, but will still be returned in the api.

You can use these 2 commands to manage what images you want to be returned by the web endpoints by purging, editing/deleting images in the channel as desired and rescanning. I may in future add more granular commands for management of images.

The provided unitypackage for sdk2 uses vrc_panorama to load remote images. In it are 2 sample prefabs that are currently set to load sample endpoints I have set up for demonstration purposes that loads the latest image and a randomly selected pseudo sync'd image that can be dynamically reloaded at runtime. Replace the domain name in the urls with your own.

For details on available web endpoints and other bot commands see below.

Web server

API Documentation: https://discord2vrc.nyanpa.su/docs

Feel free to play around with the sample web app I have set up above to see how the web end points work. There are 2 channel "aliases" set up "vrchat" and "ffxiv".

The VRC endpoints are to be used for vrchat and will return a single image. They can be used with vrc_panorama on sdk2 to load images dynamically as they are reloaded by respawning the vrc_panorama prefab. As the endpoints redirect instead of returning images directly, there shouldnt be an issue with caching.

Of note, the randomsync endpoints will return a random image using the current server time based on intervals. That means reloading the image in vrchat should show the same random image to everyone in the instance as long as they load it at the same time for the most part.

This can be used to create a slideshow prefab that is sync'd for everyone, but ideally wait for Udon support for remote images due to sdk2 limitations that might make this unfeasible on sdk2.

Discord bot

Commands are as follows

Admin:
  clear       clear channel of bot messages,
  extensions  Shows extensions available and loaded
  load        Load extension, eg. !load image
  ping        Ping!
  quit        Tells bot to quit
  reload      Reload extension, eg. !reload image
  unload      Unload extension, eg. !unload image
Image:
  alias       Sets an alias for current channel's subscription
  purge       Soft deletes all images downloaded from this channel
  reactclear  Clear bot reactions from this channel,
  rescan      Rescans current channel for images if it is subscribed
  status      Shows current channels subscription status
  subscribe   Subscribe current channel for image crawling
  unsubscribe Unsubscribe current channel for image crawling
No Category:
  help        Shows this message

Type !help command for more info on a command.
You can also type `help category for more info on a category.

Use help on specific commands for more information

Todo

  • Udon slideshow prefab (when it supports remote images)
  • Image collage
  • Videos

discord2vrc's People

Contributors

acertainbluecat avatar

Watchers

James Cloos 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.