本文整理汇总了Python中supybot.ircutils.isChannel函数的典型用法代码示例。如果您正苦于以下问题:Python isChannel函数的具体用法?Python isChannel怎么用?Python isChannel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isChannel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:bnrubin,项目名称:ubuntu-bots,代码行数:32,代码来源:plugin.py
示例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.')
开发者ID:kremlinkev,项目名称:Supybot-Lunch,代码行数:52,代码来源:plugin.py
示例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
开发者ID:barnaba,项目名称:suds,代码行数:14,代码来源:soaputils.py
示例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, [])
开发者ID:bnrubin,项目名称:IRCLogin,代码行数:30,代码来源:plugin.py
示例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
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:26,代码来源:plugin.py
示例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)))
开发者ID:kg-bot,项目名称:SupyBot,代码行数:30,代码来源:plugin.py
示例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))
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:33,代码来源:plugin.py
示例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))
开发者ID:carriercomm,项目名称:Limnoria,代码行数:30,代码来源:plugin.py
示例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
开发者ID:Elwell,项目名称:supybot,代码行数:7,代码来源:ircdb.py
示例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
开发者ID:cnelsonsic,项目名称:Limnoria,代码行数:29,代码来源:ircdb.py
示例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))
开发者ID:bnrubin,项目名称:Steamy,代码行数:25,代码来源:plugin.py
示例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]))
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:7,代码来源:plugin.py
示例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)))
开发者ID:tvieira,项目名称:Limnoria,代码行数:7,代码来源:plugin.py
示例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))
开发者ID:reticulatingspline,项目名称:Soccer,代码行数:34,代码来源:plugin.py
示例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)
开发者ID:laaabaseball,项目名称:Supybot-plugins,代码行数:7,代码来源:plugin.py
示例16: cveSnarfer
def cveSnarfer(self, irc, msg, match):
r"(https?://\S+=)?CVE[- ](?P<cveid>\d{4}[- ]\d{4,})"
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
if checkAddressed(msg.args[1].strip(), channel):
return
if not self.registryValue('bugSnarfer', channel) or not self.registryValue('cveSnarfer', channel):
return
cveid = match.group('cveid').replace(' ','-')
if not self.is_ok(channel or msg.nick, 'cve', cveid):
return
url = 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s' % cveid
try:
cvedata = utils.web.getUrl(url).decode('utf-8')
except Exception as e:
raise BugtrackerError('Could not get CVE data: %s (%s)' % (e, url))
m = cvere.search(cvedata)
if m:
cve = utils.web.htmlToText(m.group('cve'), tagReplace='')
if len(cve) > 380:
cve = cve[:380] + '...'
if not match.group(1):
cve += ' <%s>' % url
irc.reply(cve)
else:
m = cverre.search(cvedata)
if m:
cverr = utils.web.htmlToText(m.group('cverr'), tagReplace='')
irc.reply(cverr)
开发者ID:mapreri,项目名称:MPR-supybot,代码行数:28,代码来源:plugin.py
示例17: turlSnarfer
def turlSnarfer(self, irc, msg, match):
r"(https?://)?((bugs\.debian\.org|pad\.lv)/|\S+/(show_bug\.cgi\?id=|bugreport\.cgi\?bug=|view\.php\?id=|bug=|bugs/|\+bug/|ticket/|feature-requests/|patches/|todo/|issues/|pulls?/|merge_requests/))(?P<bug>\d+)/?"
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
if checkAddressed(msg.args[1].strip(), channel):
return
if not self.registryValue('bugSnarfer', channel):
return
nbugs = msg.tagged('nbugs') or 0
if nbugs >= 5:
return
msg.tag('nbugs', nbugs+1)
url = match.group(0)
bugid = int(match.group('bug'))
if '://' in url:
url = url[url.rfind('://')+3:]
try:
tracker = self.get_tracker(url, bugid)
if not tracker:
return
report = self.get_bug(channel or msg.nick, tracker, bugid, self.registryValue('showassignee', channel),
self.registryValue('extended', channel), do_url=False)
except BugtrackerError as e:
irc.error(str(e))
except BugNotFoundError:
if self.registryValue('replyWhenNotFound'):
irc.error("Could not find %s bug %s" % (tracker.description, match.group('bug')))
else:
if report:
irc.reply(report)
开发者ID:mapreri,项目名称:MPR-supybot,代码行数:29,代码来源:plugin.py
示例18: getIssue
def getIssue(self, irc, msg, match):
"""Get a Jira Issue"""
if not ircutils.isChannel(msg.args[0]):
return
issueName = match.group('issue')
try:
issue = self.jira.issue(issueName)
except:
print "Invalid Jira snarf: %s" % issueName
return
if issue:
issuetype = issue.fields.issuetype.name
key = issue.key
name = issue.fields.summary
status = issue.fields.status.name
time = issue.fields.timeestimate
if issue.fields.assignee:
assignee = issue.fields.assignee.displayName
else:
assignee = "Unassigned"
if time:
hours = time / 60 / 60
minutes = time / 60 % 60
displayTime = " / %ih%im" % (hours, minutes)
else:
displayTime = ""
url = ''.join((self.server, '/browse/', key))
replytext = ("(%s %s) %s [ \x032%s\x03%s ] \x033\x02%s\x02\x03 %s"
% (issuetype, key, name, assignee, displayTime, status,
url))
irc.reply(replytext, prefixNick=False)
开发者ID:ProgVal,项目名称:supybot-jira,代码行数:33,代码来源:plugin.py
示例19: makeBanmask
def makeBanmask(self, hostmask, options=None):
"""Create a banmask from the given hostmask. If a style of banmask
isn't specified via options, the value of
conf.supybot.protocols.irc.banmask is used.
A variable named 'channel' (defining the channel the ban is taking
place in) is expected to be in the environment of the caller of this
function.
options - A list specifying which parts of the hostmask should
explicitly be matched: nick, user, host. If 'exact' is given, then
only the exact hostmask will be used."""
assert ircutils.isChannel(dynamic.channel)
(nick, user, host) = ircutils.splitHostmask(hostmask)
bnick = '*'
buser = '*'
bhost = '*'
if not options:
options = get(supybot.protocols.irc.banmask, dynamic.channel)
for option in options:
if option == 'nick':
bnick = nick
elif option == 'user':
buser = user
elif option == 'host':
bhost = host
elif option == 'exact':
return hostmask
return ircutils.joinHostmask(bnick, buser, bhost)
开发者ID:Kefkius,项目名称:mazabot,代码行数:29,代码来源:conf.py
示例20: delquote
def delquote(self, irc, msg, args, optlist, qid):
"""[--channel <#channel>] <id>
Delete the quote number 'id', only by the creator of the quote in
the first 5 minutes or by an admin. If --channel is supplied the
quote is fetched from that channel database."""
channel = msg.args[0]
for (option, arg) in optlist:
if option == 'channel':
if not ircutils.isChannel(arg):
irc.error(format(_('%s is not a valid channel.'), arg),
Raise=True)
channel = arg
q = self.db.getQuoteById(channel, qid)
if q is not None:
if ircdb.checkCapability(msg.prefix, 'admin'):
self.db.delQuoteById(channel, qid)
irc.replySuccess()
elif (time.time() - 300) <= q[3]:
if q[2].lower() == msg.nick.lower():
self.db.delQuoteById(channel, qid)
irc.replySuccess()
else:
irc.error(format(_("This quote only can be deleted by %s "
"or an admin."), q[2]))
else:
irc.error(format(_("Too late, it has already passed 5 minutes."
" Ask an admin."), qid, channel))
else:
irc.error(format(_("No such quote %s in %s's database."),
qid, channel))
开发者ID:rostob,项目名称:Limnoria-plugins,代码行数:32,代码来源:plugin.py
注:本文中的supybot.ircutils.isChannel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论