Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Justfile.top
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
rebot: update build stop deploy start status

update:
(cd bot-src; git pull)

build:
(cd bot-src; just build)

deploy:
(cd bot-src; just deploy)

stop:
sudo service aeglbot stop

start:
sudo service aeglbot start

status:
sudo service aeglbot status

dbdump:
pg_dump -U aeglbot -d aeglbot -f aeglbot.sql
57 changes: 56 additions & 1 deletion bot/src/commands/editguar_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Message<ActorUpdateMessage> for EditGuardianCommand {

if args.len() == 1 {
let info = format!(
"{clan}{name} {email} {admin}",
"{clan}{name} {email} {admin} {rising}",
clan = guardian
.psn_clan
.clone()
Expand All @@ -94,6 +94,7 @@ impl Message<ActorUpdateMessage> for EditGuardianCommand {
} else {
""
},
rising = guardian.format_destiny_rising_id(),
);
return self.send_reply(&message, info).await;
}
Expand Down Expand Up @@ -124,6 +125,60 @@ impl Message<ActorUpdateMessage> for EditGuardianCommand {
}
self.send_reply(&message, "✅ Updated guardian clan").await;
}
"rising" => {
if value.is_empty() {
return self
.send_reply(
&message,
"❌ Rising needs at least an UID, but better UID and nickname",
)
.await;
}

let split = value.split_once(' ');
if split.is_none() {
let Ok(uid) = value.parse::<i64>() else {
return self
.send_reply(&message, "❌ Destiny: Rising uid must be a number")
.await;
};

let mut guardian: guardians::ActiveModel = guardian.into();
guardian.rising_uid = Set(Some(uid));
if guardian.update(connection).await.is_err() {
return self
.send_reply(&message, "❌ Failed to update Destiny: Rising uid")
.await;
}
return self
.send_reply(&message, "✅ Updated guardian Destiny: Rising uid")
.await;
}
let (uid, nickname) = split.unwrap();
let Ok(uid) = uid.parse::<i64>() else {
return self
.send_reply(&message, "❌ Destiny: Rising uid must be a number")
.await;
};

let mut guardian: guardians::ActiveModel = guardian.into();
guardian.rising_uid = Set(Some(uid));
guardian.rising_nickname = Set(Some(nickname.to_string()));

if guardian.update(connection).await.is_err() {
return self
.send_reply(
&message,
"❌ Failed to update Destiny: Rising uid and nickname",
)
.await;
}
self.send_reply(
&message,
"✅ Updated guardian Destiny: Rising uid and nickname",
)
.await;
}
"email" => {
let email_value = if value == "delete" {
None
Expand Down
4 changes: 2 additions & 2 deletions bot/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ pub async fn validate_username(
.await;
None
}
Err(_) => {
Err(e) => {
let _ = bot
.tell(SendMessageReply(
"❌ Error querying guardian info.".into(),
format!("❌ Error querying guardian info. {e}"),
message.clone(),
Format::Plain,
Notify::Off,
Expand Down
5 changes: 3 additions & 2 deletions bot/src/commands/whois_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ impl Message<ActorUpdateMessage> for WhoisCommand {
self.send_reply(
&message,
format!(
"✅ Guardian @{telegram_name} PSN {psn_name}",
"✅ Guardian @{telegram_name} PSN {psn_name} {rising}",
telegram_name = guardian.telegram_name,
psn_name = guardian.psn_name
psn_name = guardian.psn_name,
rising = guardian.format_destiny_rising_id(),
),
)
.await;
Expand Down
6 changes: 6 additions & 0 deletions bot/templates/editguar/usage.tera
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ Edit guardian information:

/editguar <id|@telegram|PSN|'my'>
List known guardian information

/editguar <id|@telegram|PSN|'my'> psn <NewPSN>
Change guardian's PSN

/editguar <id|@telegram|PSN|'my'> clan <Clan ticker, e.g. AEGL or \"delete\">
Change guardian's clan

/editguar <id|@telegram|PSN|'my'> email <NewEmail>
Change guardian's email

/editguar <id|@telegram|PSN|'my'> rising <Uid> [<Nickname>]
Change guardian's `Destiny: Rising` uid and optionally nickname.
2 changes: 1 addition & 1 deletion bot/templates/list/member.tera
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ member.icon }} {{ member.psn_name }} (t.me/{{ member.telegram_name }})
{{ member.icon }} {{ member.psn_name }} (t.me/{{ member.telegram_name }}) {{ member.rising_uid_and_nick }}
22 changes: 21 additions & 1 deletion entity/src/guardians.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use {sea_orm::entity::prelude::*, std::fmt};
// pending_activation_code -> Nullable<Text>,
// is_admin -> Bool,
// is_superadmin -> Bool,
// rising_uid -> Nullable<Int8>,
// }
// }

Expand Down Expand Up @@ -48,6 +49,8 @@ pub struct Model {
pub pending_activation_code: Option<String>,
pub is_admin: bool,
pub is_superadmin: bool,
pub rising_uid: Option<i64>,
pub rising_nickname: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down Expand Up @@ -80,7 +83,24 @@ impl fmt::Display for Model {

impl Model {
pub fn format_name(&self) -> String {
format!("{} (t.me/{})", self.psn_name, self.telegram_name)
format!(
"{} (t.me/{}) {}",
self.psn_name,
self.telegram_name,
self.format_destiny_rising_id()
)
}

pub fn format_destiny_rising_id(&self) -> String {
if let Some(uid) = self.rising_uid {
if let Some(nickname) = &self.rising_nickname {
format!("(D:R uid {} nickname {})", uid, nickname)
} else {
format!("(D:R uid {})", uid)
}
} else {
String::new()
}
}

pub fn names(&self) -> (String, String) {
Expand Down
3 changes: 3 additions & 0 deletions entity/src/plannedactivitymembers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl ActiveModelBehavior for ActiveModel {}
pub struct ActivityMemberTemplate {
pub psn_name: String,
pub telegram_name: String,
pub rising_uid_and_nick: String,
pub icon: String,
}

Expand Down Expand Up @@ -95,9 +96,11 @@ impl Model {
.ok_or(DbErr::RecordNotFound("Guardian not found".to_string()))?;

let (telegram_name, psn_name) = guardian.names();
let rising_uid_and_nick = guardian.format_destiny_rising_id();
ActivityMemberTemplate {
psn_name,
telegram_name,
rising_uid_and_nick,
icon: self.icon(),
}
}
Expand Down
2 changes: 2 additions & 0 deletions migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod m20180508_101326_populate_activities;
mod m20180905_090102_populate_activities;
mod m20180921_110336_add_admins;
mod m20180922_104727_add_superadmins;
mod m20250828_224244_add_destiny_rising_uids;
mod tables;

pub use tables::*;
Expand All @@ -29,6 +30,7 @@ impl MigratorTrait for Migrator {
Box::new(m20180905_090102_populate_activities::Migration),
Box::new(m20180921_110336_add_admins::Migration),
Box::new(m20180922_104727_add_superadmins::Migration),
Box::new(m20250828_224244_add_destiny_rising_uids::Migration),
]
}
}
34 changes: 34 additions & 0 deletions migration/src/m20250828_224244_add_destiny_rising_uids.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use {
crate::Guardians,
sea_orm_migration::{prelude::*, schema::*},
};

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Guardians::Table)
.add_column(big_integer_null(Guardians::RisingUid))
.add_column(string_null(Guardians::RisingNickname))
.to_owned(),
)
.await
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Guardians::Table)
.drop_column(Guardians::RisingUid)
.drop_column(Guardians::RisingNickname)
.to_owned(),
)
.await
}
}
2 changes: 2 additions & 0 deletions migration/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ pub enum Guardians {
PendingActivationCode,
IsAdmin,
IsSuperadmin,
RisingUid,
RisingNickname,
}