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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -260,15 +261,19 @@ func (mtrx *MtrxClient) handleCommand(ctx context.Context, evt *event.Event) {
|
||||||
}
|
}
|
||||||
filesearch := strings.ReplaceAll(args[0], ".", "")
|
filesearch := strings.ReplaceAll(args[0], ".", "")
|
||||||
|
|
||||||
//filename quote
|
// lookup filename from quote, shuffle each time
|
||||||
for _, v := range mtrx.pics {
|
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)) {
|
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)
|
mtrx.postBirbWithText(ctx, evt, mtrx.getAnyRandomQuoteSearch(true, strings.Join(args[1:], " ")), 0, v)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mtrx.sendMessage(ctx, evt.RoomID, "Can't find file with prefix: "+file)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue