GPL License & Rust Time
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
*lock*
|
||||
.direnv
|
||||
.envrc
|
||||
node_modules
|
||||
/target
|
||||
result*
|
||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "quick-start"
|
||||
version = "0.1.0"
|
||||
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "quick-start"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
43
flake.lock
generated
Normal file
43
flake.lock
generated
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1676283394,
|
||||
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1677655566,
|
||||
"narHash": "sha256-I8G8Lmpp3YduYl4+pkiIJFGT1WKw+8ZMH2QwANkTu2U=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ae8bdd2de4c23b239b5a771501641d2ef5e027d0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
122
flake.nix
Normal file
122
flake.nix
Normal file
@@ -0,0 +1,122 @@
|
||||
{
|
||||
description = "Build a cargo project";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
crane = {
|
||||
url = "github:ipetkov/crane";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
advisory-db = {
|
||||
url = "github:rustsec/advisory-db";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
|
||||
inherit (pkgs) lib;
|
||||
|
||||
craneLib = crane.lib.${system};
|
||||
src = craneLib.cleanCargoSource ./.;
|
||||
|
||||
# Common arguments can be set here to avoid repeating them later
|
||||
commonArgs = {
|
||||
inherit src;
|
||||
|
||||
buildInputs = [
|
||||
# Add additional build inputs here
|
||||
] ++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
# Additional darwin specific inputs can be set here
|
||||
pkgs.libiconv
|
||||
];
|
||||
|
||||
# Additional environment variables can be set directly
|
||||
# MY_CUSTOM_VAR = "some value";
|
||||
};
|
||||
|
||||
# Build *just* the cargo dependencies, so we can reuse
|
||||
# all of that work (e.g. via cachix) when running in CI
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
|
||||
# Build the actual crate itself, reusing the dependency
|
||||
# artifacts from above.
|
||||
my-crate = craneLib.buildPackage (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
in
|
||||
{
|
||||
checks = {
|
||||
# Build the crate as part of `nix flake check` for convenience
|
||||
inherit my-crate;
|
||||
|
||||
# Run clippy (and deny all warnings) on the crate source,
|
||||
# again, resuing the dependency artifacts from above.
|
||||
#
|
||||
# Note that this is done as a separate derivation so that
|
||||
# we can block the CI if there are issues here, but not
|
||||
# prevent downstream consumers from building our crate by itself.
|
||||
my-crate-clippy = craneLib.cargoClippy (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||
});
|
||||
|
||||
my-crate-doc = craneLib.cargoDoc (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
|
||||
# Check formatting
|
||||
my-crate-fmt = craneLib.cargoFmt {
|
||||
inherit src;
|
||||
};
|
||||
|
||||
# Audit dependencies
|
||||
my-crate-audit = craneLib.cargoAudit {
|
||||
inherit src advisory-db;
|
||||
};
|
||||
|
||||
# Run tests with cargo-nextest
|
||||
# Consider setting `doCheck = false` on `my-crate` if you do not want
|
||||
# the tests to run twice
|
||||
my-crate-nextest = craneLib.cargoNextest (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
partitions = 1;
|
||||
partitionType = "count";
|
||||
});
|
||||
} // lib.optionalAttrs (system == "x86_64-linux") {
|
||||
# NB: cargo-tarpaulin only supports x86_64 systems
|
||||
# Check code coverage (note: this will not upload coverage anywhere)
|
||||
my-crate-coverage = craneLib.cargoTarpaulin (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
};
|
||||
|
||||
packages.default = my-crate;
|
||||
|
||||
apps.default = flake-utils.lib.mkApp {
|
||||
drv = my-crate;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
inputsFrom = builtins.attrValues self.checks.${system};
|
||||
|
||||
# Additional dev-shell environment variables can be set directly
|
||||
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
|
||||
|
||||
# Extra inputs can be added here
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cargo
|
||||
rustc
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
||||
114
index.js
114
index.js
@@ -1,114 +0,0 @@
|
||||
const Discord = require('discord.js');
|
||||
const bot = new Discord.Client();
|
||||
const ytdl = require('ytdl-core');
|
||||
|
||||
const status = require('minecraft-server-status');
|
||||
|
||||
var server = null;
|
||||
var channels = null;
|
||||
|
||||
var vid = null;
|
||||
var con = null;
|
||||
|
||||
var mcServer = 'bront.syzygial.cc'
|
||||
|
||||
bot.on('ready', () => {
|
||||
console.log(`Logged in as ${bot.user.tag}!`);
|
||||
server = bot.guilds.cache.get("574723462803882018");
|
||||
channels = server.channels.cache.array();
|
||||
let t = Math.random()*300000+2000;
|
||||
setTimeout(joinMostppl,t);
|
||||
setTimeout(statLine,15000);
|
||||
console.log("Joining in "+t/1000+"s");
|
||||
statLine();
|
||||
});
|
||||
|
||||
function statLine() {
|
||||
console.log(mcServer)
|
||||
status(mcServer, 25565, response => {
|
||||
console.log(response)
|
||||
if (response!=undefined) {
|
||||
if (response.online) {
|
||||
let mcmax = response.players.max;
|
||||
let mccount = response.players.now;
|
||||
bot.user.setActivity(mccount+"/"+mcmax+" Players Online");
|
||||
}
|
||||
}
|
||||
})
|
||||
setTimeout(statLine,15000);
|
||||
}
|
||||
|
||||
function joinMostppl() {
|
||||
if (vid==null) {
|
||||
let max=0;
|
||||
let vids = channels.filter(c => c.type === 'voice');
|
||||
for (v in vids) {
|
||||
if (vids[v].members.size>max) {
|
||||
max = vids[v].members.size;
|
||||
vid = vids[v];
|
||||
}
|
||||
}
|
||||
if (max>0) {
|
||||
vid.join().then(c => {
|
||||
con = c;
|
||||
con.play("ding.mp3");
|
||||
let t = Math.random()*400000+6000;
|
||||
setTimeout(leaveChannel,t);
|
||||
console.log("Leaving in "+t/1000+"s");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function leaveChannel() {
|
||||
if (vid!=null) {
|
||||
vid.leave();
|
||||
vid=null;
|
||||
}
|
||||
let t = Math.random()*1000000+2000;
|
||||
setTimeout(joinMostppl,t);
|
||||
console.log("Joining in "+t/1000+"s");
|
||||
}
|
||||
|
||||
bot.on('message', msg => {
|
||||
var str = msg.content;
|
||||
if (str === "ALAN") {
|
||||
vid = msg.member.voice.channel;
|
||||
if (vid!=null) {
|
||||
vid.join().then(c => {
|
||||
// console.log(c);
|
||||
con = c;
|
||||
con.play("ding.mp3");
|
||||
}).catch(console.error);
|
||||
}
|
||||
}else if (str === "ALANO") {
|
||||
if (vid!=null) {
|
||||
vid.leave();
|
||||
vid=null;
|
||||
}
|
||||
}else if (str.startsWith("poll")) {
|
||||
var poll = str.slice(5).split('\n');
|
||||
if (poll.length<3) {
|
||||
msg.channel.send("You need at least two options for a poll");
|
||||
return;
|
||||
}
|
||||
var embed = new Discord.MessageEmbed().setTitle(`${msg.member.nickname} Poll:`)
|
||||
.setColor('#348db2');
|
||||
embed.setDescription(poll[0]);
|
||||
emos = bot.emojis.cache.random(poll.length-1);
|
||||
for (let i=1; i<poll.length; i++) {
|
||||
embed.addField(emos[i-1],poll[i]);
|
||||
}
|
||||
msg.channel.send(embed).then(m => {
|
||||
for (let i=1; i<poll.length; i++) {
|
||||
m.react(emos[i-1]);
|
||||
}
|
||||
});
|
||||
msg.delete();
|
||||
}else if (str.startsWith("ALAN STATUS")) {
|
||||
var words = str.slice(12).split(' ');
|
||||
mcServer = words[0];
|
||||
}
|
||||
});
|
||||
|
||||
bot.login('NzA4NDYxNzc0ODYwNzEzOTg0.XrX-dQ.fEo2gr8UHLV3JBr7CF47C-q8cOI');
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
3
src/main.rs
Normal file
3
src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Reference in New Issue
Block a user