• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python database.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.database.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: daemon

def daemon(code, tc):
    while True:
        time.sleep(auto_check)

        if code.debug:
            output.info('Running check for new tweets', 'TWITTER')
        # Here we do the work...
        for channel in tc:
            for tweet_item in tc[channel]:
                if tweet_item.startswith('#'):  # ID
                    data = get_tweets(uri_hash % web.quote(tweet_item))
                else:
                    data = get_tweets(uri_user % web.quote(tweet_item), tweet_item)
                if not data:
                    continue
                data = data[0]
                hash_str = hash(data['text'])
                db = database.get(code.default, 'twitter')
                if not db:  # New data on new database, don't output anywhere..
                    database.set(code.default, [hash_str], 'twitter')
                    continue
                if hash_str in db:
                    continue  # Same

                db.append(hash_str)
                database.set(code.default, db, 'twitter')
                msg = format(data)
                code.msg(channel, msg.decode('ascii', 'ignore'), shorten_urls=False)
            db = database.get(code.default, 'twitter')
            if db:
                if len(db) > 200:
                    db = db[-200:]
                    database.set(code.default, db, 'twitter')
开发者ID:HeyMan7,项目名称:Code,代码行数:33,代码来源:twitter.py


示例2: 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


示例3: 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


示例4: 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

    # now, to get the actual time
    url = "https://time.is/%s" % location.replace(' ','_').replace(' save','')
    try:
        request = urllib2.Request(url, None, headers)
        page = urllib2.urlopen(request).read()
        soup = BeautifulSoup(page, 'lxml')
        soup = soup.find('div', attrs={'id': re.compile('time_section')})
        time = filter(None, http.strip_html(soup.find('div', attrs={'id': re.compile('twd')}).renderContents().strip()))
        details = filter(None, http.strip_html(soup.find('div', attrs={'id': re.compile('dd')}).renderContents().strip()))
        prefix = filter(None, http.strip_html(soup.find('div', attrs={'id': re.compile('msgdiv')}).renderContents().strip()))
    except IndexError:
        return "Could not get time for that location."

    return formatting.output('Time', [u'{} {}, {}'.format(prefix.decode('ascii', 'ignore'), time, details)])
开发者ID:ihatevim,项目名称:spotbot,代码行数:34,代码来源:time.py


示例5: 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


示例6: 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


示例7: 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


示例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(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: return greeting
开发者ID:lity99,项目名称:uguubot,代码行数:27,代码来源:core_misc.py


示例9: 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


示例10: 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


示例11: host

def host(inp, nick=None, conn=None, db=None):
    # return user.get_hostmask(inp,db)
    if not inp:
        inp = nick
    db_host = database.get(db, 'users', 'mask', 'nick', inp)
    if inp is db_host:
        db_host = database.get(db, 'seen', 'host', 'name', inp)
    return "{}: {}".format(inp, db_host)
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:8,代码来源:core_ctcp.py


示例12: badwords

def badwords(inp, notice=None, bot=None, chan=None, db=None):
    """disabled [#channel] -- Lists disabled commands/."""

    if len(inp) == 0 or 'list' in inp:
        badwordlist = database.get(db, 'channels', 'badwords', 'chan', chan)
        if badwordlist:
            notice(u"[{}]: Bad words: {}".format(chan, badwordlist))
        else:
            notice(u"[{}]: No bad words in list.".format(chan))
            notice(badwords.__doc__)
    elif 'add' or 'del' in inp:
        command = inp.split(' ')[0].strip()
        inp = inp.replace(command, '').strip()
        badwordlist = database.get(db, 'channels', 'badwords', 'chan', chan)
        targets = inp.split()
        if 'add' in command:
            for target in targets:
                if badwordlist and target in badwordlist:
                    notice(
                        u"[{}]: {} is already a bad word.".format(
                            chan, target))
                else:
                    if len(target) < 3:
                        s = u"[{}]: badwords must be longer than 3 " \
                            "characters. ({})"
                        notice(s.format(chan, target))
                    else:
                        badwordlist = '{} {}'.format(target, badwordlist)
                        database.set(
                            db, 'channels', 'badwords',
                            badwordlist, 'chan', chan)
                        s = u"[{}]: {} has been added to the bad word list."
                        notice(s.format(chan, target))
        elif 'del' in command:
            if 'all' in targets or '*' in targets:
                database.set(db, 'channels', 'badwords', '', 'chan', chan)
                notice(u"[{}]: All bad words have been removed.".format(chan))
            else:
                for target in targets:
                    if badwordlist and target in badwordlist:
                        badwordlist = " ".join(
                            badwordlist.replace(
                                target, '').strip().split())
                        database.set(
                            db, 'channels', 'badwords', badwordlist, 'chan',
                            chan)
                        notice(
                            u"[{}]: {} is no longer a bad word.".format(
                                chan, target))
                    else:
                        notice(
                            u"[{}]: {} is not a bad word.".format(
                                chan, target))
    else:
        notice(badwords.__doc__)

    return
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:57,代码来源:core_admin_channel.py


示例13: process_vote

def process_vote(target,action,chan,mask,db,notice,conn):
    if ' ' in target: 
        notice('Invalid nick')
        return

    try: votes2kick = database.get(db,'channels','votekick','chan',chan)
    except: votes2kick = 10
    try: votes2ban = database.get(db,'channels','voteban','chan',chan)
    except: votes2ban = 10

    if len(target) is 0:
        if action is 'kick': notice('Votes required to kick: {}'.format(votes2kick))
        elif action is 'ban': notice('Votes required to ban: {}'.format(votes2ban))
        return

    votefinished = False
    global db_ready
    if not db_ready: db_init(db)
    chan = chan.lower()
    target = target.lower()
    voter = user.format_hostmask(mask)
    oters = db.execute("SELECT voters FROM votes where chan='{}' and action='{}' and target like '{}'".format(chan,action,target)).fetchone()

    if conn.nick.lower() in target: return "I dont think so Tim."

    if voters: 
        voters = voters[0]
        if voter in voters: 
            notice("You have already voted.")
            return
        else:
            voters = '{} {}'.format(voters,voter).strip()
            notice("Thank you for your vote!")
    else: 
        voters = voter

    votecount = len(voters.split(' '))

    if 'kick' in action: 
        votemax = int(votes2kick)
        if votecount >= votemax:
            votefinished = True
            conn.send("KICK {} {} :{}".format(chan, target, "You have been voted off the island."))
    if 'ban' in action:
        votemax = int(votes2ban)
        if votecount >= votemax:
            votefinished = True
            conn.send("MODE {} +b {}".format(chan, user.get_hostmask(target,db)))
            conn.send("KICK {} {} :".format(chan, target, "You have been voted off the island."))
    
    if votefinished: db.execute("DELETE FROM votes where chan='{}' and action='{}' and target like '{}'".format(chan,action,target))
    else: db.execute("insert or replace into votes(chan, action, target, voters, time) values(?,?,?,?,?)", (chan, action, target, voters, time.time()))
        
    db.commit()
    return ("Votes to {} {}: {}/{}".format(action, target, votecount,votemax))
开发者ID:Anonymike,项目名称:pasta-bot,代码行数:55,代码来源:vote.py


示例14: showfloods

def showfloods(inp, chan=None, notice=None, db=None):
    """showfloods [channel]-- Shows flood settings."""

    flood = database.get(db,'channels','flood','chan',chan)
    if flood: notice(u"[{}]: Flood: {} messages in {} seconds".format(chan,flood.split()[0],flood.split()[1]))
    else: notice(u"[{}]: Flood protection is disabled.".format(chan))

    cmdflood = database.get(db,'channels','cmdflood','chan',chan)
    if cmdflood: notice(u"[{}]: Command Flood: {} commands in {} seconds".format(chan,cmdflood.split()[0],cmdflood.split()[1]))
    else: notice(u"[{}]: Command Flood protection is disabled.".format(chan))
    return
开发者ID:geniusempire,项目名称:uguubot,代码行数:11,代码来源:core_admin_channel.py


示例15: get_hostmask

def get_hostmask(inp, db):
    "userhost -- Returns a nicks userhost"
    if "@" in inp or "." in inp:
        return inp
    nick = inp.strip().replace("~", "").lower()
    db_host = database.get(db, "users", "mask", "nick", nick)
    if db_host is False:
        db_host = database.get(db, "seen", "host", "name", nick)
    if db_host is False:
        db_host = nick

    return format_hostmask(db_host)
开发者ID:bytebit-ch,项目名称:uguubot,代码行数:12,代码来源:user.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: ignoresieve

def ignoresieve(bot, input, func, type, args):
    """ blocks input from ignored channels/nicks/hosts """
    globalignorelist = bot.config["ignored"]

    db = bot.get_db_connection(input.conn)
    mask = input.mask.lower()
    chan = input.chan.lower()
    ignorelist = database.get(db,'channels','ignored','chan',chan)

    # don't block input to event hooks
    # if type == "event": return input

    if user.is_admin(mask,chan,db,bot): return input

    if ignorelist and user.format_hostmask(mask) in ignorelist: return None
    if globalignorelist and user.format_hostmask(mask) in globalignorelist: return None
        #print "[{}]: {} is ignored.".format(input.chan,mask)
        



    # if input.chan.lower() in ignorelist \
    #    or input.nick.lower().replace('~','') in ignorelist \
    #    or input.mask.lower().replace('~','').lower() in ignorelist:
    #     if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore":
    #         return input
    #     else:
    #         return None
    return input
开发者ID:edwinfinch,项目名称:uguubot,代码行数:29,代码来源:core_sieve.py


示例18: 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


示例19: autoop

def autoop(inp, notice=None, bot=None, chan=None, db=None):
    """aop [channel] <enable|disable> OR <add|del> <nick|host> -- Add/Del Autoops."""
    inp,chan = get_chan(inp,chan)
    autoops = database.get(db,'channels','autoops','chan',chan)
    
    channel = chan.lower()
    command = inp.split()[0]
    if 'enable' in command:
        database.set(db,'channels','autoop',True,'chan',chan)
        notice(u"[{}]: Autoops is now enabled.".format(chan))
    elif 'disable' in command:
        database.set(db,'channels','autoop',False,'chan',chan)
        notice(u"[{}]: Autoops is now disabled.".format(chan))
    elif 'add' in command:
        nicks = inp.split()[1:]
        for nick in nicks:  
            nick = user.get_hostmask(nick,db)
            if autoops and nick in autoops:
                notice(u"[{}]: {} is already an autoop.".format(chan,nick))
            else:
                autoops = '{} {}'.format(nick,autoops).replace('False','').strip()
                database.set(db,'channels','autoops',autoops,'chan',chan)
                notice(u"[{}]: {} is now an auto op.".format(chan,nick))
    elif 'del' in command:
        nicks = inp.split()[1:]
        for nick in nicks:  
            nick = user.get_hostmask(nick,db)
            if autoops and nick in autoops:
                autoops = " ".join(autoops.replace(nick,'').strip().split())
                database.set(db,'channels','autoops',autoops,'chan',chan)
                notice(u"[{}]: {} is no longer an auto op.".format(chan,nick))
            else:
                notice(u"[{}]: {} is not an auto op.".format(chan,nick))
    return
开发者ID:edwinfinch,项目名称:uguubot,代码行数:34,代码来源:core_admin_channel.py


示例20: 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



注:本文中的util.database.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python database.set函数代码示例发布时间:2022-05-26
下一篇:
Python config.Config类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap