mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-08 07:11:06 +00:00
fix: bufio.Scanner message too long
This commit is contained in:
parent
96c8117135
commit
0bb4f58222
@ -23,8 +23,6 @@ func Cli(version string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
println("Message: " + currentFlags.Message)
|
||||
|
||||
if currentFlags.Version {
|
||||
fmt.Println(version)
|
||||
return
|
||||
|
22
cli/flags.go
22
cli/flags.go
@ -95,18 +95,20 @@ func Init() (ret *Flags, err error) {
|
||||
|
||||
// readStdin reads from stdin and returns the input as a string or an error
|
||||
func readStdin() (ret string, err error) {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
ret += scanner.Text() + "\n"
|
||||
}
|
||||
if err = scanner.Err(); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
err = nil
|
||||
} else {
|
||||
err = fmt.Errorf("error reading piped message from stdin: %w", err)
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
var sb strings.Builder
|
||||
for {
|
||||
line, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
sb.WriteString(line)
|
||||
break
|
||||
}
|
||||
return "", fmt.Errorf("error reading piped message from stdin: %w", err)
|
||||
}
|
||||
sb.WriteString(line)
|
||||
}
|
||||
return
|
||||
return sb.String(), nil
|
||||
}
|
||||
|
||||
func (o *Flags) BuildChatOptions() (ret *common.ChatOptions) {
|
||||
|
@ -59,6 +59,7 @@ func (o *YouTube) GetVideoOrPlaylistId(url string) (videoId string, playlistId s
|
||||
}
|
||||
|
||||
// Video ID pattern
|
||||
//https:((youtu.be/7qZl_5xHoBw
|
||||
videoPattern := `(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})`
|
||||
videoRe := regexp.MustCompile(videoPattern)
|
||||
videoMatch := videoRe.FindStringSubmatch(url)
|
||||
|
Loading…
Reference in New Issue
Block a user