Use weekly tags for veloren deps; Add kick_all
This commit is contained in:
parent
7eefb6ef8e
commit
49e6f8a68b
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -2543,7 +2543,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-client"
|
name = "veloren-client"
|
||||||
version = "0.16.0"
|
version = "0.16.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"authc",
|
"authc",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
@ -2569,7 +2569,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-common"
|
name = "veloren-common"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"approx",
|
"approx",
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
@ -2609,7 +2609,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-common-assets"
|
name = "veloren-common-assets"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assets_manager",
|
"assets_manager",
|
||||||
"dot_vox",
|
"dot_vox",
|
||||||
@ -2624,7 +2624,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-common-base"
|
name = "veloren-common-base"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"directories-next",
|
"directories-next",
|
||||||
"tracing",
|
"tracing",
|
||||||
@ -2633,7 +2633,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-common-ecs"
|
name = "veloren-common-ecs"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"specs",
|
"specs",
|
||||||
"tracing",
|
"tracing",
|
||||||
@ -2643,7 +2643,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-common-i18n"
|
name = "veloren-common-i18n"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown 0.13.2",
|
"hashbrown 0.13.2",
|
||||||
"rand",
|
"rand",
|
||||||
@ -2653,7 +2653,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-common-net"
|
name = "veloren-common-net"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"flate2",
|
"flate2",
|
||||||
@ -2671,7 +2671,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-common-state"
|
name = "veloren-common-state"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -2693,7 +2693,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-common-systems"
|
name = "veloren-common-systems"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools",
|
"itertools",
|
||||||
"ordered-float",
|
"ordered-float",
|
||||||
@ -2711,7 +2711,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-network"
|
name = "veloren-network"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@ -2736,7 +2736,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-network-protocol"
|
name = "veloren-network-protocol"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
source = "git+https://gitlab.com/veloren/veloren?branch=master#c205a1fae21ae92a85695b10428e06eade31fc32"
|
source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
|
@ -5,9 +5,9 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = "1.38.0"
|
tokio = "1.38.0"
|
||||||
veloren-common = { git = "https://gitlab.com/veloren/veloren", branch = "master", features = ["no-assets"] }
|
veloren-common = { git = "https://gitlab.com/veloren/veloren", features = ["no-assets"], tag = "weekly" }
|
||||||
veloren-client = { git = "https://gitlab.com/veloren/veloren", branch = "master" }
|
veloren-client = { git = "https://gitlab.com/veloren/veloren", tag = "weekly" }
|
||||||
veloren-common-net = { git = "https://gitlab.com/veloren/veloren", branch = "master" }
|
veloren-common-net = { git = "https://gitlab.com/veloren/veloren", tag = "weekly" }
|
||||||
toml = "0.8.14"
|
toml = "0.8.14"
|
||||||
serde = { version = "1.0.203", features = ["derive"] }
|
serde = { version = "1.0.203", features = ["derive"] }
|
||||||
env_logger = "0.11.3"
|
env_logger = "0.11.3"
|
||||||
|
52
src/bot.rs
52
src/bot.rs
@ -31,7 +31,7 @@ impl Bot {
|
|||||||
info!("Connecting to veloren");
|
info!("Connecting to veloren");
|
||||||
|
|
||||||
let client = connect_to_veloren(username, password)?;
|
let client = connect_to_veloren(username, password)?;
|
||||||
let clock = Clock::new(Duration::from_secs_f64(0.034));
|
let clock = Clock::new(Duration::from_secs_f64(1.0 / 60.0));
|
||||||
|
|
||||||
Ok(Bot {
|
Ok(Bot {
|
||||||
client,
|
client,
|
||||||
@ -101,6 +101,12 @@ impl Bot {
|
|||||||
&sender_info,
|
&sender_info,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
ChatType::Offline(uid) => {
|
||||||
|
self.client.kick_from_group(uid);
|
||||||
|
}
|
||||||
|
ChatType::CommandError => {
|
||||||
|
eprintln!("Command Error!")
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,6 +115,24 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_message(&mut self, content: &str, sender: &PlayerInfo) -> Result<(), String> {
|
fn handle_message(&mut self, content: &str, sender: &PlayerInfo) -> Result<(), String> {
|
||||||
|
if content == "inv" {
|
||||||
|
info!("Inviting {}", sender.player_alias);
|
||||||
|
|
||||||
|
let uid = self.find_uid(&sender.player_alias)?;
|
||||||
|
|
||||||
|
self.client.send_invite(uid, InviteKind::Group);
|
||||||
|
}
|
||||||
|
|
||||||
|
if content == "kick_all" && self.admin_list.contains(&sender.uuid) {
|
||||||
|
info!("Kicking everyone");
|
||||||
|
|
||||||
|
let group_members = self.client.group_members().clone();
|
||||||
|
|
||||||
|
for (uid, _) in group_members {
|
||||||
|
self.client.kick_from_group(uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut words = content.split_whitespace();
|
let mut words = content.split_whitespace();
|
||||||
let command = if let Some(command) = words.next() {
|
let command = if let Some(command) = words.next() {
|
||||||
command
|
command
|
||||||
@ -120,6 +144,8 @@ impl Bot {
|
|||||||
"admin" => {
|
"admin" => {
|
||||||
if self.admin_list.contains(&sender.uuid) || self.admin_list.is_empty() {
|
if self.admin_list.contains(&sender.uuid) || self.admin_list.is_empty() {
|
||||||
for word in words {
|
for word in words {
|
||||||
|
info!("Adminifying {word}");
|
||||||
|
|
||||||
self.adminify_player(word)?;
|
self.adminify_player(word)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,6 +153,8 @@ impl Bot {
|
|||||||
"ban" => {
|
"ban" => {
|
||||||
if self.admin_list.contains(&sender.uuid) {
|
if self.admin_list.contains(&sender.uuid) {
|
||||||
for word in words {
|
for word in words {
|
||||||
|
info!("Banning {word}");
|
||||||
|
|
||||||
let uid = self.find_uid(word)?;
|
let uid = self.find_uid(word)?;
|
||||||
|
|
||||||
self.client.kick_from_group(uid);
|
self.client.kick_from_group(uid);
|
||||||
@ -135,6 +163,8 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"cheese" => {
|
"cheese" => {
|
||||||
|
info!("Saying 'I love cheese!' to {}", sender.player_alias);
|
||||||
|
|
||||||
let uid = self.find_uid(&sender.player_alias)?;
|
let uid = self.find_uid(&sender.player_alias)?;
|
||||||
|
|
||||||
if self.client.group_members().contains_key(&uid) {
|
if self.client.group_members().contains_key(&uid) {
|
||||||
@ -144,22 +174,20 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
"inv" => {
|
"inv" => {
|
||||||
if !self.ban_list.contains(&sender.uuid) {
|
if !self.ban_list.contains(&sender.uuid) {
|
||||||
if content == "inv" {
|
|
||||||
let uid = self.find_uid(&sender.player_alias)?;
|
|
||||||
|
|
||||||
self.client.send_invite(uid, InviteKind::Group);
|
|
||||||
} else {
|
|
||||||
for word in words {
|
for word in words {
|
||||||
|
info!("Inviting {word}");
|
||||||
|
|
||||||
let uid = self.find_uid(word)?;
|
let uid = self.find_uid(word)?;
|
||||||
|
|
||||||
self.client.send_invite(uid, InviteKind::Group);
|
self.client.send_invite(uid, InviteKind::Group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
"kick" => {
|
"kick" => {
|
||||||
if self.admin_list.contains(&sender.uuid) {
|
if self.admin_list.contains(&sender.uuid) {
|
||||||
for word in words {
|
for word in words {
|
||||||
|
info!("Kicking {word}");
|
||||||
|
|
||||||
let uid = self.find_uid(word)?;
|
let uid = self.find_uid(word)?;
|
||||||
|
|
||||||
self.client.kick_from_group(uid);
|
self.client.kick_from_group(uid);
|
||||||
@ -169,6 +197,8 @@ impl Bot {
|
|||||||
"unban" => {
|
"unban" => {
|
||||||
if self.admin_list.contains(&sender.uuid) {
|
if self.admin_list.contains(&sender.uuid) {
|
||||||
for word in words {
|
for word in words {
|
||||||
|
info!("Unbanning {word}");
|
||||||
|
|
||||||
self.unban_player(word)?;
|
self.unban_player(word)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,8 +210,6 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn adminify_player(&mut self, name: &str) -> Result<(), String> {
|
fn adminify_player(&mut self, name: &str) -> Result<(), String> {
|
||||||
info!("Adminifying {name}");
|
|
||||||
|
|
||||||
let uuid = self.find_uuid(name)?;
|
let uuid = self.find_uuid(name)?;
|
||||||
|
|
||||||
if !self.admin_list.contains(&uuid) && !self.ban_list.contains(&uuid) {
|
if !self.admin_list.contains(&uuid) && !self.ban_list.contains(&uuid) {
|
||||||
@ -202,8 +230,6 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ban_player(&mut self, name: &str) -> Result<(), String> {
|
fn ban_player(&mut self, name: &str) -> Result<(), String> {
|
||||||
info!("Banning {name}");
|
|
||||||
|
|
||||||
let uuid = self.find_uuid(name)?;
|
let uuid = self.find_uuid(name)?;
|
||||||
|
|
||||||
if !self.admin_list.contains(&uuid) && !self.ban_list.contains(&uuid) {
|
if !self.admin_list.contains(&uuid) && !self.ban_list.contains(&uuid) {
|
||||||
@ -224,8 +250,6 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn unban_player(&mut self, name: &str) -> Result<(), String> {
|
fn unban_player(&mut self, name: &str) -> Result<(), String> {
|
||||||
info!("Unbanning {name}");
|
|
||||||
|
|
||||||
let uuid = self.find_uuid(name)?;
|
let uuid = self.find_uuid(name)?;
|
||||||
|
|
||||||
if let Some(uuid) = self
|
if let Some(uuid) = self
|
||||||
@ -275,7 +299,7 @@ impl Bot {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ok_or(format!("Failed to find uid for player {}", name))
|
.ok_or(format!("Failed to find uuid for player {}", name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use bot::Bot;
|
use bot::Bot;
|
||||||
|
use log::{error, info};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use veloren_common::uuid::Uuid;
|
use veloren_common::uuid::Uuid;
|
||||||
|
|
||||||
@ -19,6 +20,8 @@ struct Config {
|
|||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
fn read() -> Result<Self, String> {
|
fn read() -> Result<Self, String> {
|
||||||
|
info!("Reading config");
|
||||||
|
|
||||||
let config_path = var("CONFIG_PATH").map_err(|error| error.to_string())?;
|
let config_path = var("CONFIG_PATH").map_err(|error| error.to_string())?;
|
||||||
let config_file_content = read_to_string(config_path).map_err(|error| error.to_string())?;
|
let config_file_content = read_to_string(config_path).map_err(|error| error.to_string())?;
|
||||||
|
|
||||||
@ -26,6 +29,8 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self) -> Result<(), String> {
|
fn write(&self) -> Result<(), String> {
|
||||||
|
info!("Writing config");
|
||||||
|
|
||||||
let config_path = var("CONFIG_PATH").map_err(|error| error.to_string())?;
|
let config_path = var("CONFIG_PATH").map_err(|error| error.to_string())?;
|
||||||
let config_string = toml::to_string(self).map_err(|error| error.to_string())?;
|
let config_string = toml::to_string(self).map_err(|error| error.to_string())?;
|
||||||
|
|
||||||
@ -47,7 +52,8 @@ fn main() {
|
|||||||
|
|
||||||
bot.select_character().expect("Failed to select character");
|
bot.select_character().expect("Failed to select character");
|
||||||
|
|
||||||
|
#[allow(unused_must_use)]
|
||||||
loop {
|
loop {
|
||||||
bot.tick().expect("Failed to run bot")
|
bot.tick().inspect_err(|e| error!("{e}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user