mirror of
https://github.com/idanoo/gomatrixbot
synced 2025-07-22 16:39:11 +00:00
Shuffle images for .<filename>
This commit is contained in:
parent
0bb7067557
commit
be94d805cf
1 changed files with 9 additions and 4 deletions
|
@ -3,6 +3,7 @@ package gomatrixbot
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -260,15 +261,19 @@ func (mtrx *MtrxClient) handleCommand(ctx context.Context, evt *event.Event) {
|
|||
}
|
||||
filesearch := strings.ReplaceAll(args[0], ".", "")
|
||||
|
||||
//filename quote
|
||||
for _, v := range mtrx.pics {
|
||||
// lookup filename from quote, shuffle each time
|
||||
tmpPics := make([]string, len(mtrx.pics))
|
||||
perm := rand.Perm(len(mtrx.pics))
|
||||
for i, v := range perm {
|
||||
tmpPics[v] = mtrx.pics[i]
|
||||
}
|
||||
|
||||
for _, v := range tmpPics {
|
||||
if strings.Contains(strings.ToLower(strings.Split(v, ".")[0]), strings.ToLower(filesearch)) {
|
||||
mtrx.postBirbWithText(ctx, evt, mtrx.getAnyRandomQuoteSearch(true, strings.Join(args[1:], " ")), 0, v)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// mtrx.sendMessage(ctx, evt.RoomID, "Can't find file with prefix: "+file)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue