Skip to content

Commit

Permalink
Merge pull request #30 from kozalosev/release/1.2.1
Browse files Browse the repository at this point in the history
Release 1.2.1. Documentation and some missed features
  • Loading branch information
Leonid Kozarin authored Apr 30, 2024
2 parents 2181a2c + 9a53a2c commit e0f941f
Show file tree
Hide file tree
Showing 30 changed files with 357 additions and 206 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ DATABASE_URL=postgres://dickgrowerbot:dgb4pwd@localhost:5432/dickgrowerbotdb
DATABASE_MAX_CONNECTIONS=10

HELP_ADMIN_USERNAME=kozalo
HELP_ADMIN_CHANNEL=kozaloru
HELP_ADMIN_CHANNEL_RU=kozaloru
HELP_ADMIN_CHANNEL_EN=kozalo_blog
HELP_GIT_REPO=https://github.com/kozalosev/DickGrowerBot

CHATS_MERGING_ENABLED=true
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ ARG WEBHOOK_URL
ARG DATABASE_URL
ARG DATABASE_MAX_CONNECTIONS
ARG HELP_ADMIN_USERNAME
ARG HELP_ADMIN_CHANNEL
ARG HELP_ADMIN_CHANNEL_RU
ARG HELP_ADMIN_CHANNEL_EN
ARG HELP_GIT_REPO
ARG CHATS_MERGING_ENABLED
ARG TOP_UNLIMITED_ENABLED
Expand All @@ -51,6 +52,8 @@ ARG GROW_SHRINK_RATIO
ARG GROWTH_DOD_BONUS_MAX
ARG NEWCOMERS_GRACE_DAYS
ARG TOP_LIMIT
ARG HELP_PUSSIES_COEF
ARG LOAN_PAYOUT_COEF
ENTRYPOINT [ "/usr/local/bin/dickGrowerBot" ]

LABEL org.opencontainers.image.source=https://github.com/kozalosev/DickGrowerBot
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ services:
- DATABASE_URL=postgres://${POSTGRES_USER:?error}:${POSTGRES_PASSWORD:?error}@${POSTGRES_HOST:?error}:${POSTGRES_PORT:-5432}/${POSTGRES_DB:?error}
- DATABASE_MAX_CONNECTIONS
- HELP_ADMIN_USERNAME
- HELP_ADMIN_CHANNEL
- HELP_ADMIN_CHANNEL_RU
- HELP_ADMIN_CHANNEL_EN
- HELP_GIT_REPO
- CHATS_MERGING_ENABLED
- TOP_UNLIMITED_ENABLED
Expand All @@ -23,6 +24,8 @@ services:
- GROWTH_DOD_BONUS_MAX
- NEWCOMERS_GRACE_DAYS
- TOP_LIMIT
- HELP_PUSSIES_COEF
- LOAN_PAYOUT_COEF
expose:
- 8080
networks:
Expand Down
10 changes: 6 additions & 4 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ commands:
description: "Fight with your friend's dick!"
results:
start: "<b>%{name}</b> challenged the chat with a bet of <b>%{bet} cm</b>!"
finish: "The winner is <b>%{winner_name}</b>! His dick is now <b>%{winner_length} cm</b> long. The loser's one is <b>%{loser_length}</b>."
finish: "The winner is <b>%{winner_name}</b>! His dick is now <b>%{winner_length} cm</b> long. The loser's one is <b>%{loser_length}</b>.\nThe bet was <b>%{bet} cm</b>."
position:
winner: "<b>%{name}</b>'s position in the top is <b>%{pos}</b>."
loser: "<b>%{name}</b>'s position in the top is <b>%{pos}</b>."
withheld: "<b>%{payout} cm</b> were withheld from the winner to pay off the loan."
button: "Attack!"
errors:
no_args: "Call the command with a number of centimeters you're willing to bet."
Expand All @@ -40,13 +41,14 @@ commands:
description: "Take a loan if you have a deep cave"
debt: "Left to pay <b>%{debt} cm</b>"
confirmation:
text: "Your deep hole will be reset to zero, but each growth will be lowered by <b>%{payout_percentage}%</b> until all <b>%{debt} cm</b> is repaid."
text: "Your deep hole will be reset to zero, but each growth will be lowered by <b>%{payout_percentage}</b> until all <b>%{debt} cm</b> is repaid."
buttons:
agree: "I'm in!"
disagree: "Disagree"
callback:
success: "Perk «Where is my centimeters, Lebowski?» has been assigned successfully!"
refused: "The patient refused gender reassignment on credit."
payout_ratio_changed: "The payout rate has been changed since you sent the loan application. Please, invoke the command again."
errors:
positive_length: "I cannot make your little bro bigger. Only change your gender."
import:
Expand Down Expand Up @@ -99,8 +101,8 @@ titles:
some: "\n\nNext attempt in <b>%{hours}</b>h <b>%{minutes}</b>m."
perks:
top_line: "The following perks affected the result"
help-pussies: "Deep hole"
loan-payout: "Micro-loaner"
help-pussies: "deep hole"
loan-payout: "micro-loaner"
errors:
not_group_chat: "This bot is supposed to do its mission in group chats only!"
feature_disabled: "This feature is currently temporarily disabled."
10 changes: 6 additions & 4 deletions locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ commands:
description: "Сражайся с пипирками друзей!"
results:
start: "<b>%{name}</b> бросил чату вызов со ставкой <b>%{bet} см</b>!"
finish: "Победитель — <b>%{winner_name}</b>! Его пипирик теперь равен <b>%{winner_length} см</b>, а проигравшего — <b>%{loser_length} см</b>."
finish: "Победитель — <b>%{winner_name}</b>! Его пипирик теперь равен <b>%{winner_length} см</b>, а проигравшего — <b>%{loser_length} см</b>.\nСтавка была <b>%{bet} см</b>."
position:
winner: "<b>%{name}</b> занимает <b>%{pos}</b> место в топе."
loser: "<b>%{name}</b> занимает <b>%{pos}</b> место в топе."
withheld: "<b>%{payout} см</b> было удержано с победителя для погашения задолженности."
button: "Атаковать!"
errors:
no_args: "Вызови команду с числом сантиметров, которые готов поставить."
Expand All @@ -40,13 +41,14 @@ commands:
description: "Возьми кредит, если у тебя глубокая пещера"
debt: "Осталось выплатить <b>%{debt} см</b>"
confirmation:
text: "Твоя пропасть будет обнулена, но размер каждого прироста снизится на <b>%{payout_percentage}%</b> до выплаты всех <b>%{debt} см</b>."
text: "Твоя пропасть будет обнулена, но размер каждого прироста снизится на <b>%{payout_percentage}</b> до выплаты всех <b>%{debt} см</b>."
buttons:
agree: "Согласен"
disagree: "Я пас"
callback:
success: "Перк «Где мои сантиметры, Лебовски?» успешно предоставлен!"
refused: "Пациент отказался от смены пола в кредит."
payout_ratio_changed: "С момента подачи заявления ставка выплаты изменилась. Пожалуйста, вызовите команду ещё раз."
errors:
positive_length: "Увеличение братюни недоступно: только смена пола."
import:
Expand Down Expand Up @@ -99,8 +101,8 @@ titles:
some: "\n\nСледующая попытка через <b>%{hours}</b> ч. <b>%{minutes}</b> мин."
perks:
top_line: "На результат повлияли следующие перки"
help-pussies: "Глубокая нора"
loan-payout: "Микрозаймер"
help-pussies: "глубокая нора"
loan-payout: "микрозаймер"
errors:
not_group_chat: "Бот выполняет свою миссию только в групповых чатах!"
feature_disabled: "Данная функция пока временно отключена."
3 changes: 3 additions & 0 deletions migrations/16_add-loans-column-payout-ratio.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE Loans ADD COLUMN IF NOT EXISTS payout_ratio real NOT NULL DEFAULT 0.1
CHECK ( payout_ratio > 0.0 AND payout_ratio < 1.0 );
ALTER TABLE Loans ALTER COLUMN payout_ratio DROP DEFAULT;
10 changes: 9 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ use std::str::FromStr;
use anyhow::anyhow;
use reqwest::Url;
use teloxide::types::Me;
use crate::handlers::perks::HelpPussiesPerk;
use crate::handlers::utils::Incrementor;
use crate::help;

#[derive(Clone)]
pub struct AppConfig {
pub features: FeatureToggles,
pub top_limit: u16,
pub loan_payout_ratio: f32,
}

#[derive(Clone)]
Expand Down Expand Up @@ -45,6 +47,7 @@ pub struct BattlesFeatureToggles {
impl AppConfig {
pub fn from_env() -> Self {
let top_limit = get_env_value_or_default("TOP_LIMIT", 10);
let loan_payout_ratio = get_env_value_or_default("LOAN_PAYOUT_COEF", 0.0);
let chats_merging = get_env_value_or_default("CHATS_MERGING_ENABLED", false);
let top_unlimited = get_env_value_or_default("TOP_UNLIMITED_ENABLED", false);
let check_acceptor_length = get_env_value_or_default("PVP_CHECK_ACCEPTOR_LENGTH", false);
Expand All @@ -57,6 +60,7 @@ impl AppConfig {
}
},
top_limit,
loan_payout_ratio,
}
}
}
Expand Down Expand Up @@ -84,8 +88,12 @@ pub fn build_context_for_help_messages(me: Me, incr: &Incrementor, competitor_bo
grow_max: incr_cfg.growth_range_max().to_string(),
other_bots,
admin_username: ensure_starts_with_at_sign(get_env_mandatory_value("HELP_ADMIN_USERNAME")?),
admin_channel: ensure_starts_with_at_sign(get_env_mandatory_value("HELP_ADMIN_CHANNEL")?),
admin_channel_ru: ensure_starts_with_at_sign(get_env_mandatory_value("HELP_ADMIN_CHANNEL_RU")?),
admin_channel_en: ensure_starts_with_at_sign(get_env_mandatory_value("HELP_ADMIN_CHANNEL_EN")?),
git_repo: get_env_mandatory_value("HELP_GIT_REPO")?,
help_pussies_percentage: incr.find_perk_config::<HelpPussiesPerk>()
.map(|payout_ratio| payout_ratio * 100.0)
.unwrap_or(0.0)
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl InlineCommand {
},
InlineCommand::Loan => {
metrics::CMD_LOAN_COUNTER.invoked.inline.inc();
loan::loan_impl(repos, from_refs, incr)
loan::loan_impl(repos, from_refs, config)
.await
.map(InlineResult::from)
}
Expand Down
Loading

0 comments on commit e0f941f

Please sign in to comment.