当前位置: 首页>>代码示例>>Python>>正文


Python IRCClient.irc_NICK方法代码示例

本文整理汇总了Python中twisted.words.protocols.irc.IRCClient.irc_NICK方法的典型用法代码示例。如果您正苦于以下问题:Python IRCClient.irc_NICK方法的具体用法?Python IRCClient.irc_NICK怎么用?Python IRCClient.irc_NICK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.words.protocols.irc.IRCClient的用法示例。


在下文中一共展示了IRCClient.irc_NICK方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: irc_NICK

# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import irc_NICK [as 别名]
	def irc_NICK(self, prefix, params):
		"""
		Called when a user changes their nickname.
		"""
		IRCClient.irc_NICK(self, prefix, params)
		nick = prefix.split('!', 1)[0]
开发者ID:gkistler,项目名称:pytwitchirc,代码行数:8,代码来源:twitch.py

示例2: ClientTests

# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import irc_NICK [as 别名]

#.........这里部分代码省略.........
        self.assertNotEquals(lastLine, 'NICK %s' % (username,))

        # Keep chaining underscores for each collision
        self.protocol.irc_ERR_NICKNAMEINUSE('prefix', ['param'])
        lastLine = self.getLastLine(self.transport)
        self.assertEquals(lastLine, 'NICK %s' % (username + '__',))


    def test_overrideAlterCollidedNick(self):
        """
        L{IRCClient.alterCollidedNick} determines how a nickname is altered upon
        collision while a user is trying to change to that nickname.
        """
        nick = 'foo'
        self.protocol.alterCollidedNick = lambda nick: nick + '***'
        self.protocol.register(nick)
        self.protocol.irc_ERR_NICKNAMEINUSE('prefix', ['param'])
        lastLine = self.getLastLine(self.transport)
        self.assertEquals(
            lastLine, 'NICK %s' % (nick + '***',))


    def test_nickChange(self):
        """
        When a NICK command is sent after signon, C{IRCClient.nickname} is set
        to the new nickname I{after} the server sends an acknowledgement.
        """
        oldnick = 'foo'
        newnick = 'bar'
        self.protocol.register(oldnick)
        self.protocol.irc_RPL_WELCOME('prefix', ['param'])
        self.protocol.setNick(newnick)
        self.assertEquals(self.protocol.nickname, oldnick)
        self.protocol.irc_NICK('%[email protected]' % (oldnick,), [newnick])
        self.assertEquals(self.protocol.nickname, newnick)


    def test_erroneousNick(self):
        """
        Trying to register an illegal nickname results in the default legal
        nickname being set, and trying to change a nickname to an illegal
        nickname results in the old nickname being kept.
        """
        # Registration case: change illegal nickname to erroneousNickFallback
        badnick = 'foo'
        self.assertEquals(self.protocol._registered, False)
        self.protocol.register(badnick)
        self.protocol.irc_ERR_ERRONEUSNICKNAME('prefix', ['param'])
        lastLine = self.getLastLine(self.transport)
        self.assertEquals(
            lastLine, 'NICK %s' % (self.protocol.erroneousNickFallback,))
        self.protocol.irc_RPL_WELCOME('prefix', ['param'])
        self.assertEquals(self.protocol._registered, True)
        self.protocol.setNick(self.protocol.erroneousNickFallback)
        self.assertEquals(
            self.protocol.nickname, self.protocol.erroneousNickFallback)

        # Illegal nick change attempt after registration. Fall back to the old
        # nickname instead of erroneousNickFallback.
        oldnick = self.protocol.nickname
        self.protocol.setNick(badnick)
        self.protocol.irc_ERR_ERRONEUSNICKNAME('prefix', ['param'])
        lastLine = self.getLastLine(self.transport)
        self.assertEquals(
            lastLine, 'NICK %s' % (badnick,))
        self.assertEquals(self.protocol.nickname, oldnick)
开发者ID:twonds,项目名称:twisted,代码行数:70,代码来源:test_irc.py


注:本文中的twisted.words.protocols.irc.IRCClient.irc_NICK方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。