本文整理汇总了Python中willie.tools.Nick类的典型用法代码示例。如果您正苦于以下问题:Python Nick类的具体用法?Python Nick怎么用?Python Nick使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Nick类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: kickban
def kickban(bot, trigger):
"""
This gives admins the ability to kickban a user.
The bot must be a Channel Operator for this command to work
.kickban [#chan] user1 user!*@* get out of here
"""
if (not trigger.owner) and (not trigger.admin) and (bot.privileges[trigger.sender][trigger.nick] < OP):
return
text = trigger.group().split()
argc = len(text)
if argc < 4:
return
opt = Nick(text[1])
nick = opt
mask = text[2]
reasonidx = 3
if not opt.is_nick():
if argc < 5:
return
channel = opt
nick = text[2]
mask = text[3]
reasonidx = 4
reason = ' '.join(text[reasonidx:])
mask = configureHostMask(mask)
if mask == '':
return
bot.write(['MODE', channel, '+b', mask])
bot.write(['KICK', channel, nick, ' :', reason])
开发者ID:ict,项目名称:willie,代码行数:29,代码来源:adminchannel.py
示例2: unquiet
def unquiet(bot, trigger):
"""
This gives admins the ability to unquiet a user.
The bot must be a Channel Operator for this command to work.
"""
if bot.privileges[trigger.sender][trigger.nick] < OP:
return
if bot.privileges[trigger.sender][bot.nick] < OP:
return bot.reply("Non sono OP :(")
text = trigger.group().split()
argc = len(text)
if argc < 2:
return
opt = Nick(text[1])
quietmask = opt
channel = trigger.sender
if not opt.is_nick():
if argc < 3:
return
quietmask = text[2]
channel = opt
quietmask = configureHostMask(quietmask)
if quietmask == '':
return
bot.write(['MODE', opt, '-q', quietmask])
开发者ID:neslinesli93,项目名称:willie,代码行数:25,代码来源:adminchannel.py
示例3: kick
def kick(bot, trigger):
"""
Kick a user from the channel.
"""
if bot.privileges[trigger.sender][trigger.nick] < OP:
return
if bot.privileges[trigger.sender][bot.nick] < HALFOP:
return bot.reply("Non sono OP :(")
text = trigger.group().split()
argc = len(text)
if argc < 2:
return
opt = Nick(text[1])
nick = opt
channel = trigger.sender
reasonidx = 2
if not opt.is_nick():
if argc < 3:
return
nick = text[2]
channel = opt
reasonidx = 3
reason = '_'.join(text[reasonidx:])
if nick != bot.config.nick:
bot.write(['KICK', channel, nick, reason])
开发者ID:neslinesli93,项目名称:willie,代码行数:25,代码来源:adminchannel.py
示例4: ban
def ban(bot, trigger):
"""
This give admins the ability to ban a user.
The bot must be a Channel Operator for this command to work.
"""
if bot.privileges[trigger.sender][trigger.nick] < OP:
return
if bot.privileges[trigger.sender][bot.nick] < HALFOP:
return bot.reply("Non sono OP :(")
text = trigger.group().split()
argc = len(text)
if argc < 2:
return
opt = Nick(text[1])
banmask = opt
channel = trigger.sender
if not opt.is_nick():
if argc < 3:
return
channel = opt
banmask = text[2]
banmask = configureHostMask(banmask)
if banmask == '':
return
bot.write(['MODE', channel, '+b', banmask])
开发者ID:neslinesli93,项目名称:willie,代码行数:25,代码来源:adminchannel.py
示例5: kick
def kick(bot, trigger):
"""
Echa a un usuario del canal actual
"""
if bot.privileges[trigger.sender][trigger.nick] < OP:
return
if bot.privileges[trigger.sender][bot.nick] < HALFOP:
return bot.reply("No soy un operador del canal!")
text = trigger.group().split()
argc = len(text)
if argc < 2:
return
opt = Nick(text[1])
nick = opt
channel = trigger.sender
reasonidx = 2
if not opt.is_nick():
if argc < 3:
return
nick = text[2]
channel = opt
reasonidx = 3
reason = ' '.join(text[reasonidx:])
if nick != bot.config.nick:
bot.write(['KICK', channel, nick, reason])
开发者ID:InteliBOT,项目名称:pyDreamBot,代码行数:25,代码来源:adminchannel.py
示例6: kickban
def kickban(bot, trigger):
"""
Echa y veta a un usuario o máscara
%kickban [#chan] user1 user!*@* fuera de aquí
"""
if bot.privileges[trigger.sender][trigger.nick] < OP:
return
if bot.privileges[trigger.sender][bot.nick] < HALFOP:
return bot.reply("No soy operador de este canal!!")
text = trigger.group().split()
argc = len(text)
if argc < 4:
return
opt = Nick(text[1])
nick = opt
mask = text[2]
reasonidx = 3
if not opt.is_nick():
if argc < 5:
return
channel = opt
nick = text[2]
mask = text[3]
reasonidx = 4
reason = ' '.join(text[reasonidx:])
mask = configureHostMask(mask)
if mask == '':
return
bot.write(['MODE', channel, '+b', mask])
bot.write(['KICK', channel, nick, ' :', reason])
开发者ID:InteliBOT,项目名称:pyDreamBot,代码行数:30,代码来源:adminchannel.py
示例7: track_modes
def track_modes(bot, trigger):
"""Track usermode changes and keep our lists of ops up to date."""
# Mode message format: <channel> *( ( "-" / "+" ) *<modes> *<modeparams> )
channel = Nick(trigger.args[0])
line = trigger.args[1:]
# If the first character of where the mode is being set isn't a #
# then it's a user mode, not a channel mode, so we'll ignore it.
if channel.is_nick():
return
def handle_old_modes(nick, mode):
#Old mode maintenance. Drop this crap in 5.0.
if mode[1] == 'o' or mode[1] == 'q' or mode[1] == 'a':
if mode[0] == '+':
bot.add_op(channel, nick)
else:
bot.del_op(channel, nick)
elif mode[1] == 'h': # Halfop
if mode[0] == '+':
bot.add_halfop(channel, nick)
else:
bot.del_halfop(channel, nick)
elif mode[1] == 'v':
if mode[0] == '+':
bot.add_voice(channel, nick)
else:
bot.del_voice(channel, nick)
mapping = {'v': willie.module.VOICE,
'h': willie.module.HALFOP,
'o': willie.module.OP,
'a': willie.module.ADMIN,
'q': willie.module.OWNER}
modes = []
for arg in line:
if arg[0] in '+-':
# There was a comment claiming IRC allows e.g. MODE +aB-c foo, but
# I don't see it in any RFCs. Leaving in the extra parsing for now.
sign = ''
modes = []
for char in arg:
if char == '+' or char == '-':
sign = char
else:
modes.append(sign + char)
else:
arg = Nick(arg)
for mode in modes:
priv = bot.privileges[channel].get(arg, 0)
value = mapping.get(mode[1])
if value is not None:
if mode[0] == '+':
priv = priv | value
else:
priv = priv & ~value
bot.privileges[channel][arg] = priv
handle_old_modes(arg, mode)
开发者ID:icook,项目名称:willie,代码行数:59,代码来源:coretasks.py
示例8: handle
def handle(willie, trigger):
"""
Associates your IRC nick with a Twitter handle. Example: .handle @egdelwonk
"""
# prevent blocked users from accessing the trigger
if trigger.nick in willie.config.core.nick_blocks:
return
nick_target = trigger.group(2)
handle_match_re = re.compile(r'@([A-Za-z0-9_]+)')
updated_handle = re.findall(handle_match_re, trigger)
if willie.db and updated_handle:
# update the triggering nickname's twitter handle
willie.db.preferences.update(Nick(trigger.nick), {
'twitter_handle': updated_handle[0]})
willie.say(
Nick(trigger.nick) + ': your twitter handle is now @' + updated_handle[0])
elif nick_target:
# establish nick target
nick_target = Nick(nick_target.strip())
# return saved handle
nick_handle = get_handle(willie, nick_target)
# targeted nickname has a saved twitter handle
if nick_handle:
willie.say(
Nick(trigger.nick) + ': ' + nick_target +
'\'s twitter handle is: @' + nick_handle
+ ' / http://twitter.com/' + nick_handle)
# targeted nickname does not exists in usersdb preferences
else:
willie.say(
Nick(trigger.nick) + ': ' + nick_target + ' does not have a twitter handle saved yet.')
# no additional message was passed to the trigger
else:
nick_handle = get_handle(willie, Nick(trigger.nick))
if nick_handle:
willie.say(Nick(trigger.nick) + ': ' +
'your twitter handle is @' + nick_handle)
else:
willie.say(Nick(
trigger.nick) + ': ' + 'your twitter handle has not been saved yet.')
开发者ID:briandailey,项目名称:nashdevbot,代码行数:48,代码来源:twitter_handle.py
示例9: f_remind
def f_remind(willie, trigger):
teller = trigger.nick
verb, tellee, msg = trigger.groups()
verb = unicode(verb)
tellee = Nick(tellee.rstrip('.,:;'))
msg = unicode(msg)
if not os.path.exists(willie.tell_filename):
return
if len(tellee) > 20:
return willie.reply('That nickname is too long.')
if tellee == willie.nick:
return willie.reply("I'm here now, you can tell me whatever you want!")
tz, tformat = get_user_time(willie, tellee)
print tellee, tz, tformat
timenow = datetime.datetime.now(tz).strftime(tformat)
if not tellee in (Nick(teller), willie.nick, 'me'):
willie.memory['tell_lock'].acquire()
try:
if not willie.memory['reminders'].has_key(tellee):
willie.memory['reminders'][tellee] = [(teller, verb, timenow, msg)]
else:
willie.memory['reminders'][tellee].append((teller, verb, timenow, msg))
finally:
willie.memory['tell_lock'].release()
responses = [
"%s doesn't care, but I'll force it in conversation.",
"%s is probably just ignoring you.",
"Sure, I'll tell %s that right after you go outside once for in your life.",
"Sure says something when %s gives me more attention than they give you, doesn't it?",
"Sure, fine, whatever. I'll leave %s your message.",
"Alright, but I apologize in advance if %s just doesn't care.",
"Alright, next time I see %s I'll tell them that, just so you don't have to worry about spilling spaghetti on yourself.",
"I'll leave that with %s. Later. If I feel like it.",
"Aaalright, if you insist, but %s probably thinks you're just drunk right now.",
]
response = random.choice(responses) % tellee
willie.reply(response)
elif Nick(teller) == tellee:
willie.say("Look at me, I'm %s and I'm super clever at breaking IRC bots! I'm oozing cleverness!" % teller)
else: willie.say("Hey, I'm not as stupid as Monty you know!")
dumpReminders(willie.tell_filename, willie.memory['reminders'], willie.memory['tell_lock']) # @@ tell
开发者ID:CatmanIX,项目名称:FlutterBitch,代码行数:48,代码来源:tell.py
示例10: __init__
def __init__(self, bot, source, args, tags):
self.hostmask = source
self.tags = tags
# Split out the nick, user, and host from hostmask per the regex above.
match = Origin.source.match(source or '')
self.nick, self.user, self.host = match.groups()
self.nick = Nick(self.nick)
# If we have more than one argument, the second one is the sender
if len(args) > 1:
target = Nick(args[1])
else:
target = None
# Unless we're messaging the bot directly, in which case that second
# arg will be our bot's name.
if target and target.lower() == bot.nick.lower():
target = self.nick
self.sender = target
开发者ID:Chiggins,项目名称:willie,代码行数:20,代码来源:irc.py
示例11: f_remind
def f_remind(bot, trigger):
"""Give someone a message the next time they're seen"""
teller = trigger.nick
verb = trigger.group(1)
tellee, msg = trigger.group(2).split(None, 1)
tellee = Nick(tellee.rstrip(".,:;"))
if not os.path.exists(bot.tell_filename):
return
if len(tellee) > 20:
return bot.reply("That nickname is too long.")
if tellee == bot.nick:
return bot.reply("I'm here now, you can tell me whatever you want!")
tz, tformat = get_user_time(bot, tellee)
print tellee, tz, tformat
timenow = datetime.datetime.now(tz).strftime(tformat)
if not tellee in (Nick(teller), bot.nick, "me"):
bot.memory["tell_lock"].acquire()
try:
if not tellee in bot.memory["reminders"]:
bot.memory["reminders"][tellee] = [(teller, verb, timenow, msg)]
else:
bot.memory["reminders"][tellee].append((teller, verb, timenow, msg))
finally:
bot.memory["tell_lock"].release()
response = "I'll pass that on when %s is around." % tellee
bot.reply(response)
elif Nick(teller) == tellee:
bot.say("You can %s yourself that." % verb)
else:
bot.say("Hey, I'm not as stupid as Monty you know!")
dumpReminders(bot.tell_filename, bot.memory["reminders"], bot.memory["tell_lock"]) # @@ tell
开发者ID:roidelapluie,项目名称:willie,代码行数:39,代码来源:tell.py
示例12: f_remind
def f_remind(willie, trigger):
teller = trigger.nick
verb, tellee, msg = trigger.groups()
verb = unicode(verb)
tellee = Nick(tellee.rstrip(".,:;"))
msg = unicode(msg)
if not os.path.exists(willie.tell_filename):
return
if len(tellee) > 20:
return willie.reply("That nickname is too long.")
if tellee == willie.nick:
return willie.reply("I'm here now, you can tell me whatever you want!")
tz, tformat = get_user_time(willie, tellee)
print tellee, tz, tformat
timenow = datetime.datetime.now(tz).strftime(tformat)
if not tellee in (Nick(teller), willie.nick, "me"):
willie.memory["tell_lock"].acquire()
try:
if not willie.memory["reminders"].has_key(tellee):
willie.memory["reminders"][tellee] = [(teller, verb, timenow, msg)]
else:
willie.memory["reminders"][tellee].append((teller, verb, timenow, msg))
finally:
willie.memory["tell_lock"].release()
response = "I'll pass that on when %s is around." % tellee
willie.reply(response)
elif Nick(teller) == tellee:
willie.say("You can %s yourself that." % verb)
else:
willie.say("Hey, I'm not as stupid as Monty you know!")
dumpReminders(willie.tell_filename, willie.memory["reminders"], willie.memory["tell_lock"]) # @@ tell
开发者ID:briandailey,项目名称:nashdevbot,代码行数:38,代码来源:tell.py
示例13: kick
def kick(bot, trigger):
"""
Kick a user from the channel.
"""
if (not trigger.owner) and (not trigger.admin) and (bot.privileges[trigger.sender][trigger.nick] < OP):
return
text = trigger.group().split()
argc = len(text)
if argc < 2:
return
opt = Nick(text[1])
nick = opt
channel = trigger.sender
reasonidx = 2
if not opt.is_nick():
if argc < 3:
return
nick = text[2]
channel = opt
reasonidx = 3
reason = ' '.join(text[reasonidx:])
if nick != bot.config.nick:
bot.write(['KICK', channel, nick, reason])
开发者ID:ict,项目名称:willie,代码行数:23,代码来源:adminchannel.py
示例14: quiet
def quiet(bot, trigger):
"""
This gives admins the ability to quiet a user.
The bot must be a Channel Operator for this command to work
"""
if (not trigger.owner) and (not trigger.admin) and (bot.privileges[trigger.sender][trigger.nick] < OP):
return
text = trigger.group().split()
argc = len(text)
if argc < 2:
return
opt = Nick(text[1])
quietmask = opt
channel = trigger.sender
if not opt.is_nick():
if argc < 3:
return
quietmask = text[2]
channel = opt
quietmask = configureHostMask(quietmask)
if quietmask == '':
return
bot.write(['MODE', channel, '+q', quietmask])
开发者ID:ict,项目名称:willie,代码行数:23,代码来源:adminchannel.py
示例15: unquiet
def unquiet(bot, trigger):
"""
Quita el silencio de un usuario o máscara
"""
if bot.privileges[trigger.sender][trigger.nick] < OP:
return
if bot.privileges[trigger.sender][bot.nick] < OP:
return bot.reply("No soy operador de este canal!!")
text = trigger.group().split()
argc = len(text)
if argc < 2:
return
opt = Nick(text[1])
quietmask = opt
channel = trigger.sender
if not opt.is_nick():
if argc < 3:
return
quietmask = text[2]
channel = opt
quietmask = configureHostMask(quietmask)
if quietmask == '':
return
bot.write(['MODE', opt, '-q', quietmask])
开发者ID:InteliBOT,项目名称:pyDreamBot,代码行数:24,代码来源:adminchannel.py
示例16: unban
def unban(bot, trigger):
"""
Remueve un veto en el canal
"""
if bot.privileges[trigger.sender][trigger.nick] < OP:
return
if bot.privileges[trigger.sender][bot.nick] < HALFOP:
return bot.reply("No soy un operador de este canal!")
text = trigger.group().split()
argc = len(text)
if argc < 2:
return
opt = Nick(text[1])
banmask = opt
channel = trigger.sender
if not opt.is_nick():
if argc < 3:
return
channel = opt
banmask = text[2]
banmask = configureHostMask(banmask)
if banmask == '':
return
bot.write(['MODE', channel, '-b', banmask])
开发者ID:InteliBOT,项目名称:pyDreamBot,代码行数:24,代码来源:adminchannel.py
注:本文中的willie.tools.Nick类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论