Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IRC publish #568

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading