本文整理汇总了Python中supybot.ircdb.makeChannelCapability函数的典型用法代码示例。如果您正苦于以下问题:Python makeChannelCapability函数的具体用法?Python makeChannelCapability怎么用?Python makeChannelCapability使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeChannelCapability函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: doMode
def doMode(self, irc, msg):
channel = msg.args[0]
chanOp = ircdb.makeChannelCapability(channel, 'op')
chanVoice = ircdb.makeChannelCapability(channel, 'voice')
chanHalfOp = ircdb.makeChannelCapability(channel, 'halfop')
if not ircdb.checkCapability(msg.prefix, chanOp):
irc.sendMsg(ircmsgs.deop(channel, msg.nick))
for (mode, value) in ircutils.separateModes(msg.args[1:]):
if not value:
continue
if ircutils.strEqual(value, msg.nick):
# We allow someone to mode themselves to oblivion.
continue
if irc.isNick(value):
hostmask = irc.state.nickToHostmask(value)
if mode == '+o':
if not self.isOp(irc, channel, hostmask):
irc.queueMsg(ircmsgs.deop(channel, value))
elif mode == '+h':
if not ircdb.checkCapability(hostmask, chanHalfOp):
irc.queueMsg(ircmsgs.dehalfop(channel, value))
elif mode == '+v':
if not ircdb.checkCapability(hostmask, chanVoice):
irc.queueMsg(ircmsgs.devoice(channel, value))
elif mode == '-o':
if ircdb.checkCapability(hostmask, chanOp):
irc.queueMsg(ircmsgs.op(channel, value))
elif mode == '-h':
if ircdb.checkCapability(hostmask, chanOp):
irc.queueMsg(ircmsgs.halfop(channel, value))
elif mode == '-v':
if ircdb.checkCapability(hostmask, chanOp):
irc.queueMsg(ircmsgs.voice(channel, value))
else:
assert ircutils.isUserHostmask(value)
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:35,代码来源:plugin.py
示例2: do
def do(type):
cap = ircdb.makeChannelCapability(channel, type)
cap_auto = ircdb.makeChannelCapability(channel, "auto" + type)
try:
apply_mode = ircdb.checkCapability(
msg.prefix,
cap,
ignoreOwner=not self.registryValue("owner"),
ignoreChannelOp=True,
ignoreDefaultAllow=True,
)
except KeyError:
apply_mode = False
if self.registryValue("alternativeCapabilities", channel):
try:
override = ircdb.checkCapability(
msg.prefix,
cap_auto,
ignoreOwner=not self.registryValue("owner"),
ignoreChannelOp=True,
ignoreDefaultAllow=True,
)
except KeyError:
override = False
else:
override = False
if apply_mode or override:
if override or self.registryValue(type, channel):
self.log.info("Scheduling auto-%s of %s in %s.", type, msg.prefix, channel)
def dismiss():
"""Determines whether or not a mode has already
been applied."""
l = getattr(irc.state.channels[channel], type + "s")
return msg.nick in l
msgmaker = getattr(ircmsgs, type)
schedule_msg(msgmaker(channel, msg.nick), dismiss)
raise Continue # Even if fallthrough, let's only do one.
elif not fallthrough:
self.log.debug(
"%s has %s, but supybot.plugins.AutoMode.%s"
" is not enabled in %s, refusing to fall "
"through.",
msg.prefix,
cap,
type,
channel,
)
raise Continue
开发者ID:nW44b,项目名称:Limnoria,代码行数:50,代码来源:plugin.py
示例3: part
def part(self, irc, msg, args, channel, reason):
"""[<channel>] [<reason>]
Tells the bot to part the list of channels you give it. <channel> is
only necessary if you want the bot to part a channel other than the
current channel. If <reason> is specified, use it as the part
message. Otherwise, the default part message specified in
supybot.plugins.Channel.partMsg will be used. No part message will be
used if no default is configured.
"""
if channel is None:
if irc.isChannel(msg.args[0]):
channel = msg.args[0]
else:
irc.error(Raise=True)
capability = ircdb.makeChannelCapability(channel, 'op')
hostmask = irc.state.nickToHostmask(msg.nick)
if not ircdb.checkCapabilities(hostmask, [capability, 'admin']):
irc.errorNoCapability(capability, Raise=True)
try:
network = conf.supybot.networks.get(irc.network)
network.channels().remove(channel)
except KeyError:
pass
if channel not in irc.state.channels:
irc.error(_('I\'m not in %s.') % channel, Raise=True)
reason = (reason or self.registryValue("partMsg", channel))
reason = ircutils.standardSubstitute(irc, msg, reason)
irc.queueMsg(ircmsgs.part(channel, reason))
if msg.nick in irc.state.channels[channel].users:
irc.noReply()
else:
irc.replySuccess()
开发者ID:Ban3,项目名称:Limnoria,代码行数:33,代码来源:plugin.py
示例4: checkChangeAllowed
def checkChangeAllowed(self, irc, msg, channel, user, record):
if user.id == record.by:
return True
cap = ircdb.makeChannelCapability(channel, 'op')
if ircdb.checkCapability(msg.prefix, cap):
return True
irc.errorNoCapability(cap)
开发者ID:Elwell,项目名称:supybot,代码行数:7,代码来源:__init__.py
示例5: inFilter
def inFilter(self, irc, msg):
self.filtering = True
# We need to check for bad words here rather than in doPrivmsg because
# messages don't get to doPrivmsg if the user is ignored.
if msg.command == 'PRIVMSG':
channel = msg.args[0]
self.updateRegexp(channel)
s = ircutils.stripFormatting(msg.args[1])
if ircutils.isChannel(channel) and self.registryValue('kick', channel):
if self.words and self.regexp.search(s):
c = irc.state.channels[channel]
cap = ircdb.makeChannelCapability(channel, 'op')
if c.isHalfopPlus(irc.nick):
if c.isHalfopPlus(msg.nick) or \
ircdb.checkCapability(msg.prefix, cap):
self.log.debug("Not kicking %s from %s, because "
"they are halfop+ or can't be "
"kicked.", msg.nick, channel)
else:
message = self.registryValue('kick.message', channel)
irc.queueMsg(ircmsgs.kick(channel, msg.nick, message))
else:
self.log.warning('Should kick %s from %s, but not opped.',
msg.nick, channel)
return msg
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:25,代码来源:plugin.py
示例6: checkChannelCapability
def checkChannelCapability(irc, msg, args, state, cap):
if not state.channel:
getChannel(irc, msg, args, state)
cap = ircdb.canonicalCapability(cap)
cap = ircdb.makeChannelCapability(state.channel, cap)
if not ircdb.checkCapability(msg.prefix, cap):
state.errorNoCapability(cap, Raise=True)
开发者ID:boamaod,项目名称:Limnoria,代码行数:7,代码来源:commands.py
示例7: 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
capability = ircdb.makeChannelCapability(channel, 'op')
hostmask = irc.state.nickToHostmask(msg.nick)
if 's' in irc.state.channels[channel].modes and \
msg.args[0] != channel and \
not ircdb.checkCapability(hostmask, capability) 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:
utils.sortBy(str.lower, L)
private = self.registryValue("nicksInPrivate", channel)
irc.reply(utils.str.commaAndify(L), private=private)
else:
irc.reply(str(len(L)))
开发者ID:Ban3,项目名称:Limnoria,代码行数:26,代码来源:plugin.py
示例8: doPrivmsg
def doPrivmsg(self, irc, msg):
(recipients, text) = msg.args
for channel in recipients.split(','):
if irc.isChannel(channel):
noLogPrefix = self.registryValue('noLogPrefix', channel)
cap = ircdb.makeChannelCapability(channel, 'logChannelMessages')
try:
logChannelMessages = ircdb.checkCapability(msg.prefix, cap,
ignoreOwner=True)
except KeyError:
logChannelMessages = True
nick = msg.nick or irc.nick
if msg.tagged('LogsToDB__relayed'):
(nick, text) = text.split(' ', 1)
nick = nick[1:-1]
msg.args = (recipients, text)
if (noLogPrefix and text.startswith(noLogPrefix)) or \
not logChannelMessages:
text = '-= THIS MESSAGE NOT LOGGED =-'
if ircmsgs.isAction(msg):
self.doLog(irc, channel,
'* %s %s\n', nick, ircmsgs.unAction(msg))
else:
self.doLog(irc, channel, '<%s> %s\n', nick, text)
message = msg.args[1]
self.logViewerDB.add_message(msg.nick, msg.prefix, message, channel)
self.logViewerFile.write_message(msg.nick, message)
开发者ID:hashweb,项目名称:LogsToDB,代码行数:28,代码来源:plugin.py
示例9: voice
def voice(self, irc, msg, args, channel, nicks):
"""[<channel>] [<nick> ...]
If you have the #channel,voice capability, this will voice all the
<nick>s you provide. If you don't provide any <nick>s, this will
voice you. <channel> is only necessary if the message isn't sent in the
channel itself.
"""
if nicks:
if len(nicks) == 1 and msg.nick in nicks:
capability = "voice"
else:
capability = "op"
else:
nicks = [msg.nick]
capability = "voice"
capability = ircdb.makeChannelCapability(channel, capability)
if ircdb.checkCapability(msg.prefix, capability):
def f(L):
return ircmsgs.voices(channel, L)
self._sendMsgs(irc, nicks, f)
else:
irc.errorNoCapability(capability)
开发者ID:fbesser,项目名称:Limnoria,代码行数:25,代码来源:plugin.py
示例10: checkAndAct
def checkAndAct (self,irc,prefix,chan,kind,items,text,msg):
protected = ircdb.makeChannelCapability(chan.name, 'protected')
if ircdb.checkCapability(prefix, protected):
return
for pattern in list(items.keys()):
item = chan.kinds[kind][pattern]
if item.enable == '1':
for match in re.finditer(item.re, text):
if match:
act = item.action
account = ''
gecos = ''
if prefix.split('!')[0] in chan.nicks:
(prefix,account,gecos) = chan.nicks[prefix.split('!')[0]]
act = act.replace('$nick',prefix.split('!')[0])
act = act.replace('$hostmask',prefix)
act = act.replace('$account',account)
act = act.replace('$username',gecos)
act = act.replace('$id',str(item.uid))
act = act.replace('$channel',chan.name)
act = act.replace('$*',text)
if act.find(' :') != -1:
a = text.split(' :')
if len(a) > 1:
act = act.replace('$text',text.split(' :')[1])
for (i, j) in enumerate(match.groups()):
act = re.sub(r'\$' + str(i+1), match.group(i+1), act)
self.act(irc,msg,chan.name,act,item.owner)
break
开发者ID:ncoevoet,项目名称:ChanReg,代码行数:29,代码来源:plugin.py
示例11: newpoll
def newpoll(self, irc, msg, args, channel, interval, answers, question):
"""<number of minutes for announce interval> <"answer,answer,..."> question
Creates a new poll with the given question and answers. <channel> is
only necessary if the message isn't sent in the channel itself."""
capability = ircdb.makeChannelCapability(channel, 'op')
if not ircdb.checkCapability(msg.prefix, capability):
irc.error('Need ops')
return
db = self.getDb(channel)
cursor = db.cursor()
self._execute_query(cursor, 'INSERT INTO polls VALUES (?,?,?,?,?)', None, datetime.datetime.now(), 1, None, question)
pollid = cursor.lastrowid
# used to add choices into db. each choice represented by character, starting at capital A (code 65)
def genAnswers():
for i, answer in enumerate(answers, start=65):
yield pollid, chr(i), answer
cursor.executemany('INSERT INTO choices VALUES (?,?,?)', genAnswers())
db.commit()
irc.reply('Started new poll #%s' % pollid)
# function called by schedule event. can not have args
def runPoll():
self._runPoll(irc, channel, pollid)
# start schedule. will announce poll/choices to channel at interval
schedule.addPeriodicEvent(runPoll, interval*60, name='%s_poll_%s' % (channel, pollid))
self.poll_schedules.append('%s_poll_%s' % (channel, pollid))
开发者ID:tz18,项目名称:Supybot-Polls,代码行数:33,代码来源:plugin.py
示例12: _checkManageCapabilities
def _checkManageCapabilities(self, irc, msg, channel):
"""Check if the user has any of the required capabilities to manage
the channel topic.
The list of required capabilities is in requireManageCapability
channel config.
Also allow if the user is a chanop. Since they can change the topic
manually anyway.
"""
c = irc.state.channels[channel]
if msg.nick in c.ops or msg.nick in c.halfops or 't' not in c.modes:
return True
capabilities = self.registryValue('requireManageCapability', channel)
if capabilities:
for capability in re.split(r'\s*;\s*', capabilities):
if capability.startswith('channel,'):
capability = ircdb.makeChannelCapability(
channel, capability[8:])
if capability and ircdb.checkCapability(msg.prefix, capability):
return
capabilities = self.registryValue('requireManageCapability',
channel)
irc.errorNoCapability(capabilities, Raise=True)
else:
return
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:26,代码来源:plugin.py
示例13: learn
def learn(self, irc, msg, args, channel, key, factoid):
db = self.getDb(channel)
cursor = db.cursor()
cursor.execute("SELECT id, locked FROM keys WHERE key LIKE %s", key)
if cursor.rowcount == 0:
cursor.execute("""INSERT INTO keys VALUES (NULL, %s, 0)""", key)
db.commit()
cursor.execute("SELECT id, locked FROM keys WHERE key LIKE %s", key)
(id, locked) = map(int, cursor.fetchone())
capability = ircdb.makeChannelCapability(channel, "factoids")
if not locked:
if ircdb.users.hasUser(msg.prefix):
name = ircdb.users.getUser(msg.prefix).name
else:
name = msg.nick
cursor.execute(
"""INSERT INTO factoids VALUES
(NULL, %s, %s, %s, %s)""",
id,
name,
int(time.time()),
factoid,
)
db.commit()
irc.replySuccess()
else:
irc.error("That factoid is locked.")
开发者ID:EnderBlue,项目名称:supybot,代码行数:27,代码来源:plugin.py
示例14: setUp
def setUp(self):
ChannelPluginTestCase.setUp(self)
self.prefix = "[email protected]"
self.nick = "foo"
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick, "register foo bar", prefix=self.prefix))
_ = self.irc.takeMsg()
chanop = ircdb.makeChannelCapability(self.channel, "op")
ircdb.users.getUser(self.nick).addCapability(chanop)
开发者ID:the1glorfindel,项目名称:PoohBot,代码行数:8,代码来源:test.py
示例15: _kban
def _kban(self, irc, msg, args, bannedNick, reason):
# Check that they're not trying to make us kickban ourself.
channel = msg.args[0]
if not irc.isNick(bannedNick[0]):
self.log.warning('%q tried to kban a non nick: %q',
msg.prefix, bannedNick)
raise callbacks.ArgumentError
elif bannedNick == irc.nick:
self.log.warning('%q tried to make me kban myself.', msg.prefix)
irc.error('I cowardly refuse to kickban myself.')
return
if not reason:
reason = msg.nick
try:
bannedHostmask = irc.state.nickToHostmask(bannedNick)
except KeyError:
irc.error(format('I haven\'t seen %s.', bannedNick), Raise=True)
capability = ircdb.makeChannelCapability(channel, 'op')
banmaskstyle = conf.supybot.protocols.irc.banmask
banmask = banmaskstyle.makeBanmask(bannedHostmask, ["host", "user"])
# Check (again) that they're not trying to make us kickban ourself.
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
if ircutils.hostmaskPatternEqual(bannedHostmask, irc.prefix):
self.log.warning('%q tried to make me kban myself.',msg.prefix)
irc.error('I cowardly refuse to ban myself.')
return
else:
self.log.warning('Using exact hostmask since banmask would '
'ban myself.')
banmask = bannedHostmask
# Now, let's actually get to it. Check to make sure they have
# #channel,op and the bannee doesn't have #channel,op; or that the
# bannee and the banner are both the same person.
def doBan():
if irc.state.channels[channel].isOp(bannedNick):
irc.queueMsg(ircmsgs.deop(channel, bannedNick))
irc.queueMsg(ircmsgs.ban(channel, banmask))
irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
def f():
if channel in irc.state.channels and \
banmask in irc.state.channels[channel].bans:
irc.queueMsg(ircmsgs.unban(channel, banmask))
schedule.addEvent(f, 3600)
if bannedNick == msg.nick:
doBan()
elif ircdb.checkCapability(msg.prefix, capability):
if ircdb.checkCapability(bannedHostmask, capability):
self.log.warning('%s tried to ban %q, but both have %s',
msg.prefix, bannedHostmask, capability)
irc.error(format('%s has %s too, you can\'t ban him/her/it.',
bannedNick, capability))
else:
doBan()
else:
self.log.warning('%q attempted kban without %s',
msg.prefix, capability)
irc.errorNoCapability(capability)
exact,nick,user,host
开发者ID:kyl191,项目名称:aurora,代码行数:58,代码来源:plugin.py
示例16: _checkManageCapabilities
def _checkManageCapabilities(self, irc, msg, channel):
"""Check if the user has any of the required capabilities to manage
the regexp database."""
if channel != 'global':
capability = ircdb.makeChannelCapability(channel, 'op')
else:
capability = 'admin'
if not ircdb.checkCapability(msg.prefix, capability):
irc.errorNoCapability(capability, Raise=True)
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:9,代码来源:plugin.py
示例17: isProtected
def isProtected(self, irc, channel, hostmask):
cap = ircdb.makeChannelCapability(channel, 'protected')
if ircdb.checkCapability(hostmask, cap):
self.log.debug('%s is protected on %s, it has %s.',
hostmask, channel, cap)
return True
if ircutils.strEqual(hostmask, irc.prefix):
return True
return False
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:9,代码来源:plugin.py
示例18: getCapability
def getCapability(name):
capability = 'owner' # Default to requiring the owner capability.
parts = registry.split(name)
while parts:
part = parts.pop()
if ircutils.isChannel(part):
# If a registry value has a channel in it, it requires a channel.op
# capability, or so we assume. We'll see if we're proven wrong.
capability = ircdb.makeChannelCapability(part, 'op')
### Do more later, for specific capabilities/sections.
return capability
开发者ID:Kefkius,项目名称:mazabot,代码行数:11,代码来源:plugin.py
示例19: setUp
def setUp(self):
ChannelPluginTestCase.setUp(self)
self.prefix = '[email protected]'
self.nick = 'foo'
self.wildcardTest = ['f*', '*oo', '*foo*', 'f*o*o']
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick,
'register foo bar',
prefix=self.prefix))
_ = self.irc.takeMsg()
chancap = ircdb.makeChannelCapability(self.channel, 'op')
ircdb.users.getUser(self.nick).addCapability(chancap)
开发者ID:Erika-Mustermann,项目名称:Limnoria,代码行数:11,代码来源:test.py
示例20: user_has_capability
def user_has_capability(self, msg):
channel = msg.args[0]
mask = msg.prefix
required_capability = self.registryValue("requireCapability")
cap = ircdb.makeChannelCapability(channel, required_capability)
has_cap = ircdb.checkCapability(mask, cap, ignoreDefaultAllow=True)
if has_cap:
log.debug("SpiffyTitles: %s has required capability '%s'" % (mask, required_capability))
else:
log.debug("SpiffyTitles: %s does NOT have required capability '%s'" % (mask, required_capability))
return has_cap
开发者ID:lunchdump,项目名称:limnoria-plugins,代码行数:13,代码来源:plugin.py
注:本文中的supybot.ircdb.makeChannelCapability函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论