gruik

Fork of GCU-Squad's RSS-to-IRC bridge
git clone https://git.instinctive.eu/gruik.git
Log | Files | Refs | README | LICENSE

commit ef4334feee11de88eede9290c4106377e2b16d29
parent 6f7b49330da530b1b8a285d93e17b3e523ffaca7
Author: bleader <bleader@ratonland.org>
Date:   Wed, 18 Oct 2023 09:19:49 +0200

fix: no chanlist check for query targets

When using a "channel" that is actually a query, everything was ready to
work, except the part waiting for connexion to be complete, checking a
channel list, that is therefore empty as there is no channel to join.

Only checking channel list if "channel" name does not start by a '#' is
sufficient to make it work with queries.

Diffstat:
Mmain.go | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/main.go b/main.go @@ -117,7 +117,8 @@ func newsFetch(client *girc.Client, channel string) { } for { - if client.IsConnected() && len(client.ChannelList()) != 0 { + // Only check chanlist if target is not a query + if client.IsConnected() && (!strings.HasPrefix(channel, "#") || len(client.ChannelList()) != 0) { break } log.Printf("%v, not connected, waiting...\n", client.ChannelList()) @@ -298,11 +299,15 @@ func main() { } client.Handlers.Add(girc.CONNECTED, func(c *girc.Client, e girc.Event) { - c.Cmd.Join(channel) + if strings.HasPrefix(channel, "#") { + c.Cmd.Join(channel) + } // join secondary channels for xposting for _, xchan := range viper.GetStringSlice("irc.xchannels") { - c.Cmd.Join(xchan) + if strings.HasPrefix(xchan, "#") { + c.Cmd.Join(xchan) + } } }) client.Handlers.Add(girc.PRIVMSG, func(c *girc.Client, e girc.Event) {