Closed sbeparey closed 8 years ago
Is this fixed, or did you find a fix for it? If you found some other way to fix it it would be awesome if you could help future users.
If not, I might be able to find something out about this, although I haven't run into it myself.
@daboross This isn't fixed in the official repo but I "fixed" it on my end. I got tired of waiting around on them, so I just closed it. I'm not proud of the solution because it's kind of hacky. For me it works on Snoonet, it should work on other networks as well but it hasn't been tested elsewhere.
On event.py find the line: self.chan = channel (should be around 124) and replace it with the following code:
if channel is not None:
self.chan = channel
else:
try:
raw = irc_raw.split(':')
if raw[-1].startswith('#'):
self.chan = raw[-1].lower()
elif raw[1] and raw[1].startswith('#'):
self.chan = raw[1].lower()
elif raw[2] and raw[2].startswith('#'):
self.chan = raw[2].lower()
except:
pass
I hope it helps!
Thank you, that is helpful! Sorry the team hasn't paid much attention to this issue.
If you want to do a less hacky fix, it might be best to include the code above in https://github.com/CloudBotIRC/CloudBot/blob/master/cloudbot/clients/irc.py#L397.
If you could print and share a few lines of what irc_raw looks like for your bot, I could probably get a more permanent-y fix for it in the main repository.
okay, that worked out really well, thanks! I'll try to get the irc_raw for you later, if I remember. Gotta run now!
@daboross Here's the real solution and I don't think you'll have to evaluate the irc_raw text. I noticed when the user joins the channel, the event content property has the channel name instead of the channel property, for this particular server. This is easily fixed by this:
else:
channel = None
if event_type is EventType.join and channel is None:
if content and content.startswith('#'):
channel = content.lower()
else:
raw = line.split(':')
if raw:
for item in raw:
if item.startswith('#'):
channel = item;
pass
if event_type is EventType.nick and content is None and channel:
content = channel
channel = None
The later part of the code also fixes when the user changes nick and the new nick is None. (This requires adding a new event_type of EventType.nick on irc_command_to_event_type on): https://github.com/CloudBotIRC/CloudBot/blob/master/cloudbot/clients/irc.py#L24
When a user joins a channel, the raised event does not have any information about the said channel. Even the log shows "None."
Update: This only happens on certain IRC network like Snoonet.