Files
neo/helper/media.go
T
FdandClaude Opus 4.7 e783284881 feat: add download commands (yt, ig, tt, fb) and middleware support
- Add core Middleware support via `core.Default.Use()`
- Implement download command handlers for YouTube, Instagram, TikTok, and Facebook
- Add regex-based URL validation for all download commands
- Add API client for fetching download links
- Add helpers for uploading and sending media to WhatsApp

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-07-15 10:33:58 +07:00

50 lines
1.2 KiB
Go

package helper
import (
"strings"
hc "neo/context"
)
func SendMedia(ctx *hc.Ctx, data []byte, mime, caption string) {
switch {
case strings.HasPrefix(mime, "video/mp4"):
ctx.SendVideo(data, caption)
case strings.HasPrefix(mime, "image/"):
ctx.SendImage(data, caption)
case strings.HasPrefix(mime, "audio/"):
ctx.SendAudio(data)
default:
ctx.SendDocument(data, "media", "media"+extByMIME(mime))
}
}
func extByMIME(mime string) string {
switch {
case strings.HasPrefix(mime, "video/mp4"):
return ".mp4"
case strings.HasPrefix(mime, "video/webm"):
return ".webm"
case strings.HasPrefix(mime, "video/quicktime"):
return ".mov"
case strings.HasPrefix(mime, "video/x-matroska"):
return ".mkv"
case strings.HasPrefix(mime, "video/"):
return ".video"
case strings.HasPrefix(mime, "image/jpeg"):
return ".jpg"
case strings.HasPrefix(mime, "image/png"):
return ".png"
case strings.HasPrefix(mime, "image/gif"):
return ".gif"
case strings.HasPrefix(mime, "image/webp"):
return ".webp"
case strings.HasPrefix(mime, "audio/mpeg"), strings.HasPrefix(mime, "audio/mp3"):
return ".mp3"
case strings.HasPrefix(mime, "audio/"):
return ".m4a"
default:
return ".bin"
}
}