本文整理汇总了Python中supybot.ircmsgs.nick函数的典型用法代码示例。如果您正苦于以下问题:Python nick函数的具体用法?Python nick怎么用?Python nick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nick函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doNickservNotice
def doNickservNotice(self, irc, msg):
nick = self._getNick()
s = ircutils.stripFormatting(msg.args[1].lower())
on = 'on %s' % irc.network
networkGroup = conf.supybot.networks.get(irc.network)
if 'incorrect' in s or 'denied' in s:
log = 'Received "Password Incorrect" from NickServ %s. ' \
'Resetting password to empty.' % on
self.log.warning(log)
self.sentGhost = time.time()
self._setNickServPassword(nick, '')
elif self._ghosted(s):
self.log.info('Received "GHOST succeeded" from NickServ %s.', on)
self.sentGhost = None
self.identified = False
irc.queueMsg(ircmsgs.nick(nick))
elif 'is not registered' in s:
self.log.info('Received "Nick not registered" from NickServ %s.',
on)
elif 'currently' in s and 'isn\'t' in s or 'is not' in s:
# The nick isn't online, let's change our nick to it.
self.sentGhost = None
irc.queueMsg(ircmsgs.nick(nick))
elif ('owned by someone else' in s) or \
('nickname is registered and protected' in s) or \
('nick belongs to another user' in s):
# freenode, arstechnica, chatjunkies
# oftc, zirc.org
# sorcery
self.log.info('Received "Registered nick" from NickServ %s.', on)
elif '/msg' in s and 'id' in s and 'password' in s:
# Usage info for identify command; ignore.
self.log.debug('Got usage info for identify command %s.', on)
elif ('please choose a different nick' in s): # oftc, part 3
# This is a catch-all for redundant messages from nickserv.
pass
elif ('now recognized' in s) or \
('already identified' in s) or \
('password accepted' in s) or \
('now identified' in s):
# freenode, oftc, arstechnica, zirc, ....
# sorcery
self.log.info('Received "Password accepted" from NickServ %s.', on)
self.identified = True
for channel in irc.state.channels.keys():
self.checkPrivileges(irc, channel)
for channel in self.channels:
irc.queueMsg(networkGroup.channels.join(channel))
if self.waitingJoins:
for m in self.waitingJoins:
irc.sendMsg(m)
self.waitingJoins = []
elif 'not yet authenticated' in s:
# zirc.org has this, it requires an auth code.
email = s.split()[-1]
self.log.warning('Received "Nick not yet authenticated" from '
'NickServ %s. Check email at %s and send the '
'auth command to NickServ.', on, email)
else:
self.log.debug('Unexpected notice from NickServ %s: %q.', on, s)
示例2: doNick
def doNick(self, irc, msg):
nick = self._getNick()
if ircutils.strEqual(msg.args[0], irc.nick) and \
ircutils.strEqual(irc.nick, nick):
self._doIdentify(irc)
elif ircutils.strEqual(msg.nick, nick):
irc.sendMsg(ircmsgs.nick(nick))
示例3: testFirstCommands
def testFirstCommands(self):
try:
originalNick = conf.supybot.nick()
originalUser = conf.supybot.user()
originalPassword = conf.supybot.networks.test.password()
nick = 'nick'
conf.supybot.nick.setValue(nick)
user = 'user any user'
conf.supybot.user.setValue(user)
expected = [ircmsgs.nick(nick), ircmsgs.user('supybot', user)]
irc = irclib.Irc('test')
msgs = [irc.takeMsg()]
while msgs[-1] != None:
msgs.append(irc.takeMsg())
msgs.pop()
self.assertEqual(msgs, expected)
password = 'password'
conf.supybot.networks.test.password.setValue(password)
irc = irclib.Irc('test')
msgs = [irc.takeMsg()]
while msgs[-1] != None:
msgs.append(irc.takeMsg())
msgs.pop()
expected.insert(0, ircmsgs.password(password))
self.assertEqual(msgs, expected)
finally:
conf.supybot.nick.setValue(originalNick)
conf.supybot.user.setValue(originalUser)
conf.supybot.networks.test.password.setValue(originalPassword)
示例4: testNick
def testNick(self):
self.prefix = '[email protected]'
self.assertRegexp('gpg ident', 'are identified')
self.irc.feedMsg(msg=ircmsgs.nick('newnick', prefix=self.prefix))
self.assertRegexp('gpg ident', 'not identified')
self.prefix = 'newnick' + '!' + self.prefix.split('!',1)[1]
self.assertRegexp('gpg ident', 'You are identified')
示例5: testNick
def testNick(self):
self.prefix = "[email protected]"
self.assertRegexp("gpg ident", "are identified")
self.irc.feedMsg(msg=ircmsgs.nick("newnick", prefix=self.prefix))
self.assertRegexp("gpg ident", "not identified")
self.prefix = "newnick" + "!" + self.prefix.split("!", 1)[1]
self.assertRegexp("gpg ident", "You are identified")
示例6: nick
def nick(self, irc, msg, args, nick):
"""[<nick>]
Changes the bot's nick to <nick>. If no nick is given, returns the
bot's current nick.
"""
if nick:
conf.supybot.nick.setValue(nick)
irc.queueMsg(ircmsgs.nick(nick))
self.pendingNickChanges[irc.getRealIrc()] = irc
else:
irc.reply(irc.nick)
示例7: nick
def nick(self, irc, msg, args, nick, network):
"""[<nick>] [<network>]
Changes the bot's nick to <nick>. If no nick is given, returns the
bot's current nick.
"""
network = network or irc.network
if nick:
group = getattr(conf.supybot.networks, network)
group.nick.setValue(nick)
irc.queueMsg(ircmsgs.nick(nick))
self.pendingNickChanges[irc.getRealIrc()] = irc
else:
irc.reply(irc.nick)
示例8: __call__
def __call__(self, irc, msg):
self.__parent.__call__(irc, msg)
if self.disabled(irc):
return
nick = self._getNick()
if nick not in self.registryValue('nicks'):
return
nickserv = self.registryValue('NickServ')
password = self._getNickServPassword(nick)
ghostDelay = self.registryValue('ghostDelay')
if nick and nickserv and password and \
not ircutils.strEqual(nick, irc.nick):
if irc.afterConnect and (self.sentGhost is None or
(self.sentGhost + ghostDelay) < time.time()):
if nick in irc.state.nicksToHostmasks:
self._doGhost(irc)
else:
irc.sendMsg(ircmsgs.nick(nick)) # 433 is handled elsewhere.
示例9: testFirstCommands
def testFirstCommands(self):
try:
originalNick = conf.supybot.nick()
originalUser = conf.supybot.user()
originalPassword = conf.supybot.networks.test.password()
nick = 'nick'
conf.supybot.nick.setValue(nick)
user = 'user any user'
conf.supybot.user.setValue(user)
expected = [
ircmsgs.nick(nick),
ircmsgs.user('limnoria', user),
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'account-notify')),
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'extended-join')),
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'multi-prefix')),
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'metadata-notify')),
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'account-tag')),
ircmsgs.IrcMsg(command='CAP', args=('END',)),
]
irc = irclib.Irc('test')
msgs = [irc.takeMsg()]
while msgs[-1] != None:
msgs.append(irc.takeMsg())
msgs.pop()
self.assertEqual(msgs, expected)
password = 'password'
conf.supybot.networks.test.password.setValue(password)
irc = irclib.Irc('test')
msgs = [irc.takeMsg()]
while msgs[-1] != None:
msgs.append(irc.takeMsg())
msgs.pop()
expected.insert(0, ircmsgs.password(password))
self.assertEqual(msgs, expected)
finally:
conf.supybot.nick.setValue(originalNick)
conf.supybot.user.setValue(originalUser)
conf.supybot.networks.test.password.setValue(originalPassword)
示例10: doQuit
def doQuit(self, irc, msg):
if ircmsgs.isSplit(msg):
irc.reply("GOOD JOB OPERS!", prefixNick=False)
if msg.nick == self.oper_nick:
irc.queueMsg(ircmsgs.nick(self.oper_nick))
示例11: _sendNick
def _sendNick(self, irc, nick):
self.log.info('Attempting to switch to nick %s on %s.',
nick, irc.network)
irc.sendMsg(ircmsgs.nick(nick))
示例12: nick
def nick():
irc.queueMsg(ircmsgs.nick(target))
示例13: doNickservNotice
def doNickservNotice(self, irc, msg):
if self.disabled(irc):
return
nick = self._getNick(irc.network)
s = ircutils.stripFormatting(msg.args[1].lower())
on = "on %s" % irc.network
networkGroup = conf.supybot.networks.get(irc.network)
if "incorrect" in s or "denied" in s:
log = 'Received "Password Incorrect" from NickServ %s. ' "Resetting password to empty." % on
self.log.warning(log)
self.sentGhost = time.time()
self._setNickServPassword(nick, "")
elif self._ghosted(irc, s):
self.log.info('Received "GHOST succeeded" from NickServ %s.', on)
self.sentGhost = None
self.identified = False
irc.queueMsg(ircmsgs.nick(nick))
elif "is not registered" in s:
self.log.info('Received "Nick not registered" from NickServ %s.', on)
elif "currently" in s and "isn't" in s or "is not" in s:
# The nick isn't online, let's change our nick to it.
self.sentGhost = None
irc.queueMsg(ircmsgs.nick(nick))
elif (
("owned by someone else" in s)
or ("nickname is registered and protected" in s)
or ("nick belongs to another user" in s)
):
# freenode, arstechnica, chatjunkies
# oftc, zirc.org
# sorcery
self.log.info('Received "Registered nick" from NickServ %s.', on)
elif "/msg" in s and "id" in s and "password" in s:
# Usage info for identify command; ignore.
self.log.debug("Got usage info for identify command %s.", on)
elif "please choose a different nick" in s: # oftc, part 3
# This is a catch-all for redundant messages from nickserv.
pass
elif (
("now recognized" in s)
or ("already identified" in s)
or ("already logged in" in s)
or ("successfully identified" in s)
or ("password accepted" in s)
or ("now identified" in s)
):
# freenode, oftc, arstechnica, zirc, ....
# sorcery
self.log.info('Received "Password accepted" from NickServ %s.', on)
self.identified = True
for channel in irc.state.channels.keys():
self.checkPrivileges(irc, channel)
for channel in self.channels:
irc.queueMsg(networkGroup.channels.join(channel))
waitingJoins = self.waitingJoins.pop(irc.network, None)
if waitingJoins:
for m in waitingJoins:
irc.sendMsg(m)
elif "not yet authenticated" in s:
# zirc.org has this, it requires an auth code.
email = s.split()[-1]
self.log.warning(
'Received "Nick not yet authenticated" from '
"NickServ %s. Check email at %s and send the "
"auth command to NickServ.",
on,
email,
)
else:
self.log.debug("Unexpected notice from NickServ %s: %q.", on, s)