Skip to content

Commit b1f1d95

Browse files
committed
squashed git history
0 parents  commit b1f1d95

29 files changed

+660
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.vscode
3+
*.log

.gitlab-ci.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
stages:
2+
# - newsite
3+
# - build
4+
# - test
5+
- deploy
6+
7+
# .newsite:make: &makedef
8+
# script:
9+
# - sudo darktools newsite --non-interactive --if-not-exists
10+
# variables:
11+
# DARKTOOLS_FQDN: "lax.xunn.io"
12+
# stage: newsite
13+
# tags:
14+
# - darktools
15+
# - local
16+
17+
# newsite:make_production:
18+
# <<: *makedef
19+
# environment: production
20+
# only: master
21+
22+
# newsite:make_develop:
23+
# <<: *makedef
24+
# environment: staging
25+
# only: develop
26+
27+
deploy:master_to_www:
28+
script:
29+
- /home/build-scripts/deploy/lax-master
30+
stage: deploy
31+
environment: production
32+
variables:
33+
WEBMIRROR_JSON_CONFIG: |+
34+
{
35+
"branches": {
36+
"master": {
37+
"web_public_dir": "www",
38+
"web_push_target": "lax.xunn.io/main"
39+
}
40+
}
41+
}
42+
only:
43+
- master
44+
- triggers
45+
tags:
46+
- deploy
47+
48+
deploy:develop_to_www:
49+
script:
50+
- /home/build-scripts/deploy/lax-develop
51+
stage: deploy
52+
environment: staging
53+
variables:
54+
WEBMIRROR_JSON_CONFIG: |+
55+
{
56+
"branches": {
57+
"develop": {
58+
"web_public_dir": "www",
59+
"web_push_target": "lax.xunn.io/develop"
60+
}
61+
}
62+
}
63+
only:
64+
- develop
65+
- triggers
66+
tags:
67+
- deploy

.pm2-process.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apps:
2+
- name : "lax-main"
3+
script : "/var/www/gitlab/lax.xunn.io/main/bot/main.js"
4+
cwd : "/var/www/gitlab/lax.xunn.io/main/"
5+
out_file : "/var/log/lax/lax-main.pm2.log"
6+
error_file : "/var/log/lax/lax-main.pm2.log"
7+
merge_logs : true
8+
autorestart: true
9+
env:
10+
APP_DEBUG_LEVEL : 0
11+
WORKS_WITH_WINDOWS: true
12+
APP_CONTEXT : "lax-main"
13+
LOG_DIR_PATH : "/var/log/lax/"
14+
SERVER_NAME : "lax discord bot server"
15+
16+
- name : "lax-edge"
17+
script : "/var/www/gitlab/lax.xunn.io/develop/bot/main.js"
18+
cwd : "/var/www/gitlab/lax.xunn.io/develop/"
19+
out_file : "/var/log/lax/lax-edge.pm2.log"
20+
error_file : "/var/log/lax/lax-edge.pm2.log"
21+
merge_logs : true
22+
autorestart: true
23+
env:
24+
APP_DEBUG_LEVEL : 1
25+
WORKS_WITH_WINDOWS: true
26+
APP_CONTEXT : "lax-edge"
27+
LOG_DIR_PATH : "/var/log/lax/"
28+
SERVER_NAME : "lax discord bot server (edge preview)"
29+
30+
- name : "lax-xunn"
31+
script : "/home/xunnamius/repos/web-mirrored/lax.xunn.io/bot/main.js"
32+
cwd : "/home/xunnamius/repos/web-mirrored/lax.xunn.io/"
33+
out_file : "/home/xunnamius/repos/web-mirrored/lax.xunn.io/lax-edge.pm2.log"
34+
error_file : "/home/xunnamius/repos/web-mirrored/lax.xunn.io/lax-edge.pm2.log"
35+
merge_logs : true
36+
autorestart: false
37+
max_restarts: 1
38+
env:
39+
APP_DEBUG_LEVEL : 2
40+
WORKS_WITH_WINDOWS: true
41+
APP_CONTEXT : "lax-xunn"
42+
LOG_DIR_PATH : ""
43+
SERVER_NAME : "lax discord bot server (xunn-develop debug)"

CHANGE_SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stuff got fixed, other stuff got better, be happy about it.

README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Lax
2+
3+
## The bot Discord deserves, but one it doesn't think it needs right now
4+
5+
### What is Lax?
6+
7+
Lax. It has some Slack-like features, but a whole lot more powerful. Oh, and it's for Discord and may eventually be accessible from Messenger (Facebook), accept commands via SMS/text and email, etc.
8+
9+
### Features
10+
11+
* (list to be populated eventually)
12+
* [and many more...](#)
13+
14+
### For The Devs: Get Started Now!
15+
16+
Deving this bot is pretty easy. For this project, like any other semi-professional and professional project, commit flow control is strictly enforced. Each developer should have their own publically accessible branch named `yourname-develop`. You should test and develop your version of the bot locally to your satisfaction. When you have a feature that you believe is ready for life, pretty your history up a bit with a `git squash` and submit a merge request against the develop branch. The lead devs will then accept/reject merge requests into develop. If after testing your feature in the live staging environment it is deemed worthy, submit a new merge request from develop into master (ensure that you've bumped the version appropriately in develop's `package.json` but **only at this point**). @Xunnamius will then accept/reject merge requests into master.
17+
18+
When you first clone the project to begin developing, **don't forget to modify `.pm2-process.yml` and `secrets.json`** and add a context for your environment. `.pm2-process.yml` is **not** ignored by version control, so you should not put sensitive configuration variables inside of it. If you're thinking of adding new potentially sensitive configuration variables that must exist in upstream configurations and not just locally, please discuss first. `.secrets.yml` **is ignored by version control**, so you **should** put sensitive configuration variables inside of it and only it.
19+
20+
Relevant Discord stuff that you should take a look at:
21+
22+
* https://discordapp.com/developers/docs/intro
23+
* https://discord.js.org/
24+
* https://luis.ai
25+
* https://github.com/Microsoft/Cognitive-LUIS-Node.js
26+
* http://pm2.keymetrics.io/docs/usage/application-declaration/
27+
* https://github.com/tj/commander.js
28+
29+
### Add Bot to Server
30+
31+
To add the production bot to a Discord server, use this URL: https://discordapp.com/oauth2/authorize?client_id=316786432306053121&permissions=8&scope=bot
32+
33+
To add the staging bot to a Discord server, use this URL: https://discordapp.com/oauth2/authorize?client_id=316788662283272192&permissions=8&scope=bot
34+
35+
Note that there are restrictions on which servers the bot will work properly on.
36+
37+
### In-depth API Documentation
38+
39+
(todo)

bot/config/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
secrets.json

bot/config/globals.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/nodejs
2+
/* jshint browser:true, mocha:true, node:true, devel:true */
3+
/* globals */
4+
5+
/*
6+
* @author Xunnamius
7+
*/
8+
9+
"use strict";
10+
11+
const globals = {};
12+
13+
globals.reuse = (strings) => (...vars) => strings.map((v, i) => `${v}${vars[i] || ''}`).join('');
14+
15+
globals.LAX_PREVIEW_CHANNEL_ID = '316789032447377423';
16+
globals.PUBLIC_WARNING_SLEEP = 5000;
17+
globals.TYPING_RESPONSE_SLEEP = 2000;
18+
globals.CMD_PREFIX = '!';
19+
globals.TYPING_RESPONSE_DELAY = 2000;
20+
globals.TYPING_RESPONSE_DELAY_DECAY = 3;
21+
globals.TYPING_RESPONSE_DELAY_MIN = 500;
22+
23+
globals.IS_RUNNING_WINDOWS = process.platform == 'win32';
24+
globals.DEBUG_MODE = parseInt(process.env.APP_DEBUG_LEVEL || 0);
25+
globals.SUPER_DEBUG_MODE = DEBUG_MODE > 1;
26+
globals.APP_ENV = process.env.APP_ENV;
27+
28+
globals.inspect = obj =>
29+
{
30+
return util.inspect(obj, false, DEBUG_MODE || 1, true);
31+
};
32+
33+
globals.implementMessageExtras = (message) =>
34+
{
35+
message.forUs = false;
36+
message.mentions.byName = false;
37+
message.mentions.byPrefix = false;
38+
39+
message.sender = message.member ? message.member.displayName : `${message.author.tag} (member not on server)`;
40+
41+
if(message.isMentioned(client.user.id) && message.cleanContent.indexOf('@') == message.cleanContent.lastIndexOf('@'))
42+
message.mentions.byName = true;
43+
44+
if(message.cleanContent.startsWith(CMD_PREFIX))
45+
message.mentions.byPrefix = true;
46+
47+
message.forUs = message.member
48+
&& client.user.id != message.member.id
49+
&& (message.mentions.byName || message.mentions.byPrefix);
50+
51+
message.text = message.cleanContent.replace(`@${client.nickname}`, '')
52+
.replace(`@${client.user.username}`, '')
53+
.replace(`@${client.user.tag}`, '')
54+
.replace(' ', ' ')
55+
.trim();
56+
57+
if(message.mentions.byPrefix)
58+
message.text = message.cleanContent.substring(CMD_PREFIX.length).trim();
59+
};
60+
61+
globals.implementChannelExtras = (channel) =>
62+
{
63+
channel.typeAndSend = (...msg) => responseQueues.get(channel.id).add(...msg);
64+
};
65+
66+
module.exports = globals;

0 commit comments

Comments
 (0)