本文整理汇总了Python中util.database.set函数的典型用法代码示例。如果您正苦于以下问题:Python set函数的具体用法?Python set怎么用?Python set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: timefunction2
def timefunction2(inp, nick="", reply=None, db=None, notice=None):
"time [location] [dontsave] | [@ nick] -- Gets time for <location>."
save = True
if '@' in inp:
nick = inp.split('@')[1].strip()
location = database.get(db,'users','location','nick',nick)
if not location: return "No location stored for {}.".format(nick.encode('ascii', 'ignore'))
else:
location = database.get(db,'users','location','nick',nick)
if not inp:
if not location:
notice(time.__doc__)
return
else:
# if not location: save = True
if " dontsave" in inp: save = False
location = inp.split()[0]
# now, to get the actual time
try:
url = "https://time.is/%s" % location.replace(' ','+').replace(' save','')
html = http.get_html(url)
prefix = html.xpath("//div[@id='msgdiv']/h1/a/text()")[0].strip()
curtime = html.xpath("//div[contains(@id,'twd')]/text()")[0].strip()
ampm = html.xpath("//div[contains(@id,'twd')]/span/text()")[0].strip()
date = html.xpath("//h2[contains(@id,'dd')]/text()")[0].strip()
except IndexError:
return "Could not get time for that location."
if location and save: database.set(db,'users','location',location,'nick',nick)
return u'Time in {} is \x02{} {}\x02 [{}]'.format(prefix, curtime, ampm.upper(), date)
开发者ID:Noclip21,项目名称:uguubot,代码行数:34,代码来源:time.py
示例2: onjoined
def onjoined(inp,input=None, conn=None, chan=None,raw=None, db=None):
database.set(db,'users','mask',input.mask.lower().replace('~',''),'nick',input.nick.lower())
mask = user.format_hostmask(input.mask)
disabled_commands = database.get(db,'channels','disabled','chan',chan)
if not disabled_commands: disabled_commands = ""
if not 'banlist' in disabled_commands:
#check if bans
banlist = database.get(db,'channels','bans','chan',chan)
if banlist and mask in banlist:
conn.send(u"MODE {} {} *{}".format(input.chan, '+b', mask))
conn.send(u"KICK {} {} :{}".format(input.chan, input.nick, 'I dont think so Tim.'))
if not 'autoop' in disabled_commands:
#check if ops
autoop = database.get(db,'channels','autoop','chan',chan)
if autoop: autoops = database.get(db,'channels','admins','chan',chan)
else: autoops = database.get(db,'channels','autoops','chan',chan)
if autoops and mask in autoops:
conn.send(u"MODE {} {} {}".format(input.chan, '+o', input.nick))
if not 'greeting' in disabled_commands:
# send greeting
greeting = database.get(db,'users','greeting','nick',input.nick)
if greeting: conn.msg(chan, greeting.decode('UTF-8'))
if input.nick == "kimi":
conn.send('PRIVMSG {} :\x02[QUALITY OF CHANNEL SIGNIFICANTLY DECREASED]\x02'.format(input.chan))
开发者ID:inexist3nce,项目名称:Taigabot,代码行数:29,代码来源:core_misc.py
示例3: weather
def weather(inp, nick=None, reply=None, db=None, notice=None):
"weather | <location> [save] | <@ user> -- Gets weather data for <location>."
save = True
if '@' in inp:
save = False
nick = inp.split('@')[1].strip()
loc = database.get(db,'users','location','nick',nick)
if not loc: return "No location stored for {}.".format(nick.encode('ascii', 'ignore'))
else:
loc = database.get(db,'users','location','nick',nick)
if not inp:
if not loc:
notice(weather.__doc__)
return
else:
# if not loc: save = True
if " dontsave" in inp:
inp = inp.replace(' dontsave','')
save = False
loc = inp.replace(' ','_') #.split()[0]
location = http.quote_plus(loc)
# location = location.replace(',','').replace(' ','-')
# now, to get the actual weather
try:
data = get_weather('%s' % location)
except KeyError:
return "Could not get weather for that location."
if location and save: database.set(db,'users','location',location,'nick',nick)
# put all the stuff we want to use in a dictionary for easy formatting of the output
weather_data = {
"place": data['location']['city'],
"conditions": data['item']['condition']['text'],
"temp_f": data['item']['condition']['temp'],
"temp_c": data['item']['condition']['temp_c'],
"humidity": data['atmosphere']['humidity'],
"wind_kph": data['wind']['speed_kph'],
"wind_mph": data['wind']['speed'],
"wind_text": data['wind']['text'],
"forecast": data['item']['forecast'][0]['text'],
"high_f": data['item']['forecast'][0]['high'],
"high_c": data['item']['forecast'][0]['high_c'],
"low_f": data['item']['forecast'][0]['low'],
"low_c": data['item']['forecast'][0]['low_c'],
"_forecast": data['item']['forecast'][1]['text'],
"_high_f": data['item']['forecast'][1]['high'],
"_high_c": data['item']['forecast'][1]['high_c'],
"_low_f": data['item']['forecast'][1]['low'],
"_low_c": data['item']['forecast'][1]['low_c']
}
reply("\x02{place}\x02 - \x02Current:\x02 {conditions}, {temp_f}F/{temp_c}C, Humidity: {humidity}%, " \
"Wind: {wind_kph}KPH/{wind_mph}MPH {wind_text}, \x02Today:\x02 {forecast}, " \
"High: {high_f}F/{high_c}C, Low: {low_f}F/{low_c}C. " \
"\x02Tomorrow:\x02 {_forecast}, High: {_high_f}F" \
"/{_high_c}C, Low: {_low_f}F/{_low_c}C.".format(**weather_data))
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:60,代码来源:weather.py
示例4: horoscope
def horoscope(inp, db=None, notice=None, nick=None):
"""horoscope <sign> [save] -- Get your horoscope."""
save = False
database.init(db)
if '@' in inp:
nick = inp.split('@')[1].strip()
sign = database.get(db,'users','horoscope','nick',nick)
if not sign: return "No horoscope sign stored for {}.".format(nick)
else:
sign = database.get(db,'users','horoscope','nick',nick)
if not inp:
if not sign:
notice(horoscope.__doc__)
return
else:
if not sign: save = True
if " save" in inp: save = True
sign = inp.split()[0]
url = "http://www.astrology.com/horoscope/daily/%s.html" % sign
try:
request = urllib2.Request(url, None, headers)
page = urllib2.urlopen(request).read()
result = BeautifulSoup(page, 'lxml')
horoscopetxt = http.strip_html(str(result.find('div', attrs={'class':('page-horoscope-text')})))
except: return "Check your spelling, acronyms and short forms are not accepted."
if sign and save: database.set(db,'users','horoscope',sign,'nick',nick)
horoscopetxt = horoscopetxt.rsplit('.', 2)[0]
horoscopetxt += '.'
return u"{}".format(horoscopetxt)
开发者ID:ihatevim,项目名称:spotbot,代码行数:33,代码来源:core_user.py
示例5: enable
def enable(inp, notice=None, bot=None, chan=None, db=None):
"""enable [#channel] <commands|all> -- Enables commands for a channel.
(you can enable multiple commands at once)"""
disabledcommands = database.get(db,'channels','disabled','chan',chan)
targets = inp.split()
if 'all' in targets or '*' in targets:
database.set(db,'channels','disabled','','chan',chan)
notice(u"[{}]: All commands are now enabled.".format(chan))
else:
for target in targets:
if disabledcommands and target in disabledcommands:
disabledcommands = disabledcommands.split(" ")
for commands in disabledcommands:
if target == commands:
disabledcommands = " ".join(disabledcommands)
disabledcommands = " ".join(disabledcommands.replace(target,'').strip().split())
database.set(db,'channels','disabled',disabledcommands,'chan',chan)
notice(u"[{}]: {} is now enabled.".format(chan,target))
else:
pass
else:
if target in " ".join(bot.config["disabled_commands"]):
notice(u"[{}]: {} is globally disabled. Use .genable {} to enable.".format(chan,target,target))
else:
notice(u"[{}]: {} is not disabled.".format(chan,target))
return
开发者ID:FrozenPigs,项目名称:uguubot,代码行数:27,代码来源:core_admin_channel.py
示例6: horoscope
def horoscope(inp, db=None, notice=None, nick=None):
"""horoscope <sign> [save] -- Get your horoscope."""
save = False
database.init(db)
if '@' in inp:
nick = inp.split('@')[1].strip()
sign = database.get(db,'users','horoscope','nick',nick)
if not sign: return "No horoscope sign stored for {}.".format(nick)
else:
sign = database.get(db,'users','horoscope','nick',nick)
if not inp:
if not sign:
notice(horoscope.__doc__)
return
else:
if not sign: save = True
if " save" in inp: save = True
sign = inp.split()[0]
import urllib
url = "http://my.horoscope.com/astrology/free-daily-horoscope-%s.html" % sign
try:
response = urllib.urlopen(url)
result = response.read()
horoscopetxt = result.find('div', {'class': 'block-horoscope-text f16 l20'}).text
except: return "Could not get the horoscope for {}.".format(sign.encode('utf8'))
if sign and save: database.set(db,'users','horoscope',sign,'nick',nick)
return u"\x02{}\x02 {}".format(sign, horoscopetxt)
开发者ID:ewhal,项目名称:uguubot,代码行数:31,代码来源:core_user.py
示例7: ban
def ban(inp, conn=None, chan=None, notice=None, db=None, nick=None):
"""ban [channel] <user> [reason] [timer] -- Makes the bot ban <user> in [channel].
If [channel] is blank the bot will ban <user> in
the channel the command was used in."""
mode = "+b"
reason = "#rekt"
inp,chan = get_chan(inp,chan)
split = inp.split(" ")
inp_nick = split[0]
if conn.nick in inp_nick or 'infinity' in inp_nick:
target = nick
reason = "Youre silly onii-chan."
conn.send(u"KICK {} {} :{}".format(chan, target, reason))
return
if len(split) > 1: reason = " ".join(split[1:])
target = user.get_hostmask(inp_nick,db)
if '@' in target and not '!' in target: target = '*!*{}'.format(target)
timer = scheduler.check_for_timers(inp)
if timer > 0: reason = "{} Come back in {} seconds!!!".format(reason,timer)
notice(u"Attempting to ban {} in {}...".format(nick, chan))
conn.send(u"MODE {} {} {}".format(chan, mode, target))
conn.send(u"KICK {} {} :{}".format(chan, inp_nick, reason))
if timer > 0:
notice(u"{} will be unbanned in {} seconds".format(target, timer))
scheduler.schedule(timer, 1, "MODE {} -b {}".format(chan, target), conn)
#scheduler.schedule(timer, 2, "PRIVMSG ChanServ :unban {} {}".format(channel, nick), conn)
else:
banlist = database.get(db,'channels','bans','chan',chan)
banlist = '{} {}'.format(target,banlist).replace('False','').strip()
database.set(db,'channels','bans',banlist,'chan',chan)
return
开发者ID:edwinfinch,项目名称:uguubot,代码行数:34,代码来源:core_admin_channel.py
示例8: onjoined
def onjoined(inp,input=None, conn=None, chan=None,raw=None, db=None):
database.set(db,'users','mask',input.mask.lower().replace('~',''),'nick',input.nick.lower())
mask = user.format_hostmask(input.mask)
disabled_commands = database.get(db,'channels','disabled','chan',chan)
if not disabled_commands: disabled_commands = ""
if not 'banlist' in disabled_commands:
#check if bans
banlist = database.get(db,'channels','bans','chan',chan)
if banlist and mask in banlist:
conn.send("MODE {} {} *{}".format(input.chan, '+b', mask))
conn.send("KICK {} {} :{}".format(input.chan, input.nick, 'I dont think so Tim.'))
if not 'autoop' in disabled_commands:
#check if ops
autoop = database.get(db,'channels','autoop','chan',chan)
if autoop: autoops = database.get(db,'channels','admins','chan',chan)
else: autoops = database.get(db,'channels','autoops','chan',chan)
if autoops and mask in autoops:
conn.send("MODE {} {} {}".format(input.chan, '+o', input.nick))
if not 'greeting' in disabled_commands:
# send greeting
greeting = database.get(db,'users','greeting','nick',input.nick)
if greeting: return greeting
开发者ID:bytebit-ch,项目名称:uguubot,代码行数:27,代码来源:core_misc.py
示例9: cmdflood
def cmdflood(inp, conn=None, chan=None, notice=None, db=None):
'''
cmdflood [channel] <number> <duration> | disable
Enables commandflood protection for a channel.
ex: .cmdflood 3 30 - Allows 3 commands in 30 seconds,
set disable to disable.
'''
if len(inp) == 0:
floods = database.get(db, 'channels', 'cmdflood', 'chan', chan)
if floods:
notice(u"[{}]: Command Flood: {} commands in {} seconds".format(
chan, floods.split()[0], floods.split()[1]))
else:
notice(u"[{}]: CMD Flood is disabled.".format(chan))
notice(cmdflood.__doc__)
elif "disable" in inp:
database.set(db, 'channels', 'cmdflood', None, 'chan', chan)
notice(u"[{}]: Command Flood Protection Disabled.".format(chan))
else:
flood_num = inp.split()[0]
flood_duration = inp.split()[1]
floods = '{} {}'.format(flood_num, flood_duration)
database.set(db, 'channels', 'cmdflood', floods, 'chan', chan)
s = u"[{}]: Command Flood Protection limited to {} commands " \
"in {} seconds."
notice(s.format(chan, flood_num, flood_duration))
return
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:28,代码来源:core_admin_channel.py
示例10: horoscope
def horoscope(inp, db=None, notice=None, nick=None):
"""horoscope <sign> [save] -- Get your horoscope."""
save = False
database.init(db)
if '@' in inp:
nick = inp.split('@')[1].strip()
sign = database.get(db,'users','horoscope','nick',nick)
if not sign: return "No horoscope sign stored for {}.".format(nick)
else:
sign = database.get(db,'users','horoscope','nick',nick)
if not inp:
if not sign:
notice(horoscope.__doc__)
return
else:
if not sign: save = True
if " save" in inp: save = True
sign = inp.split()[0]
url = "http://my.horoscope.com/astrology/free-daily-horoscope-%s.html" % sign
try:
result = http.get_soup(url)
title = result.find_all('h1', {'class': 'h1b'})[1].text
horoscopetxt = result.find('div', {'id': 'textline'}).text
except: return "Could not get the horoscope for {}.".format(sign.encode('utf8'))
if sign and save: database.set(db,'users','horoscope',sign,'nick',nick)
return u"\x02{}\x02 {}".format(title, horoscopetxt)
开发者ID:Noclip21,项目名称:uguubot,代码行数:30,代码来源:core_user.py
示例11: disablehash
def disablehash(inp, notice=None, bot=None, chan=None, db=None):
'''
disablehash [#channel] <hashtah
Disables hashtah for a channel.
(you can disable multiple hastags at once, don't put # before the hashtag)
'''
disabledhashes = database.get(
db, 'channels', 'disabledhashes', 'chan', chan)
targets = inp.split()
for target in targets:
if disabledhashes and target in disabledhashes:
notice(u"[{}]: {} is already disabled.".format(chan, target))
else:
if 'disable' in target or 'enable' in target:
notice(u"[{}]: {} cannot be disabled.".format(chan, target))
else:
disabledhashes = '{} {}'.format(target, disabledhashes)
database.set(
db,
'channels',
'disabledhashes',
disabledhashes,
'chan',
chan)
notice(u"[{}]: {} has been disabled.".format(chan, target))
return
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:27,代码来源:core_admin_channel.py
示例12: enablehash
def enablehash(inp, notice=None, bot=None, chan=None, db=None):
'''
enablehash [#channel] <hashtag|all>
Enables hashtags for a channel.
(you can enable multiple hashtags at once, don't put # before the hashtag)
'''
disabledhashes = database.get(
db, 'channels', 'disabledhashes', 'chan', chan)
targets = inp.split()
if 'all' in targets or '*' in targets:
database.set(db, 'channels', 'disabledhashes', '', 'chan', chan)
notice(u"[{}]: All commands are now enabled.".format(chan))
else:
for target in targets:
if disabledhashes and target in disabledhashes:
disabledhashes = " ".join(
disabledhashes.replace(
target, '').strip().split())
database.set(
db,
'channels',
'disabledhashes',
disabledhashes,
'chan',
chan)
notice(u"[{}]: {} is now enabled.".format(chan, target))
else:
notice(u"[{}]: {} is not disabled.".format(chan, target))
return
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:30,代码来源:core_admin_channel.py
示例13: ignore
def ignore(inp, notice=None, bot=None, chan=None, db=None):
"""ignore [channel] <nick|host> -- Makes the bot ignore <nick|host>."""
ignorelist = database.get(db, 'channels', 'ignored', 'chan', chan)
targets = inp.split()
for target in targets:
target = user.get_hostmask(target, db)
if (user.is_admin(target, chan, db, bot)):
notice(
u"[{}]: {} is an admin and cannot be ignored.".format(
chan, inp))
else:
if ignorelist and target in ignorelist:
notice(u"[{}]: {} is already ignored.".format(chan, target))
else:
ignorelist = '{} {}'.format(target, ignorelist)
database.set(
db,
'channels',
'ignored',
ignorelist,
'chan',
chan)
notice(u"[{}]: {} has been ignored.".format(chan, target))
return
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:25,代码来源:core_admin_channel.py
示例14: admin
def admin(inp, notice=None, bot=None, chan=None, db=None):
"""admin [channel] <add|del> <nick|host> -- Makes the user an admin."""
inp,chan = get_chan(inp,chan)
admins = database.get(db,'channels','admins','chan',chan)
channel = chan.lower()
command = inp.split()[0]
nicks = inp.split()[1:]
if 'add' in command:
for nick in nicks:
nick = user.get_hostmask(nick,db)
if admins and nick in admins:
notice(u"[{}]: {} is already an admin.".format(chan,nick))
else:
admins = '{} {}'.format(nick,admins).replace('False','').strip()
database.set(db,'channels','admins',admins,'chan',chan)
notice(u"[{}]: {} is now an admin.".format(chan,nick))
elif 'del' in command:
for nick in nicks:
nick = user.get_hostmask(nick,db)
if admins and nick in admins:
admins = " ".join(admins.replace(nick,'').strip().split())
database.set(db,'channels','admins',admins,'chan',chan)
notice(u"[{}]: {} is no longer an admin.".format(chan,nick))
else:
notice(u"[{}]: {} is not an admin.".format(chan,nick))
return
开发者ID:edwinfinch,项目名称:uguubot,代码行数:28,代码来源:core_admin_channel.py
示例15: time
def time(inp, nick="", reply=None, db=None, notice=None):
"time [location] [dontsave] | [@ nick] -- Gets time for <location>."
save = True
if '@' in inp:
nick = inp.split('@')[1].strip()
location = database.get(db,'users','location','nick',nick)
if not location: return "No location stored for {}.".format(nick.encode('ascii', 'ignore'))
else:
location = database.get(db,'users','location','nick',nick)
if not inp:
if not location:
notice(time.__doc__)
return
else:
if not location: save = True
if " save" in inp: save = True
location = inp.split()[0]
# now, to get the actual time
try:
url = "https://www.google.com/search?q=time+in+%s" % location.replace(' ','+').replace(' save','')
html = http.get_html(url)
prefix = html.xpath("//div[contains(@class,'vk_c vk_gy')]//span[@class='vk_gy vk_sh']/text()")[0].strip()
curtime = html.xpath("//div[contains(@class,'vk_c vk_gy')]//div[@class='vk_bk vk_ans']/text()")[0].strip()
day = html.xpath("//div[contains(@class,'vk_c vk_gy')]//div[@class='vk_gy vk_sh']/text()")[0].strip()
date = html.xpath("//div[contains(@class,'vk_c vk_gy')]//div[@class='vk_gy vk_sh']/span/text()")[0].strip()
except IndexError:
return "Could not get time for that location."
if location and save: database.set(db,'users','location',location,'nick',nick)
return u'{} is \x02{}\x02 [{} {}]'.format(prefix, curtime, day, date)
开发者ID:edwinfinch,项目名称:uguubot,代码行数:34,代码来源:time.py
示例16: weather
def weather(inp, nick=None, reply=None, db=None, notice=None):
"weather | <location> [save] | <@ user> -- Gets weather data for <location>."
save = False
if '@' in inp:
save = False
nick = inp.split('@')[1].strip()
loc = database.get(db,'users','location','nick',nick)
if not loc: return "No location stored for {}.".format(nick.encode('ascii', 'ignore'))
else:
loc = database.get(db,'users','location','nick',nick)
if not inp:
if not loc:
notice(weather.__doc__)
return
else:
# if not loc: save = True
if " save" in inp:
inp = inp.replace(' save','')
save = True
loc = inp.replace(' ','_') #.split()[0]
location = http.quote_plus(loc)
# location = location.replace(',','').replace(' ','-')
# now, to get the actual weather
try:
q ={
'q': 'select title, units.temperature, item.forecast from weather.forecast where woeid in (select woeid from geo.places where text="'+ location+'") limit 1',
'format': 'json',
'env': 'store://datatables.org/alltableswithkeys'
}
result = query(q)
data = json.loads(result)
weather = data["query"]["results"]["channel"]
average_F = float((int(weather['item']['forecast']['high']) + int(weather['item']['forecast']['low']))/2)
average_C = round(float((average_F - 32) * (5.0/9.0)), 2)
except KeyError:
return "Could not get weather for that location."
if location and save: database.set(db,'users','location',location,'nick',nick)
# put all the stuff we want to use in a dictionary for easy formatting of the output
weather_data = {
'title': weather["title"].replace("Yahoo! Weather -", ""),
'current': weather['item']['forecast']['text'],
'temp_f': average_F,
'temp_c': average_C
}
reply("\x02{title}\x02 - \x02Current:\x02 {current}, {temp_f}F/{temp_c}C".format(**weather_data))
开发者ID:ewhal,项目名称:uguubot,代码行数:53,代码来源:weather.py
示例17: unignore
def unignore(code, input):
""" unignore <mask> - Removes <mask> from ignore list. """
mask = matchmask(input.group(2))
if not mask:
return code.say('Invalid mask! For more info, see: https://github.com/Liamraystanley/Code/wiki/Masks')
blocks = database.get(code.nick, 'ignore', [])
if mask not in blocks:
return code.say('%s doesn\'t exist in the ignore list!' % mask)
del blocks[blocks.index(mask)]
code.blocks = blocks
code.blocks = [convertmask(x) for x in blocks]
database.set(code.nick, blocks, 'ignore')
return code.say('Successfully removed %s from the ignore list.' % mask)
开发者ID:HeyMan7,项目名称:Code,代码行数:13,代码来源:admin.py
示例18: unignore
def unignore(inp, notice=None, bot=None, chan=None, db=None):
"""unignore [channel] <nick|host> -- Makes the bot listen to <nick|host>."""
ignorelist = database.get(db,'channels','ignored','chan',chan)
targets = inp.split()
for target in targets:
target = user.get_hostmask(target,db)
if ignorelist and target in ignorelist:
ignorelist = " ".join(ignorelist.replace(target,'').strip().split())
database.set(db,'channels','ignored',ignorelist,'chan',chan)
notice(u"[{}]: {} has been unignored.".format(chan,target))
else:
notice(u"[{}]: {} is not ignored.".format(chan,target))
return
开发者ID:geniusempire,项目名称:uguubot,代码行数:13,代码来源:core_admin_channel.py
示例19: ban
def ban(inp, conn=None, chan=None, notice=None, db=None, nick=None, bot=None):
'''
ban [channel] <user> [reason] [timer]
Makes the bot ban <user> in [channel].
If [channel] is blank the bot will ban <user> in
the channel the command was used in.
'''
mode = "+b"
reason = "#rekt"
# inp,chan = get_chan(inp,chan)
split = inp.split(" ")
inp_nick = split[0]
if conn.nick in inp_nick or bot.config['owner'] == inp_nick:
target = nick
reason = "Your attitude is not conducive to the desired environment"
conn.send(u"KICK {} {} :{}".format(chan, target, reason))
return
if len(split) > 1:
reason = " ".join(split[1:])
if '@' not in inp_nick:
target = user.get_hostmask(inp_nick, db)
else:
target = inp_nick
if '@' in target and '!' not in target:
target = '*!*{}'.format(target)
timer = scheduler.check_for_timers(inp)
if timer > 0:
reason = "{} Come back in {} seconds!!!".format(reason, timer)
notice(u"Attempting to ban {} in {}...".format(target, chan))
conn.send(u"MODE {} {} {}".format(chan, mode, target))
conn.send(u"KICK {} {} :{}".format(chan, inp_nick, reason))
if timer > 0:
notice(u"{} will be unbanned in {} seconds".format(target, timer))
scheduler.schedule(
timer, 1, "MODE {} -b {}".format(chan, target), conn)
# scheduler.schedule(timer, 2,
# "PRIVMSG ChanServ :unban {} {}".format(channel,
# nick),
# conn)
else:
banlist = database.get(db, 'channels', 'bans', 'chan', chan)
banlist = '{} {}'.format(target, banlist).replace('False', '').strip()
database.set(db, 'channels', 'bans', banlist, 'chan', chan)
return
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:50,代码来源:core_admin_channel.py
示例20: mug
def mug(inp, db=None, nick=None, chan=None, conn=None, notice=None):
"""mug <user> -- Takes money from <user>.."""
inp = inp.split()
user = inp[0]
money = float(random.randint(20, 1500))
try:
money = inp[-1].split('.')[0] + '.' + inp[-1].split('.')[1][0:2]
money = float(money)
except:
pass
try:
robber = float(database.get(db,'users','fines','nick',nick))
except:
robber = 0.0
try:
victim = float(database.get(db,'users','fines','nick',user))
except:
victim = 0.0
robbingfails = random.randint(1, 3)
if robbingfails == 2:
if victim != robber:
database.set(db,'users','fines',robber + money,'nick', nick)
database.set(db,'users','fines',victim - money,'nick',user)
conn.send(u"PRIVMSG {} :\x01ACTION {} shoots you in the foot and takes \x02${}\x02.\x01".format(chan, user, money))
else:
if robber != victim:
database.set(db,'users','fines',victim + money,'nick', user)
database.set(db,'users','fines',robber - money,'nick', nick)
conn.send(u"PRIVMSG {} :\x01ACTION {} shanks {} in a dark alley and takes \x02${}\x02\x01".format(chan, nick, user, money))
开发者ID:inexist3nce,项目名称:Taigabot,代码行数:29,代码来源:stupid.py
注:本文中的util.database.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论