Compare commits
9 Commits
main
...
1ddda1122d
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ddda1122d | |||
| c326d201f5 | |||
| fa8ba060be | |||
| f25484672b | |||
| 1ba07c0bbf | |||
| cf68d8fab3 | |||
| 6602ae27c5 | |||
| a39c61a951 | |||
|
|
85c4818e37 |
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Cargo.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 = "New Alan"
|
||||
version = "0.0.1"
|
||||
edition = "2023"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
140
flake.lock
generated
Normal file
140
flake.lock
generated
Normal file
@@ -0,0 +1,140 @@
|
||||
{
|
||||
"nodes": {
|
||||
"advisory-db": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1677345087,
|
||||
"narHash": "sha256-PSkBGJ6KyGbTeLtEgdHSljm76NOeoww9hDgBD/QBffk=",
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"rev": "9a5b1008028e4b37e91f5951e639ad7848232f8e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1677642623,
|
||||
"narHash": "sha256-GlRa6/HWg8mIxPM29ZuTP2dP8y9sQ6BdbrjzCO8JgAo=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "f3f763e4d9f156ec0c37f39b0f77e2d62213b296",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"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": 1677816901,
|
||||
"narHash": "sha256-oqe8Q9LlWNGfVfUDkKfpWAk+I9RRDBvMSyYVIOZCfPM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0749042bfaa2f4efa70ac829c5387133cfc0a337",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"advisory-db": "advisory-db",
|
||||
"crane": "crane",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"crane",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"crane",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676437770,
|
||||
"narHash": "sha256-mhJye91Bn0jJIE7NnEywGty/U5qdELfsT8S+FBjTdG4=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "a619538647bd03e3ee1d7b947f7c11ff289b376e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"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.
|
||||
newalan = craneLib.buildPackage (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
in
|
||||
{
|
||||
checks = {
|
||||
# Build the crate as part of `nix flake check` for convenience
|
||||
inherit newalan;
|
||||
|
||||
# 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.
|
||||
newalan-clippy = craneLib.cargoClippy (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||
});
|
||||
|
||||
newalan-doc = craneLib.cargoDoc (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
|
||||
# Check formatting
|
||||
newalan-fmt = craneLib.cargoFmt {
|
||||
inherit src;
|
||||
};
|
||||
|
||||
# Audit dependencies
|
||||
newalan-audit = craneLib.cargoAudit {
|
||||
inherit src advisory-db;
|
||||
};
|
||||
|
||||
# Run tests with cargo-nextest
|
||||
# Consider setting `doCheck = false` on `newalan` if you do not want
|
||||
# the tests to run twice
|
||||
newalan-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)
|
||||
newalan-coverage = craneLib.cargoTarpaulin (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
};
|
||||
|
||||
packages.default = newalan;
|
||||
|
||||
apps.default = flake-utils.lib.mkApp {
|
||||
drv = newalan;
|
||||
};
|
||||
|
||||
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, hydra!");
|
||||
}
|
||||
Reference in New Issue
Block a user