bump libs
migrate to typescript 6 remove ytdl feature
This commit is contained in:
@@ -3,7 +3,7 @@ import {CallbackCommand} from "../base/callback-command";
|
||||
export class Cancel extends CallbackCommand {
|
||||
|
||||
text = "❌ Отменить";
|
||||
data = null;
|
||||
data = "";
|
||||
|
||||
constructor(text?: string, data?: string) {
|
||||
super();
|
||||
@@ -13,7 +13,7 @@ export class Cancel extends CallbackCommand {
|
||||
}
|
||||
|
||||
static withData(data?: string): Cancel {
|
||||
return new Cancel(null, data);
|
||||
return new Cancel("", data);
|
||||
}
|
||||
|
||||
async execute(): Promise<void> {
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import {CallbackCommand} from "../base/callback-command";
|
||||
import {CallbackQuery} from "typescript-telegram-bot-api";
|
||||
import {Requirements} from "../base/requirements";
|
||||
import {Requirement} from "../base/requirement";
|
||||
import {commands} from "../index";
|
||||
import {YouTubeDownload} from "../commands/youtube-download";
|
||||
|
||||
const downloadText = " 📥 Скачать";
|
||||
const getFromCacheText = "📥 Загрузить из кэша";
|
||||
|
||||
export class DownloadYtVideo extends CallbackCommand {
|
||||
data = "/ytdl";
|
||||
text = " 📥 Скачать";
|
||||
|
||||
requirements = Requirements.Build(Requirement.SAME_USER);
|
||||
|
||||
constructor(text?: string, data?: string) {
|
||||
super();
|
||||
|
||||
this.text = text || this.text;
|
||||
this.data = data || this.data;
|
||||
}
|
||||
|
||||
static withData(inCache?: boolean, data?: string): DownloadYtVideo {
|
||||
return new DownloadYtVideo(inCache ? getFromCacheText : downloadText, data);
|
||||
}
|
||||
|
||||
async execute(query: CallbackQuery): Promise<void> {
|
||||
const videoId = query.data.split(" ")[1];
|
||||
if (!videoId) return;
|
||||
|
||||
const yt = commands.find(c => c instanceof YouTubeDownload);
|
||||
if (!yt) return;
|
||||
await yt.downloadYouTubeVideo(query.message, {videoId: videoId});
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ export class OllamaCancel extends CallbackCommand {
|
||||
requirements = Requirements.Build(Requirement.SAME_USER);
|
||||
|
||||
async execute(query: CallbackQuery): Promise<void> {
|
||||
if (!query.message || !query.data) return;
|
||||
|
||||
const chatId = query.message.chat.id;
|
||||
const fromId = query.from.id;
|
||||
const messageId = query.message.message_id;
|
||||
@@ -44,7 +46,7 @@ export class OllamaCancel extends CallbackCommand {
|
||||
|
||||
let content: string | null = null;
|
||||
|
||||
if (msg?.text?.trim()?.length > 0) {
|
||||
if (msg?.text?.trim()?.length) {
|
||||
content = msg?.text.trim();
|
||||
if (content.length + Environment.ollamaCancelledText.length > 4096) {
|
||||
content = content.substring(0, 4096 - Environment.ollamaCancelledText.length - 2) + "\n";
|
||||
|
||||
@@ -12,7 +12,7 @@ export class TryAgain extends CallbackCommand {
|
||||
}
|
||||
|
||||
static withData(data?: string): TryAgain {
|
||||
return new TryAgain(null, data);
|
||||
return new TryAgain("", data);
|
||||
}
|
||||
|
||||
async execute(): Promise<void> {
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import {CallbackCommand} from "../base/callback-command";
|
||||
import {CallbackQuery} from "typescript-telegram-bot-api";
|
||||
import {processYouTubeLink} from "../util/utils";
|
||||
|
||||
export class YtInfo extends CallbackCommand {
|
||||
data = "/ytinfo";
|
||||
text: string;
|
||||
|
||||
async execute(query: CallbackQuery): Promise<void> {
|
||||
const videoId = query.data.split(" ")[1];
|
||||
if (!videoId) return;
|
||||
|
||||
await processYouTubeLink(query.message, null, videoId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user