utils

package
v1.5.1-0...-06e15ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* This file is part of YukkiMusic. * * YukkiMusic — A Telegram bot that streams music into group voice chats with seamless playback and control. * Copyright (C) 2025 TheTeamVivek * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddChatAdmin

func AddChatAdmin(c *telegram.Client, chatID, userID int64) error

Adds a user to the cached admin list, auto-reloading if cache is missing

func CanAct

func CanAct(key string) bool

CanAct returns true if the key is allowed to act (cooldown expired).

func CleanURL

func CleanURL(raw string) string

func EOR

func EOR(msg *telegram.NewMessage, text string, opts ...telegram.SendOptions) (m *telegram.NewMessage, err error)

func ExtractURLs

func ExtractURLs(m *telegram.NewMessage) ([]string, error)

func ExtractUser

func ExtractUser(m *telegram.NewMessage) (int64, error)

func GetDuration

func GetDuration(f *telegram.MessageMediaDocument) int

func GetDurationByFFProbe

func GetDurationByFFProbe(filePath string) (int, error)

func GetFlood

func GetFlood(key string) time.Duration

GetFlood returns the remaining cooldown time for a key. If zero or negative, the action is allowed.

func GetPeerID

func GetPeerID(c *telegram.Client, chatId any) (int64, error)

func GetProgress

func GetProgress(mystic *telegram.NewMessage) *telegram.ProgressManager

func GetProgressBar

func GetProgressBar(playedSec, durationSec int) string

func IsChatAdmin

func IsChatAdmin(c *telegram.Client, chatID, userID int64) (bool, error)

Checks if a user is an admin in a chat

func MentionHTML

func MentionHTML(u *telegram.UserObj) string

func ParseBool

func ParseBool(s string) (bool, error)

ParseBool converts strings like "on", "off", "enable", "disable", "true", "false" into a boolean value. Returns an error if input is invalid.

func ReloadChatAdmin

func ReloadChatAdmin(c *telegram.Client, chatID int64) ([]int64, error)

Reloads the chat admins from Telegram and updates the cache

func RemoveChatAdmin

func RemoveChatAdmin(c *telegram.Client, chatID, userID int64) error

Removes a user from the cached admin list, auto-reloading if cache is missing

func SetFlood

func SetFlood(key string, duration time.Duration)

SetFlood sets a flood timeout for the key. 'duration' specifies how long the key should be blocked.

func ShortTitle

func ShortTitle(title string, max ...int) string

Types

type Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[K comparable, V any](defaultTTL time.Duration) *Cache[K, V]

func (*Cache[K, V]) Delete

func (c *Cache[K, V]) Delete(key K)

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(key K) (V, bool)

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(key K, value V, ttl ...time.Duration)

type CacheItem

type CacheItem[V any] struct {
	Value      V
	Expiration int64
}

func (CacheItem[V]) Expired

func (i CacheItem[V]) Expired() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL