Skip to content

Commit 1c93703

Browse files
committed
feat: Imporve /info command
1 parent 0b13fd9 commit 1c93703

8 files changed

Lines changed: 40 additions & 12 deletions

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ API_ENDPOINTS='[
1212
]'
1313
ERROR_CHAT_ID= # Optional, Telegram chat ID that recieves all unhandled exceptions.
1414
CUSTOM_INSTANCE_PROXY_URL= # Optional, HTTP proxy that gets used for all custom instances and for instances marked with `unsafe` flag.
15+
ADDITIONAL_INFO= #Optional, can be multi-line, added after main text in `/info`

locales/en.ftl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
start = hii! just send me a link and i'll download it. (ᵔᵕᵔ)◜
1+
start =
2+
hii! just send me a link and i'll download it. (ᵔᵕᵔ)◜
3+
details: /info
24
35
error-title = error
46
error = { error-title }: { $message } { $error-emoticon }
@@ -68,7 +70,13 @@ setting-audio-quality = audio bitrate
6870
stats-personal = i helped you with downloading { $count } times! (˶ᵔ ᵕ ᵔ˶)
6971
stats-global = i helped with downloading { $count } times! (˶ᵔ ᵕ ᵔ˶)
7072
73+
info-open = about me
7174
info =
75+
i can download videos, photos and music from any service supported by cobalt!
76+
you can use me right here in pms or in any chat via inline mode.
77+
7278
running { $name }@{ $version }
7379
sources: { $repository }
74-
report bugs: { $bugs }
80+
report bugs: { $bugs }
81+
news & updates: { $homepage }
82+
supported services: https://github.com/imputnet/cobalt/tree/main/api#supported-services

locales/ru.ftl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
start = привет! просто отправь мне ссылку и я её скачаю. (ᵔᵕᵔ)◜
1+
start =
2+
привет! просто отправь мне ссылку и я её скачаю. (ᵔᵕᵔ)◜
3+
подробнее: /info
24
35
error-title = ошибка
46
error = { error-title }: { $message } { $error-emoticon }
@@ -54,7 +56,13 @@ setting-audio-quality = битрейт аудио
5456
stats-personal = я помог тебе с загрузкой { $count } раз! (˶ᵔ ᵕ ᵔ˶)
5557
stats-global = я помог с загрузкой { $count } раз! (˶ᵔ ᵕ ᵔ˶)
5658
59+
info-open = обо мне
5760
info =
61+
я умею скачивать видео, фото и музыку из любих сервисов, которые доступны в cobalt!
62+
меня можно использовать прямо тут в лс или в любом чате через инлайн.
63+
5864
выполняется { $name }@{ $version }
5965
сурсы: { $repository }
60-
репорт багов: { $bugs }
66+
репорт багов: { $bugs }
67+
новости и апдейты: { $homepage }
68+
поддерживаемые сервисы: https://github.com/imputnet/cobalt/tree/main/api#supported-services

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "cobold",
33
"version": "3.1.0",
4+
"homepage": "https://t.me/coboldlogs",
45
"repository": "https://github.com/tskau/cobold",
56
"bugs": "https://github.com/tskau/cobold/issues",
67
"private": true,

src/telegram/bot/download.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@ downloadDp.onNewMessage(filters.chat("user"), async (msg) => {
6262
downloadDp.onInlineQuery(async (ctx) => {
6363
const { t, e } = await evaluatorsFor(ctx.user)
6464

65+
const infoSwitchPm = {
66+
text: t("info-open"),
67+
parameter: "info",
68+
}
69+
6570
const settingsSwitchPm = {
6671
text: t("settings-open"),
6772
parameter: "settings",
6873
}
6974

7075
if (!ctx.query.trim()) {
71-
await ctx.answer([], { switchPm: settingsSwitchPm })
76+
await ctx.answer([], { cacheTime: 0, switchPm: infoSwitchPm })
7277
return
7378
}
7479

src/telegram/bot/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const dp = Dispatcher.for<BotState>(bot, {
2222

2323
dp.onError(createDispatcherErrorHandler(bot))
2424
dp.extend(settingsDp)
25+
dp.extend(infoDp)
2526
dp.extend(startDp)
2627
dp.extend(statsDp)
27-
dp.extend(infoDp)
2828
dp.extend(downloadDp)
2929

3030
export async function startBot() {

src/telegram/bot/info.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { Dispatcher, filters } from "@mtcute/dispatcher"
2-
import { bugs, name, repository, version } from "@/../package.json"
3-
import { settingsDp } from "@/telegram/bot/settings"
2+
import { bugs, homepage, name, repository, version } from "@/../package.json"
3+
import { env } from "@/telegram/helpers/env"
44
import { evaluatorsFor } from "@/telegram/helpers/text"
55

66
export const infoDp = Dispatcher.child()
77

8-
settingsDp.onNewMessage(filters.command("info"), async (msg) => {
9-
const { t } = await evaluatorsFor(msg.sender)
10-
await msg.replyText(t("info", { bugs, name, repository, version }))
11-
})
8+
infoDp.onNewMessage(
9+
filters.or(filters.command("info"), filters.deeplink(["info"])),
10+
async (msg) => {
11+
const { t } = await evaluatorsFor(msg.sender)
12+
const infoText = t("info", { bugs, name, repository, version, homepage })
13+
await msg.replyText(`${infoText}\n\n${env.ADDITIONAL_INFO}`)
14+
},
15+
)

src/telegram/helpers/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const env = createEnv({
2828
.pipe(z.array(apiServerSchema)),
2929
ERROR_CHAT_ID: z.coerce.number().int().optional(),
3030
CUSTOM_INSTANCE_PROXY_URL: z.string().url().optional(),
31+
ADDITIONAL_INFO: z.string().optional().default(""),
3132
},
3233
emptyStringAsUndefined: true,
3334
runtimeEnv: process.env,

0 commit comments

Comments
 (0)