Ticket #3910: t.w.p.irc-action.patch

File t.w.p.irc-action.patch, 2.5 KB (added by stefanor, 12 years ago)

describe() function replaces me() and doesn't prepend #

  • twisted/words/test/test_irc.py

    class ClientTests(TestCase): 
    723723                username, hostname, servername, self.protocol.realname),
    724724            '']
    725725        self.assertEquals(self.transport.value().split('\r\n'), expected)
     726
     727    def test_describe(self):
     728        target = 'foo'
     729        channel = 'bar'
     730        action = 'waves'
     731        self.protocol.describe(target, action)
     732        self.protocol.describe(channel, action)
     733        expected = [
     734            'PRIVMSG %s :\01ACTION %s\01' % (target, action),
     735            'PRIVMSG %s :\01ACTION %s\01' % (channel, action),
     736            '']
     737        self.assertEquals(self.transport.value().split('\r\n'), expected)
  • twisted/words/protocols/irc.py

    Test coverage needs to be better. 
    3030
    3131import errno, os, random, re, stat, struct, sys, time, types, traceback
    3232import string, socket
     33import warnings
    3334from os import path
    3435
    3536from twisted.internet import reactor, protocol
    class IRCClient(basic.LineReceiver): 
    10671068
    10681069    ### user input commands, client->client
    10691070
     1071    def describe(self, channel, action):
     1072        """
     1073        Strike a pose.
     1074
     1075        @type channel: C{str}
     1076        @param channel: The name of the channel to have an action on. If it
     1077            has no prefix, it is sent to the user of that name.
     1078        @type action: C{str}
     1079        @param action: The action to preform.
     1080        """
     1081        self.ctcpMakeQuery(channel, [('ACTION', action)])
     1082
    10701083    def me(self, channel, action):
    10711084        """
    10721085        Strike a pose.
    10731086
     1087        This function is deprecated. Use describe().
     1088
    10741089        @type channel: C{str}
    10751090        @param channel: The name of the channel to have an action on. If it
    10761091            has no prefix, C{'#'} will to prepended to it.
    10771092        @type action: C{str}
    10781093        @param action: The action to preform.
    10791094        """
     1095        warnings.warn("me() is deprecated.  Use IRCClient.describe().",
     1096                DeprecationWarning, stacklevel=2)
     1097
    10801098        if channel[0] not in '&#!+': channel = '#' + channel
    1081         self.ctcpMakeQuery(channel, [('ACTION', action)])
     1099        self.describe(channel, action)
    10821100
    10831101    _pings = None
    10841102    _MAX_PINGRING = 12