Skip to content

Commit

Permalink
Add option to disable sale of new accounts
Browse files Browse the repository at this point in the history
When the server is at full capacity you would need to disable
the sale of new accounts and only allow renewals. Now this option
is added under "Telegram CRM" settings menu.
  • Loading branch information
mjef committed May 14, 2023
1 parent 7a37191 commit bd9dcb1
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions translation/crm.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"msgNotActive": "This feature is not available. Please contact support!",
"msgTrafficExceeds85": "The account below has exceeded 85% of its quota! Please consider renewing.",
"msgAccExpiringSoon": "The account below expires in less than 24 hours. Please consider renewing.",
"msgSoldOut": "Sorry! Currently this server is at full capacity. You can only renew your current accounts.",

"incorrectUuid": "Incorrect UUID!",
"yes": "Yes",
Expand Down
1 change: 1 addition & 0 deletions translation/crm.fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"msgNotActive": "این قابلیت فعال نمی باشد. لطفا با پشتیبانی تماس بگیرید.",
"msgTrafficExceeds85": "شما بیش از 85 درصد ترافیک سرویس زیر را مصرف نموده اید. در صورت تمایل برای تمدید اقدام کنید.",
"msgAccExpiringSoon": "سرویس زیر کمتر از 24 ساعت دیگر منقضی می شود. لطفا نسبت به تمدید اشتراک اقدام نمایید.",
"msgSoldOut": "با عرض پوزش ظرفیت این سرور تکمیل شده و فقط تمدید سرویسهای فعلی امکان پذیر می باشد.",

"incorrectUuid": "شناسه کاربری صحیح نمی باشد.",
"yes": "بله",
Expand Down
1 change: 1 addition & 0 deletions translation/crm.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"msgNotActive": "Эта функция недоступна. Пожалуйста, свяжитесь с поддержкой!",
"msgTrafficExceeds85": "Этот аккаунт израсходовал свой пакет на 85%! Пожалуйста, подумайте о продлении заранее.",
"msgAccExpiringSoon": "Срок действия этого аккаунта истекает менее чем через 24 часа. Пожалуйста, подумайте о продлении заранее.",
"msgSoldOut": "Извини! В настоящее время этот сервер загружен на полную мощность. Вы можете только продлить свои текущие учетные записи.",

"incorrectUuid": "Неверный ID!",
"yes": "Да",
Expand Down
1 change: 1 addition & 0 deletions web/assets/js/model/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class AllSetting {
this.tgRunTime = "";
this.xrayTemplateConfig = "";
this.tgCrmEnabled = false;
this.tgCrmSoldOut = false;
this.tgClientRegAccList = "";
this.tgClientRegFinalMsg = "";
this.tgMoneyTransferMsg = "";
Expand Down
1 change: 1 addition & 0 deletions web/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type AllSetting struct {
TgRunTime string `json:"tgRunTime" form:"tgRunTime"`
XrayTemplateConfig string `json:"xrayTemplateConfig" form:"xrayTemplateConfig"`
TgCrmEnabled bool `json:"tgCrmEnabled" form:"tgCrmEnabled"`
TgCrmSoldOut bool `json:"tgCrmSoldOut" form:"tgCrmSoldOut"`
TgClientRegAccList string `json:"tgClientRegAccList" form:"tgClientRegAccList"`
TgClientRegFinalMsg string `json:"tgClientRegFinalMsg" form:"tgClientRegFinalMsg"`
TgMoneyTransferMsg string `json:"tgMoneyTransferMsg" form:"tgMoneyTransferMsg"`
Expand Down
1 change: 1 addition & 0 deletions web/html/xui/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<a-tab-pane key="5" tab='{{ i18n "pages.setting.tg.telegramCrm"}}'>
<a-list item-layout="horizontal" style="background: white">
<setting-list-item type="switch" title='{{ i18n "pages.setting.tg.telegramCrmEnabled" }}' desc='{{ i18n "pages.setting.tg.telegramCrmEnableDesc" }}' v-model="allSetting.tgCrmEnabled"></setting-list-item>
<setting-list-item type="switch" title='{{ i18n "pages.setting.tg.telegramCrmSoldOut" }}' desc='{{ i18n "pages.setting.tg.telegramCrmSoldOutDesc" }}' v-model="allSetting.tgCrmSoldOut"></setting-list-item>
<setting-list-item type="number" title='{{ i18n "pages.setting.tg.telegramCrmTargetInbound" }}' desc='{{ i18n "pages.setting.tg.telegramCrmTargetInboundDesc" }}' v-model="allSetting.telegramCrmTargetInbound"></setting-list-item>
<setting-list-item type="textarea" title='{{ i18n "pages.setting.tg.telegramRegAccList"}}' v-model="allSetting.tgClientRegAccList"></setting-list-item>
<setting-list-item type="textarea" title='{{ i18n "pages.setting.tg.telegramRegApprovalMsg"}}' desc='{{ i18n "pages.setting.tg.telegramRegApprovalDesc" }}' v-model="allSetting.tgClientRegFinalMsg"></setting-list-item>
Expand Down
9 changes: 9 additions & 0 deletions web/service/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var defaultValueMap = map[string]string{
"tgBotChatId": "0",
"tgRunTime": "",
"tgCrmEnabled": "false",
"tgCrmSoldOut": "false",
"tgClientRegFinalMsg": "Congratulations! Your account is created. You will soon receive an email.",
"tgMoneyTransferMsg": "Please transfer the fee to the following wallet/account and send over the receipt.",
"tgClientRegAccList": "1- One user 1 month\n2- Two users 2 months",
Expand Down Expand Up @@ -300,6 +301,14 @@ func (s *SettingService) GetTgCrmEnabled() bool {
return crmEnabled
}

func (s *SettingService) GetTgCrmSoldOut() bool {
crmEnabled, err := s.getBool("tgCrmSoldOut")
if err != nil {
return false
}
return crmEnabled
}

func (s *SettingService) GetTgCrmRegFinalMsg() (string, error) {
return s.getString("tgClientRegFinalMsg")
}
Expand Down
5 changes: 5 additions & 0 deletions web/service/telegram_fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ func IdleState(s *TgSession, msg *tgbotapi.Message) *tgbotapi.MessageConfig {
break
}

if s.telegramService.settingService.GetTgCrmSoldOut() {
resp.Text = Tr("msgSoldOut", s.lang)
break
}

client, _ := s.telegramService.getTgClient(msg.Chat.ID)
s.client = client

Expand Down
2 changes: 2 additions & 0 deletions web/translation/translate.en_US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
"telegramCrm" = "Telegram CRM"
"telegramCrmEnabled" = "Telegram CRM"
"telegramCrmEnableDesc" = "Enable built-in client management system via TG bot"
"telegramCrmSoldOut" = "Disable sale"
"telegramCrmSoldOutDesc" = "Disable sale of new accounts on the server, only renewal will be enabled"
"telegramRegApprovalMsg" = "New account message"
"telegramRegApprovalDesc" = "Will be sent to the user right after the request is approved"
"telegramMoneyTransferMsg" = "Money transfer instructions"
Expand Down

0 comments on commit bd9dcb1

Please sign in to comment.