Opened 12 years ago

Last modified 8 years ago

#3978 defect new

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

Reported by: SpaceHobo Owned by: Upasana Shukla
Priority: normal Milestone:
Component: words Keywords: irc
Cc: Thijs Triemstra, Upasana Shukla Branch:

Description (last modified by Thijs Triemstra)

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 Shukla 8 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 12 years ago by SpaceHobo

comment:2 Changed 12 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 10 years ago by <automation>

Owner: Jean-Paul Calderone deleted

comment:4 Changed 10 years ago by Thijs Triemstra

Cc: Thijs Triemstra added
Resolution: duplicate
Status: newclosed was deprecated in #3910 and replaced with IRCClient.describe. Closing this as duplicate. Please reopen if this is a different issue.

comment:5 Changed 10 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: closedreopened

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 10 years ago by Thijs Triemstra

Description: modified (diff)
Summary: overagressively backslashestwisted.words.protocols.irc.IRCClient.describe() overagressively backslashes

comment:7 Changed 8 years ago by Upasana Shukla

Cc: Upasana Shukla added
Owner: set to Upasana Shukla
Status: reopenednew

Changed 8 years ago by Upasana Shukla

Attachment: bug_3978.patch added

comment:8 Changed 8 years ago by Upasana Shukla

Keywords: review added
Owner: Upasana Shukla 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 8 years ago by Itamar Turner-Trauring

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 Changed 8 years ago by acapnotic

Owner: set to acapnotic
Status: newassigned

comment:11 in reply to:  10 Changed 8 years ago by Upasana Shukla

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. Thanks.

comment:12 Changed 8 years ago by acapnotic

Keywords: review removed
Owner: changed from acapnotic to Upasana Shukla
Status: assignednew

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 8 years ago by Upasana Shukla

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

Note: See TracTickets for help on using tickets.