mirror of
https://github.com/lyx0/nourybot-matrix.git
synced 2024-11-13 19:49:54 +01:00
7e46dd6f8a
yaf downloads a link to a video with yt-dlp and uploads the video to yaf.li
36 lines
1 KiB
Go
36 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"maunium.net/go/mautrix/event"
|
|
)
|
|
|
|
func (app *application) ParseCommand(evt *event.Event) {
|
|
// commandName is the actual name of the command without the prefix.
|
|
// e.g. `!ping` would be `ping`.
|
|
commandName := strings.ToLower(strings.SplitN(evt.Content.AsMessage().Body, " ", 2)[0][1:])
|
|
|
|
// cmdParams are additional command parameters.
|
|
// e.g. `!weather san antonio`
|
|
// cmdParam[0] is `san` and cmdParam[1] = `antonio`.
|
|
cmdParams := strings.SplitN(evt.Content.AsMessage().Body, " ", 500)
|
|
app.Log.Info().Msgf("cmdParams: %s", cmdParams)
|
|
|
|
// msgLen is the amount of words in a message without the prefix.
|
|
// Useful to check if enough cmdParams are provided.
|
|
//msgLen := len(strings.SplitN(evt.Content.AsMessage().Body, " ", -2))
|
|
|
|
app.Log.Info().Msgf("Command: %s", evt.Content.AsMessage().Body)
|
|
|
|
//message := evt.Content.AsMessage().Body
|
|
switch commandName {
|
|
case "xd":
|
|
app.SendText(evt, "xd !")
|
|
return
|
|
case "yaf":
|
|
app.NewDownload("yaf", evt, cmdParams[1])
|
|
return
|
|
}
|
|
}
|