Opened 5 years ago

Last modified 17 months ago

#3978 defect new

twisted.words.protocols.irc.IRCClient.describe() overagressively backslashes

Reported by: SpaceHobo Owned by: Upasana
Priority: normal Milestone:
Component: words Keywords: irc
Cc: thijs, me@… Branch:
Author: Launchpad Bug:

Description (last modified by thijs)

When my IRCClient-descended bot class calls:, r'\o/')

I am presented with the following in IRC (seen with irssi):

	13:00 * yardbird \\o/

It strikes me that ctcpStringify is overagressively escaping the payload somehow.

Is there any way I can work around this? I'm happy to override or replace with my own method in my subclass. I've fiddled with all sorts of dequotation and quotation, but I can only get even numbers of backslashes as a result.

the PRIVMSG functions do not do this.

One last irk: for some reason you can only send actions to channels, while I can happily do /me in a user query window in irssi. Why the restriction?

Attachments (1)

bug_3978.patch (1.6 KB) - added by Upasana 17 months ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 5 years ago by SpaceHobo

comment:2 Changed 5 years ago by SpaceHobo

The answer is simple: /me is not a CTCP ACTION but a PRIVMSG ACTION: says:

 351 void irc_server_send_action(IRC_SERVER_REC *server, const char *target, const char *data)           
 352 {
 353         char *recoded;
 355         recoded = recode_out(SERVER(server), data, target);
 356         irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, recoded);
 357         g_free(recoded);
 358 }

So in my IRCClient subclass I just did:

    def me(self, channel, action):
        return self.msg(channel, '\001ACTION %s\001' % action)

And, action) now does the right thing!

This may help bug#1335 as well.

comment:3 Changed 4 years ago by <automation>

  • Owner exarkun deleted

comment:4 Changed 3 years ago by thijs

  • Cc thijs added
  • Resolution set to duplicate
  • Status changed from new to closed was deprecated in #3910 and replaced with IRCClient.describe. Closing this as duplicate. Please reopen if this is a different issue.

comment:5 Changed 3 years ago by exarkun

  • Resolution duplicate deleted
  • Status changed from closed to reopened

IRCClient.describe has exactly the same problem because it quotes the message in exactly the same way. Please err on the side of leaving tickets open, rather than making bug reporters re-verify and re-open tickets which are still valid.

comment:6 Changed 3 years ago by thijs

  • Description modified (diff)
  • Summary changed from overagressively backslashes to twisted.words.protocols.irc.IRCClient.describe() overagressively backslashes

comment:7 Changed 17 months ago by Upasana

  • Cc me@… added
  • Owner set to Upasana
  • Status changed from reopened to new

Changed 17 months ago by Upasana

comment:8 Changed 17 months ago by Upasana

  • Keywords review added
  • Owner Upasana deleted

I think, there is no need of X_QUOTE, in twisted.words.protocols.irc.ctcpQuote

xQuoteTable = {
    X_DELIM: X_QUOTE + 'a',


comment:9 Changed 17 months ago by itamar

I would suggest making a new test, rather than adding another check to an existing test. Also, some direct tests for ctcpQuote and adding a docstring to ctcpQuote might be a good idea (there's a QuotingTests class in the test module).

Not marking as reviewed yet since I don't know enough IRC to be sure this change is correct.

comment:10 follow-up: Changed 17 months ago by acapnotic

  • Owner set to acapnotic
  • Status changed from new to assigned

comment:11 in reply to: ↑ 10 Changed 17 months ago by Upasana

Replying to acapnotic:

hi acapnotic, I saw in the log, that you're the author of the snippet which I pasted in my last comment. Can you please tell me why you used X_QUOTE?I tried to find its answer, but didn't get it.

comment:12 Changed 17 months ago by acapnotic

  • Keywords review removed
  • Owner changed from acapnotic to Upasana
  • Status changed from assigned to new

I think all quoting mechanisms must have a way to quote the escape character. If you don't, when you receive the message "\a", how do you know if it's supposed to decode to the literal message "\a" or if it represents X_DELIM?

So the approach here is probably not to change ctcpQuote, but to decide if IRCClient.describe should use ctcpQuote at all.

(As the first comment says, this is closely tied to bug #1335, and I'm no longer entirely sure if one can be done without the other.)

comment:13 Changed 17 months ago by Upasana

okay, I'll look at it again. Thanks :)

Note: See TracTickets for help on using tickets.