本文整理汇总了Python中supybot.ircutils.isChannel函数的典型用法代码示例。如果您正苦于以下问题:Python isChannel函数的具体用法?Python isChannel怎么用?Python isChannel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isChannel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkIgnored
def checkIgnored(hostmask, recipient='', users=ircdb.users, channels=ircdb.channels):
if ircdb.ignores.checkIgnored(hostmask):
return True
try:
id = ircdb.users.getUserId(hostmask)
user = users.getUser(id)
except KeyError:
# If there's no user...
if ircutils.isChannel(recipient):
channel = channels.getChannel(recipient)
if channel.checkIgnored(hostmask):
return True
else:
return False
else:
return False
if user._checkCapability('owner'):
# Owners shouldn't ever be ignored.
return False
elif user.ignore:
return True
elif recipient:
if ircutils.isChannel(recipient):
channel = ircdb.channels.getChannel(recipient)
if channel.checkIgnored(hostmask):
return True
else:
return False
else:
return False
else:
return False
示例2: lunch
def lunch(self, irc, msg, args):
# Reject query if privmsg
if not ircutils.isChannel(msg.args[0]):
irc.reply('I will not reply to your soft whispers.')
return
# Look for channel in arguments, else assume current channel is target
for i in args:
if ircutils.isChannel(i):
chan = i
args.remove(i)
break
else:
chan = msg.args[0]
# Look for arguments else spit list
if not args:
places = self.get_places(chan)
if len(places) == 0:
irc.reply('My list is empty, why not tell me what you like to',
'eat?')
else:
eatme = random.choice(places)
irc.reply(eatme)
elif 'add' in args:
args.remove('add')
place = ' '.join(args)
places = self.get_places(chan)
if place in places:
irc.reply('%s already in list for %s' % (place, chan))
return
places.append(place)
self.setRegistryValue('places', places, chan)
irc.reply('Added %s to %s\'s list.' % (place, chan))
elif 'remove' in args:
args.remove('remove')
place = ' '.join(args)
places = self.get_places(chan)
if place not in places:
irc.reply('%s not found in list for %s' % (place, chan))
return
places.remove(place)
self.setRegistryValue('places', places, chan)
irc.reply('Removed %s from %s\'s list.' % (place, chan))
elif 'list' in args:
places = ', '.join(self.get_places(chan))
if len(places) == 0:
irc.reply('List for %s is empty.' % chan)
else:
irc.reply(places)
else:
irc.reply('Unknown command.')
示例3: getConnection
def getConnection(connections, channels, source, serverID = None):
conn = None
if not serverID:
if ircutils.isChannel(source) and source.lower() in channels:
conn = connections.get(source)
else:
if ircutils.isChannel(serverID):
conn = connections.get(serverID)
else:
for c in connections.itervalues():
if c.ID == serverID.lower():
conn = c
return conn
示例4: doPrivmsg
def doPrivmsg(self, irc, msg):
if not conf.supybot.defaultIgnore(): # Only do this when defaultIgnore is set
return
if chr(1) in msg.args[1]:
return
try:
user = ircdb.users.getUser(msg.prefix)
if user.checkHostmask(msg.prefix):
return
except:
pass
text = callbacks.addressed(irc.nick, msg)
cmd = ''
if not text or text != "login":
if msg.args[1]:
if ircutils.isChannel(msg.args[0]):
if msg.args[1][0] == '@':
cmd = msg.args[1][1:]
else:
if msg.args[1][0] == '@':
cmd = msg.args[1][1:]
else:
cmd = msg.args[1]
if cmd != "login":
return
else:
return
self.log.info("IRCLogin: Calling login for %s" % msg.prefix)
self._callCommand(["login"], irc, msg, [])
示例5: addMsg
def addMsg(self, msg):
assert msg.command == 'PRIVMSG'
(channel, text) = msg.args
if not ircutils.isChannel(channel):
return
channel = plugins.getChannel(channel)
text = text.strip().lower()
if not text:
return
try:
id = ircdb.users.getUserId(msg.prefix)
except KeyError:
return
msgwords = [s.strip(nonAlphaNumeric).lower() for s in text.split()]
if channel not in self.channelWords:
self.channelWords[channel] = {}
for word in self.channelWords[channel]:
lword = word.lower()
count = msgwords.count(lword)
if count:
self.channelWords[channel][word] += count
if (channel, id) not in self:
self[channel, id] = {}
if word not in self[channel, id]:
self[channel, id][word] = 0
self[channel, id][word] += count
示例6: nicks
def nicks(self, irc, msg, args, channel, optlist):
"""[<channel>] [--count]
Returns the nicks in <channel>. <channel> is only necessary if the
message isn't sent in the channel itself. Returns only the number of
nicks if --count option is provided.
"""
# Make sure we don't elicit information about private channels to
# people or channels that shouldn't know
if 's' in irc.state.channels[channel].modes and \
msg.args[0] != channel and \
(ircutils.isChannel(msg.args[0]) or \
msg.nick not in irc.state.channels[channel].users):
irc.error(_('You don\'t have access to that information.'),
Raise=True)
L = list(irc.state.channels[channel].users)
keys = [option for (option, arg) in optlist]
if 'count' not in keys:
irc.reply(channel)
irc.reply(optlist)
irc.reply(keys)
irc.reply(args)
utils.sortBy(str.lower, L)
irc.reply(utils.str.commaAndify(L))
else:
irc.reply(args)
irc.reply(channel)
irc.reply(optlist)
irc.reply(keys)
irc.reply(str(len(L)))
示例7: set
def set(self, irc, msg, args, optlist, name, alias):
"""[--channel <#channel>] <name> <command>
Overwrites an existing alias <name> to execute <command> instead. The
<command> should be in the standard "command argument [nestedcommand
argument]" arguments to the alias; they'll be filled with the first,
second, etc. arguments. $1, $2, etc. can be used for required
arguments. @1, @2, etc. can be used for optional arguments. $* simply
means "all arguments that have not replaced $1, $2, etc.", ie. it will
also include optional arguments.
"""
channel = 'global'
for (option, arg) in optlist:
if option == 'channel':
if not ircutils.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg,
Raise=True)
channel = arg
try:
self._remove_aka(channel, name)
except AkaError as e:
irc.error(str(e), Raise=True)
if ' ' not in alias:
# If it's a single word, they probably want $*.
alias += ' $*'
try:
self._add_aka(channel, name, alias)
self.log.info('Setting Aka %r to %r (from %s)',
name, alias, msg.prefix)
irc.replySuccess()
except AkaError as e:
irc.error(str(e))
示例8: calc
def calc(self, irc, msg, args, expr):
"""<expression>
Uses Google's calculator to calculate the value of <expression>.
"""
channel = msg.args[0]
if not ircutils.isChannel(channel):
channel = None
url = self._googleUrl(expr, channel)
h = {"User-Agent":"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"}
html = utils.web.getUrl(url, headers=h).decode('utf8')
match = self._calcRe1.search(html)
if not match:
match = self._calcRe2.search(html)
if not match:
match = self._calcRe3.search(html)
if not match:
irc.reply("I could not find an output from Google Calc for: %s" % expr)
return
else:
s = match.group(1)
else:
s = match.group(1)
else:
s = match.group(1)
# do some cleanup of text
s = re.sub(r'<sup>(.*)</sup>⁄<sub>(.*)</sub>', r' \1/\2', s)
s = re.sub(r'<sup>(.*)</sup>', r'^\1', s)
s = utils.web.htmlToText(s)
irc.reply("%s = %s" % (expr, s))
示例9: isChannelCapability
def isChannelCapability(capability):
"""Returns True if capability is a channel capability; False otherwise."""
if ',' in capability:
(channel, capability) = capability.split(',', 1)
return ircutils.isChannel(channel) and isCapability(capability)
else:
return False
示例10: checkIgnored
def checkIgnored(hostmask, recipient='', users=users, channels=channels):
"""checkIgnored(hostmask, recipient='') -> True/False
Checks if the user is ignored by the recipient of the message.
"""
try:
id = users.getUserId(hostmask)
user = users.getUser(id)
if user._checkCapability('owner'):
# Owners shouldn't ever be ignored.
return False
elif user.ignore:
log.debug('Ignoring %s due to his IrcUser ignore flag.', hostmask)
return True
except KeyError:
# If there's no user...
if conf.supybot.defaultIgnore():
log.debug('Ignoring %s due to conf.supybot.defaultIgnore',
hostmask)
return True
if ignores.checkIgnored(hostmask):
log.debug('Ignoring %s due to ignore database.', hostmask)
return True
if ircutils.isChannel(recipient):
channel = channels.getChannel(recipient)
if channel.checkIgnored(hostmask):
log.debug('Ignoring %s due to the channel ignores.', hostmask)
return True
return False
示例11: np
def np(self, irc, msg, args):
"""Return a list of a people currently in-game on Steam
"""
key = self.registryValue('apikey')
if not key:
irc.replyError('plugins.steamy.apikey has not been set')
return
self.update(key)
ingame = filter(lambda player: player.isInGame(), self.group.members)
playerCount = len(ingame)
playerlist = map(lambda x:
'{0}: {1}'.format(x.steamID.encode('utf8'), x.gameextrainfo.encode('utf8')), ingame)
self.log.info(str(playerlist))
if len(playerlist) != 0:
reply = 'Now Playing: %s' % (', '.join(playerlist))
else:
reply = 'Now Playing: nobody :('
if ircutils.isChannel(msg.args[0]):
irc.queueMsg(ircmsgs.privmsg(msg.args[0], reply))
else:
irc.queueMsg(ircmsgs.privmsg(msg.nick, reply))
示例12: do437
def do437(self, irc, msg):
"""Nick/channel is temporarily unavailable"""
if ircutils.isChannel(msg.args[1]):
return
self.log.info('Nick %s is unavailable; attempting NickServ release '
'on %s.' % (msg.args[1], irc.network))
irc.sendMsg(ircmsgs.privmsg('NickServ', 'release %s' % msg.args[1]))
示例13: get_feedName
def get_feedName(irc, msg, args, state):
if ircutils.isChannel(args[0]):
state.errorInvalid('feed name', args[0], 'must not be channel names.')
if not registry.isValidRegistryName(args[0]):
state.errorInvalid('feed name', args[0],
'Feed names must not include spaces.')
state.args.append(callbacks.canonicalName(args.pop(0)))
示例14: soccerformation
def soccerformation(self, irc, msg, args):
"""
Display a random lineup for channel users.
"""
if not ircutils.isChannel(msg.args[0]): # make sure its run in a channel.
irc.reply("ERROR: Must be run from a channel.")
return
# now make sure we have more than 9 users.
users = [i for i in irc.state.channels[msg.args[0]].users]
if len(users) < 11: # need >9 users.
irc.reply("Sorry, I can only run this in a channel with more than 9 users.")
return
# now that we're good..
formations = {'4-4-2':['(GK)', '(RB)', '(CB)', '(CB)', '(LB)', '(RM)', '(LM)', '(CM)', '(CM)', '(FW)', '(FW)'],
'4-4-1-1':['(GK)', '(RB)', '(CB)', '(CB)', '(LB)', '(RM)', '(LM)', '(CM)', '(CM)', '(ST)', '(FW)'],
'4-5-1':['(GK)', '(RB)', '(CB)', '(CB)', '(LB)', '(RM)', '(LM)', '(CM)', '(CM)', '(CM)', '(ST)'],
'3-5-1-1':['(GK)', '(CB)', '(CB)', '(SW)', '(RM)', '(CM)', '(LM)', '(CM)', '(CM)', '(FW)', '(ST)'],
'10-1 (CHELSEA)':['(GK)', '(LB)', '(CB)', '(RB)', '(CB)', '(CB)', '(CB)', '(CB)', '(CB)', '(CB)', '(DROGBA)'],
'8-1-1 (PARK THE BUS)':['(GK)', '(LB)', '(CB)', '(RB)', '(CB)', '(CB)', '(CB)', '(CB)', '(CB)', '(CM)', '(ST)']
}
formation = random.choice(formations.keys())
random.shuffle(formations[formation]) # shuffle.
lineup = [] # list for output.
for position in formations[formation]: # iterate through and highlight.
a = random.choice(users) # pick a random user.
users.remove(a) # remove so its unique. append below.
lineup.append("{0}{1}".format(ircutils.bold(a), position))
# now output.
output = "{0} ALL-STAR LINEUP ({1}) :: {2}".format(ircutils.mircColor(msg.args[0], 'red'), formation, ", ".join(lineup))
if not self.registryValue('disableANSI', msg.args[0]): # display color or not?
irc.reply(output)
else:
irc.reply(ircutils.stripFormatting(output))
示例15: _is_not_ignored
def _is_not_ignored(self, msg, irc):
channel = msg.args[0]
enabled = self.registryValue('enable', channel) or \
(self.registryValue('enableIfModerated', channel) and \
'm' in irc.state.channels[channel].modes)
return ircutils.isChannel(channel) and enabled and \
not irc.state.channels[channel].isVoicePlus(msg.nick)