Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
šŸ› fix(writer.go): add check for mainWriter buffer length in Close() mā€¦
Browse files Browse the repository at this point in the history
ā€¦ethod for DiscordWriter and TelegramWriter interfaces
  • Loading branch information
kamushadenes committed Mar 29, 2023
1 parent 22a4228 commit 22c9afc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion interfaces/discord/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (w *DiscordWriter) Flush() {
}

func (w *DiscordWriter) Close() error {
if len(w.bufs) > 0 && w.bufs[0].Len() > 0 {
if (len(w.bufs) > 0 && w.bufs[0].Len() > 0) ||
(w.mainWriter != nil && len(w.mainWriter.bufs) > 0 && w.mainWriter.bufs[0].Len() > 0) {
switch w.Type {
case "text":
return w.closeText()
Expand Down
3 changes: 2 additions & 1 deletion interfaces/telegram/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (w *TelegramWriter) Flush() {
}

func (w *TelegramWriter) Close() error {
if len(w.bufs) > 0 && w.bufs[0].Len() > 0 {
if (len(w.bufs) > 0 && w.bufs[0].Len() > 0) ||
(w.mainWriter != nil && len(w.mainWriter.bufs) > 0 && w.mainWriter.bufs[0].Len() > 0) {
switch w.Type {
case "text":
return w.closeText()
Expand Down

0 comments on commit 22c9afc

Please sign in to comment.