The script doesn't seem to read PRIVMSG

Bug #863017 reported by helpshae
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
xctts
Fix Released
Low
motters

Bug Description

Some IRC like Ustream send all messages in a channel as PRIVMSG and the script doesn't seem to recognize them. I'm not too familiar with writing plugins for xchat and my python is a little rusty, but I added a few lines and it works for ustream's irc. It seems there must be a more elegant way of doing this, but for now this works. Thanks for releasing a great plugin, it is exactly what I was looking for! If it's not appropriate to post the code in a bug report, then please let me know. I'm very new to launch pad.

I added the following to speak_msg():
nick = work[0]
if ':' in nick:
  nicka = re.match(r":(.*?)!", nick)
  nick = nicka.group(1)
......
msg = msg.rstrip('^')
if 'PRIVMSG' in msg:
  msg = msg.replace ('PRIVMSG', '')
  msga = re.match(r"^.*?:(.*)$", msg)
  msg = msga.group(1)

to the very end of the script:
xchat.hook_print('Channel Message', speak_message)
xchat.hook_server('PRIVMSG', speak_message)

motters (fuzzgun)
Changed in xctts:
status: New → In Progress
importance: Undecided → Low
assignee: nobody → motters (fuzzgun)
Revision history for this message
motters (fuzzgun) wrote :

Do you have any particular Ustream channels as examples. Connecting XChat2 to Ustream as in these instructions

  http://youtu.be/QXm6jWhHx90

I'm unable to reproduce the problem (don't see any PRIVMSG prefix).

Revision history for this message
helpshae (helpshae) wrote :

Sorry for the delayed response.

The video that you linked too does accurately demonstrate how I use xchat to connect to ustream. As far as the PRIVMSG, that was found during the development of a chat-bot side project. Early in the development of the bot, I had it dumping the raw data it received from the chat room. Most every chat packet that comes from ustream's IRC is formatted as follows:

:chatnickname!<email address hidden> PRIVMSG #channel Hello everyone I said something in a ustream channel.

This is the same information that the xchat.server command receives and what the regex filters to produce the nick and msg.

To get a clearer picture, you can use wireshark to capture a ustream chat conversation and examine the protocol structure.

I hope this helps!

(also, just for further info)
when sending a message, my chatbot sends either "PRIVMSG #ustreamchannel something to say to channel" or "PRIVMSG chatnickname something private to say to only one person"

Revision history for this message
helpshae (helpshae) wrote :

I joined a couple of channels on irc.freenode.net and confirmed that the original plugin works fine for them. However, for #shine1019 or any other ustream irc channel I tried, it didn't appear to work.

The wireshark dump of the freenode chat reveals the same protocol structure I described for ustream. However, I did leave out a colon between the #channel and the message in my previous post. The corrected structures is as follows:

:nick!<email address hidden> PRIVMSG #channel :message posted to everyone

However, after applying the fix I originally described, and relaunching xchat, the freenode channels are repeated. To fix this, I commented out the original hook so they appear as follows:

#xchat.hook_print('Channel Message', speak_message)
xchat.hook_server('PRIVMSG', speak_message)

Now, both freenode and ustream are read only once. As I mentioned earlier, there must be a better way of parsing the data in the speak_message function, but I haven't had a chance to brush up on my python. I'm going to test on geekshed and other irc hosts tomorrow.

Thanks again, and I hope this helps!

Revision history for this message
motters (fuzzgun) wrote :

The modified version seems to work on my system. It has been committed in revision 11.

motters (fuzzgun)
Changed in xctts:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.