Suggested changes
flexd opened this issue · comments
I made some changes I felt were needed, you can see here https://github.com/flexd/hellabot if you want to take a look. :-)
And I have some other plans to make the API a bit nicer as well, but this was just me playing with the bot this evening.
In short I have:
- Embedded irc.Message instead of copying it over
- Removed Prefix since it's identical to the sorcix/irc one.
- Removed Message.Raw
- Added a Deadline in handleIncomingMessage of 300 seconds to disconnect us if we get absolutely nothing for that time.
- Renamed IrcCon to Bot, IrcChannel to Channel, IrcUser to User, and DoSasl to DoSASL.
- Renamed IrcCon.tr to IrcCon.triggers (Bot.triggers)
- Check Notice() for len(text)==0 as well
- Shortened LoadConfig a tiny bit
- Moved a few methods to Bot core instead of channel (not sure about this one yet)
I was basically just playing with it and seeing what seemed natural and more Go idiomatic. I also tried changing the IRC parsing/handling to rely more on sorcix/irc, since that already implements most of what we want to do.
Let me know what you think :-)
most of that sounds good to me! wanna file a PR? that makes it easier for me to see the changes and comment on them
Yeah I will in a bit, just want to fix stuff up a bit.. I'll make a PR when it's ready :)
sounds good, thanks!
Are you on IRC somewhere? Or the Gopher slack. I would love to have a chat.. I have discovered what I think are a few bugs. Not entirely sure if I introduced them by swapping out ParseMessage yet :)
https://github.com/whyrusleeping/hellabot/blob/master/ircchannel.go#L86
The bot seems to never receive a JOIN there.
And there is also a memory dereference error in MODE if a person in a channel rejoins/cycles.
I just reproduced the lack of "JOIN" commands in your version as well.. so it's not something I did.. weird.. It also does not seem to catch a MODE now.
Aha
msg=":flexd!flexd@coldfront-4CBACCF1.tools JOIN :#test" msg.To= msg.Params=[]
Both msg.To and msg.Params are empty for JOINs.. Which is why it is not seeing anything :-)
I kind of want to remove the whole Channel struct (and file) and just reimplement that with Triggers and a database/global map (with locks)
@flexd I'm on freenode pretty much all the time. we can squat in a channel for testing things if you'd like.
Interesting that the message parsing code isnt doing what i expected it to, I'm not opposed to a rewrite.
I'm on freenode as flexd, but I'm testing on another network because Freenode is really slow to connect to. irc.coldfront.net #test
See PR #16