本文整理汇总了Python中twisted.words.protocols.irc.IRCClient.setNick方法的典型用法代码示例。如果您正苦于以下问题:Python IRCClient.setNick方法的具体用法?Python IRCClient.setNick怎么用?Python IRCClient.setNick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.words.protocols.irc.IRCClient
的用法示例。
在下文中一共展示了IRCClient.setNick方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ClientTests
# 需要导入模块: from twisted.words.protocols.irc import IRCClient [as 别名]
# 或者: from twisted.words.protocols.irc.IRCClient import setNick [as 别名]
#.........这里部分代码省略.........
self.protocol.password = None
self.protocol.register(username, hostname, servername)
expected = [
'NICK %s' % (username,),
'USER %s %s %s :%s' % (
username, hostname, servername, self.protocol.realname),
'']
self.assertEquals(self.transport.value().split('\r\n'), expected)
def test_registerWithPassword(self):
"""
If the C{password} attribute of L{IRCClient} is not C{None}, the
C{register} method also sends a PASS command with it as the
argument.
"""
username = 'testuser'
hostname = 'testhost'
servername = 'testserver'
self.protocol.realname = 'testname'
self.protocol.password = 'testpass'
self.protocol.register(username, hostname, servername)
expected = [
'PASS %s' % (self.protocol.password,),
'NICK %s' % (username,),
'USER %s %s %s :%s' % (
username, hostname, servername, self.protocol.realname),
'']
self.assertEquals(self.transport.value().split('\r\n'), expected)
def test_registerWithTakenNick(self):
"""
Verify that the client repeats the L{IRCClient.setNick} method with a
new value when presented with an C{ERR_NICKNAMEINUSE} while trying to
register.
"""
username = 'testuser'
hostname = 'testhost'
servername = 'testserver'
self.protocol.realname = 'testname'
self.protocol.password = 'testpass'
self.protocol.register(username, hostname, servername)
self.protocol.irc_ERR_NICKNAMEINUSE('prefix', ['param'])
lastLine = self.getLastLine(self.transport)
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 + '***',))