Strona zostanie usunięta „Development Setup”. Bądź ostrożny.
This application runs using Ruby and Postgresql. In order to run and maintain the bot, some linux libraries must be installed.
Enable Developer Mode
Open your settings, and navigate to Update and Security
On the left, click For Developers, and check Developer Mode
Subsystem for Linux
Next open the Control Panel, and select Programs
and select Turn Windows features on or off on the side bar
Search for Windows Subsystem for Linux, check it and wait for the
install, then restart
Installing Bash
Now you can open a Command Prompt and type in:
C:\Users\YourUserName> bash
If it returns saying you have no installed distributions, open up the Microsoft Store and install Ubuntu (its free), and try again
If it is asking for verification, reply with y and wait for the install
Once prompted you can provide a username and password of your choice, you should then get a prompt:
username@ComputerName: $
First and foremost, it is important to have git installed
$ sudo apt-get install git
Next we can clone the project and move into its directory
$ git clone https://github.com/kjswis/rotom_bot.git
$ cd rotom_bot/
R0ry uses Ruby version 2.6.3
I recommend using RVM to manage ruby versions
$ \curl -sSL https://get.rvm.io | bash -s stable
$ rvm install ruby 2.6.3
R0ry uses ImageMagick version 7.0.11-2
For installation and setup instructions please visit imagemagick.org
R0ry uses PostgreSQL version 11.2
For installation, documentation, and setup instructions visit postgresql.org
To install using command line
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql
$ sudo apt-get install postgresql-11.2
We need to create a user and database for the bot to use. The actual user and Database names don't matter
They can be created with commandline tools
$ psql
CREATE USER [name] WITH PASSWORD '[password]';
CREATE DATABASE [name] WITH OWNER [username];
If the db gets created with initail setup this is how to change owner
ALTER DATABASE [name] OWNER TO [new_owner];
R0ry has a number of gems that are necessary to run.
They can be found in the Gemfile found in the main directory
In order to use this, we must install the bundler gem, then we can use it to install the rest of the necessary gems
$ gem install bundler
$ bundle install
In order to run the bot locally, you'll need a discord bot!
You can create one through the Discord Developer Portal
Create a new project, and name it whatever you want. We're going to need 3
codes from there. Client ID and Client Secret are on the General
Information page, and the last code we need is on the Bot page. Simply
create a bot here, and copy its Token
For R0ry to know what bot to use, we need those codes from the last step, as well as the postgres user we created, its password and the name of the database you want R0ry to query from
Create a .env file in the root directory of the bot, this can be taken from the .env.template. The variables we need in order to run the bot are as follows:
Now that our setup is all complete, we can finally run the bot!
$ ruby bot.rb
It is important to remember to work in your own branch when contributing to this project. All contributions made should be commited and pushed, then rebased from master before their pull-requests are made.
$ git status # Shows the current branch, and any file changes
$ git fetch --all # Looks for changes and new branches
$ git pull # Pulls changes from the server to your computer for the current branch
$ git add [files] # Adds the files to be saved (staged)
$ git commit # Commits the saved changes
$ git push origin [branch] # Pushes changes from your computer to the server
when changes are commited, the terminal will open a commit file for you to insert a message. To insert, type i, then type your message and hit esc. You can then save your changes with :wq
To avoid using vi to edit your commit message, you can also alter your commit command
$ git commit -m 'my commit message'
Branches are a great way to keep changes contained, and avoid merge conflicts
$ git checkout [existing_branch] # Switches to an existing branch
$ git checkout -b [new_branch] # Creates a new branch based on the branch you were in
If you begin working on a branch, and changes get merged into master, you can rebase your branch to merge the changes more smoothy
$ git rebase master
If you want to clean up your branches, you can list and delete them
$ git branch # Lists all the local branches
$ git branch -D [branch] # Deletes the specified branch locally
Strona zostanie usunięta „Development Setup”. Bądź ostrożny.