1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-09 16:42:48 +00:00

changes for public use

This commit is contained in:
2017-03-27 18:46:03 -05:00
committed by mgerb42
parent 39861a62bc
commit 1626bdddcd
25 changed files with 58 additions and 2789 deletions

5
.gitignore vendored
View File

@@ -1,5 +1,4 @@
config.json
dist/config.json
dist/sounds
dist
node_modules
yarn-error*
yarn-error*

View File

@@ -6,14 +6,10 @@ import Wrapper from './Wrapper';
import Soundboard from './pages/Soundboard/Soundboard';
import NotFound from './pages/NotFound/NotFound';
//pages
import Home from './pages/Home/Home';
ReactDOM.render(
<Router history={browserHistory}>
<Route path="/" component={Wrapper}>
<IndexRoute component={Home}/>
<Route path="/soundboard" component={Soundboard}/>
<IndexRoute component={Soundboard}/>
<Route path="*" component={NotFound}/>
</Route>
</Router>

View File

@@ -8,12 +8,8 @@ export default class Navbar extends React.Component {
render() {
return (
<div className="Navbar">
<div className="Navbar__header">GoBot</div>
<Link to="/" className="Navbar__item" onlyActiveOnIndex activeClassName="Navbar__item--active">Home</Link>
<Link to="/soundboard" className="Navbar__item" activeClassName="Navbar__item--active">Soundboard</Link>
<div className="link">
<a href="https://discordapp.com/invite/0Z2tzxKECEj2BHwj" target="_blank">Join the discord</a>
</div>
<div className="Navbar__header">Sound<br/>Bot</div>
<Link to="/" className="Navbar__item" onlyActiveOnIndex activeClassName="Navbar__item--active">Soundboard</Link>
</div>
);
}
@@ -21,4 +17,4 @@ export default class Navbar extends React.Component {
Navbar.propTypes = {
children: React.PropTypes.node,
};
};

View File

@@ -12,14 +12,6 @@
border-right: 1px solid darken($gray2, 2%);
overflow-y: auto;
padding-bottom: 10px;
.link {
display: flex;
flex: 1;
flex-direction: column;
justify-content: flex-end;
text-align: center;
}
}
.Navbar__header {
@@ -28,6 +20,7 @@
display: flex;
align-items: center;
justify-content: center;
text-align: center;
background-color: $primaryBlue;
border-bottom: 1px solid $gray3;
}

View File

@@ -1,23 +0,0 @@
import React from 'react';
import './Home.scss';
export default class Home extends React.Component {
render() {
return (
<div className="Home">
<div className="Card">
<div className="Card__header">
GoBot Early Access Pre Pre Alpha
</div>
<p>This application is a work in progress.</p>
<p>Check out the source code on
<a href="https://github.com/mgerb/GoBot" target="_blank"> GitHub
<i className="fa fa-github" aria-hidden="true"></i>
</a>
</p>
</div>
</div>
);
}
}

View File

@@ -1,5 +0,0 @@
@import "../../scss/variables";
.Home {
padding: 10px;
}

View File

@@ -77,6 +77,18 @@ export default class Soundboard extends React.Component {
return (
<div className="Soundboard">
<div className="column">
<div className="Card">
<div className="Card__header">
Discord Sound Bot
</div>
<p>Drag and drop files to upload. The sounds can then be played in discord by typing the commands below.</p>
<p>Check out the source code on
<a href="https://github.com/mgerb/GoBot" target="_blank"> GitHub
<i className="fa fa-github" aria-hidden="true"></i>
</a>
</p>
<p>Follow the readme to set up your own bot!</p>
</div>
<SoundList ref="SoundList"/>
</div>

View File

@@ -28,6 +28,7 @@ body {
border-radius: 5px;
max-width: 800px;
padding: 10px;
margin-bottom: 20px;
border: 1px solid $gray3;
}

BIN
dist/GoBot-linux vendored

Binary file not shown.

View File

@@ -1,7 +0,0 @@
{
"Token": "",
"BotPrefix": "#",
"SoundsPath": "./sounds/",
"UploadPassword": "",
"ServerAddr": ":80"
}

5
dist/index.html vendored
View File

@@ -1,5 +0,0 @@
<html><head><link href="/static/app.51a9064c6fa89f0c8861.css" rel="stylesheet"></head>
<body>
<div id="app"></div>
<script type="text/javascript" src="/static/manifest.51a9064c6fa89f0c8861.js"></script><script type="text/javascript" src="/static/vendor.51a9064c6fa89f0c8861.js"></script><script type="text/javascript" src="/static/app.51a9064c6fa89f0c8861.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +0,0 @@
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n=window.webpackJsonp;window.webpackJsonp=function(t,c,i){for(var u,a,f,s=0,l=[];s<t.length;s++)a=t[s],o[a]&&l.push(o[a][0]),o[a]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(n&&n(t,c,i);l.length;)l.shift()();if(i)for(s=0;s<i.length;s++)f=r(r.s=i[s]);return f};var t={},o={2:0};r.e=function(e){function n(){c.onerror=c.onload=null,clearTimeout(i);var r=o[e];0!==r&&(r&&r[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return Promise.resolve();if(o[e])return o[e][2];var t=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.timeout=12e4,r.nc&&c.setAttribute("nonce",r.nc),c.src=r.p+"/static/"+e+".51a9064c6fa89f0c8861.js";var i=setTimeout(n,12e4);c.onerror=c.onload=n;var u=new Promise(function(r,n){o[e]=[r,n]});return o[e][2]=u,t.appendChild(c),u},r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r.oe=function(e){throw console.error(e),e}}([]);

File diff suppressed because one or more lines are too long

BIN
ffmpeg Normal file

Binary file not shown.

View File

@@ -1,20 +1,18 @@
run:
go run ./server/main.go
linux:
go build -o ./dist/GoBot-linux ./server/main.go
mac:
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o ./dist/GoBot-mac ./server/main.go
install:
go get ./server && yarn install
build:
go build -o ./dist/GoBot ./server/main.go
windows:
CGO_ENABLED=1 GOOS=windows GOARCH=386 go build -o ./dist/GoBot-windows.exe ./server/main.go
clean:
rm -rf ./dist
copyfiles:
cp config.template.json ./dist/config.template.json
cp ffmpeg ./dist/ffmpeg
all: linux copyfiles
all: install build copyfiles
yarn run build

View File

@@ -4,7 +4,7 @@
"description": "A seed for a simple react application",
"scripts": {
"build": "webpack -p --progress --colors",
"dev": "webpack-dev-server --inline --hot --history-api-fallback",
"dev": "webpack --watch",
"c9": "webpack-dev-server --host 0.0.0.0 --port 8080 --inline --hot --history-api-fallback"
},
"author": "Mitchell Gerber",

View File

@@ -1,18 +1,34 @@
# GoBot
# Discord Sound Bot
My experimental Discord bot
This is a soundboard bot for discord. The back end is in GoLang and the front end uses React.
### Cross Compiling
The gopus library uses the CGO package, therefore building both Mac and Linux require `CGO_ENABLED=1`.
<img src="http://i.imgur.com/jtAyJZ1.png"/>
> Work in progress
## Dependencies
- Go
- Yarn (or npm - makefile will need to be adjusted)
- make
Other libraries are needed in order for CGO work properly cross platform.
## How to use
```
sudo apt-get install gcc-multilib
apt-get install libpango1.0
```
- Make sure dependencies are installed
- `make all`
- Rename the `config.template.json` to `config.json`
- add configurations to `config.json`
- run the executable
- open a browser `localhost:<port>`
- upload files
- success!
This are some packages I came across as suggestions after a little browsing. Doesn't seem to be working currently.
This is something I need to investigate more on in the future.
### NOTE
If you get a permissions error with ffmpeg:
`sudo chmod +x dist/ffmpeg`
Sounds are stored in the `dist/sounds` directory. You may copy files directly to this folder rather than uploading through the site.
### Windows
I've only compiled and run this on linux, but it should work on windows with little changes.
An ffmpeg executable is required. The linux executable is included.
If running on windows ffmpeg.exe must be downloaded.
Check line 116 in server/bothandlers/sounds.go

View File

@@ -113,8 +113,9 @@ func loadFile(fileName string) error {
fmt.Println("Loading file: " + fname + fextension)
// TODO - check if windows and use "./ffmpeg.exe" - change this if you wish to run on windows
// use ffmpeg to convert file into a format we can use
cmd := exec.Command("ffmpeg", "-i", config.Config.SoundsPath+fname+fextension, "-f", "s16le", "-ar", strconv.Itoa(frameRate), "-ac", strconv.Itoa(channels), "pipe:1")
cmd := exec.Command("./ffmpeg", "-i", config.Config.SoundsPath+fname+fextension, "-f", "s16le", "-ar", strconv.Itoa(frameRate), "-ac", strconv.Itoa(channels), "pipe:1")
ffmpegout, err := cmd.StdoutPipe()