https://github.com/octohedron/goddit
🏓 Reddit golang chat
https://github.com/octohedron/goddit
chat golang mgo mongodb reddit-api redigo redis websockets
Last synced: 5 months ago
JSON representation
🏓 Reddit golang chat
- Host: GitHub
- URL: https://github.com/octohedron/goddit
- Owner: octohedron
- License: mit
- Created: 2017-05-06T20:08:20.000Z (about 9 years ago)
- Default Branch: reddit
- Last Pushed: 2020-05-24T03:56:34.000Z (about 6 years ago)
- Last Synced: 2024-06-20T15:21:45.756Z (about 2 years ago)
- Topics: chat, golang, mgo, mongodb, reddit-api, redigo, redis, websockets
- Language: Go
- Homepage:
- Size: 279 KB
- Stars: 35
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Golang chat server 🏓
============================
##### Try it out!
- Install mongodb
- Clone repo to `$GOPATH/src/github.com/octohedron/goddit`
- Install dependencies
```bash
$ go get
```
- Build the binary
```bash
$ go build
```
- Edit the [.env](./.env) file in the root of the repository with your values
```bash
# from reddit.com/prefs/apps
APPID=YOUR_APP_ID
APPSECRET=YOUR_APP_SECRET
GODDITADDR=YOUR_SERVER_ADDR # i.e. http://localhost:9000
GODDITDOMAIN=YOUR_DOMAIN # i.e. localhost / goddit.pro
GPORT=9000 # 9000 / 80
GCOOKIE=YOUR_COOKIE # i.e. goddit
MONGO_ADDR=YOUR_MONGO_ADDR # i.e. 127.0.0.1, 172.17.0.1 for docker, etc
MONGO_USER=YOUR_MONGO_USER # i.e. username
MONGO_PASS=YOUR_MONGO_PASS # i.e. hunter2
```
- Run it manually
```bash
$ nohup ./goddit &
```
- Run it with Docker
```bash
docker rm goddit && docker build -t goddit . && docker run --name goddit -p 9000:9000 -it goddit
```
## Features
- Crawls popular subreddits (first 25) and adds them as chatrooms in a separate `goroutine` (for faster startup) when you start the program
- Loads previous chatroom history (up to 150 messages) when switching rooms
- Authorizes via reddit and pairs a `cookie` with a user in the server for Authorization
- Only broadcasts messages to those present in the room, not to others in different rooms
- Different color avatars, autogenerated from [placeskull.com](http://placeskull.com)
- Enforces a single `WebSocket` for each client, closing the connection when switching rooms
- Each client reads and writes to a different `goroutine` (2 goroutines/client)
- Database writes are performed in a separate `goroutine`
##### CONTRIBUTING: Yes
LICENSE: MIT