Skip to content

Commit

Permalink
Fix IRC publish (#568)
Browse files Browse the repository at this point in the history
* Improve irc publish

* Update docs/changelog.md
  • Loading branch information
waybackarchiver authored Sep 6, 2024
1 parent b15a77d commit 9f0e48c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fix playback from discord no response
- Improve IRC publish

## [0.20.1] - 2024-07-02

Expand Down
18 changes: 16 additions & 2 deletions publish/relaychat/relaychat.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/wabarc/wayback"
"github.com/wabarc/wayback/config"
"github.com/wabarc/wayback/errors"
"github.com/wabarc/wayback/ingress"
"github.com/wabarc/wayback/metrics"
"github.com/wabarc/wayback/publish"
"github.com/wabarc/wayback/reduxer"
Expand Down Expand Up @@ -44,9 +45,22 @@ func (i *IRC) Publish(ctx context.Context, _ reduxer.Reduxer, cols []wayback.Col
// this value accessed from service module.
if i.conn == nil {
v := ctx.Value(publish.FlagIRC)
conn, ok := v.(*irc.Client)
client, ok := v.(*irc.Client)
if ok {
i.conn = conn
i.conn = client
} else {
config := irc.ClientConfig{
Nick: i.opts.IRCNick(),
User: i.opts.IRCNick(),
Name: i.opts.IRCName(),
Pass: i.opts.IRCPassword(),
}
dialer := ingress.Dialer()
conn, err := dialer.Dial("tcp", i.opts.IRCServer())
if err != nil {
return err
}
i.conn = irc.NewClient(conn, config)
}
}

Expand Down
4 changes: 2 additions & 2 deletions template/render/relaychat.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func (i *Relaychat) main() *bytes.Buffer {
func (i *Relaychat) join(buf *bytes.Buffer) *bytes.Buffer {
tmplBytes := &bytes.Buffer{}
tmplBytes.WriteString("***** List of Archives *****")
tmplBytes.WriteString("\n \n") // blank line
tmplBytes.WriteString("\n")
tmplBytes.Write(buf.Bytes())
tmplBytes.WriteString("\n \n") // blank line
tmplBytes.WriteString("\n")
tmplBytes.WriteString("***** End of Archives *****")
return tmplBytes
}
2 changes: 0 additions & 2 deletions template/render/relaychat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

func TestRenderForIRC(t *testing.T) {
expected := `***** List of Archives *****
‹ Example ›
• Source
Expand All @@ -26,7 +25,6 @@ func TestRenderForIRC(t *testing.T) {
> https://ipfs.io/ipfs/QmTbDmpvQ3cPZG6TA5tnar4ZG6q9JMBYVmX2n3wypMQMtr
• Telegraph:
> http://telegra.ph/title-01-01
***** End of Archives *****`

got := ForPublish(&Relaychat{Cols: collects, Data: bundleExample}).String()
Expand Down

0 comments on commit 9f0e48c

Please sign in to comment.