Esempio n. 1
0
def do_opts(type="console", args=[], *argslist, **kwargs):
    from tl.version import getversion
    if not args: args = sys.argv
    if type != "console": print("TIMELINE %s" % getversion(type.upper()))
    cfg = None
    if type == "irc": target = api_opts + bot_opts + irc_opts
    elif type == "xmpp": target = api_opts + bot_opts + xmpp_opts
    elif type == "fleet": target = api_opts + fleet_opts
    elif type == "init": target = []
    elif type == "console": target = bot_opts + console_opts
    else: target = []
    opts =  make_opts(args, target, *argslist, **kwargs)
    if type == "console": ll = "error"
    else: ll = "warn" 
    if opts.datadir: setdatadir(opts.datadir)
    else: setdatadir(homedir + os.sep + ".tl")
    setloglevel(opts.loglevel or ll)
    if opts.bork: tl.utils.exception.bork = True ; logging.warn("bork mode enabled")
    if opts.nourl: tl.utils.url.enabled = False ; logging.warn("url fetching disabled")
    if opts.nocolors: tl.utils.log.docolor = False ; logging.warn("colors in logging is disabled")
    from tl.lib.users import getusers
    u = getusers()
    if opts.owner and u: u.make_owner(opts.owner)
    from tl.lib.config import getmainconfig
    maincfg = getmainconfig(opts.datadir)
    if type == "irc": cfg = makeircconfig(opts, opts.name)
    elif type == "xmpp" or type == "xmpp": cfg = makexmppconfig(opts, opts.name)
    elif type == "console": cfg = makeconsoleconfig(opts, opts.name)
    else: cfg = makedefaultconfig(opts, opts.name) 
    if opts.anon: cfg.auto_register = True ; cfg.guestasuser = True
    else: cfg.auto_register = False
    if maincfg.dbtype: logging.warn("database type is %s" % maincfg.dbtype)
    return (opts, cfg)
Esempio n. 2
0
 def handle_ctcp(self, ievent):
     """ handle client to client request .. version and ping. """
     if ievent.txt.find('VERSION') != -1:
         from tl.version import getversion
         self.ctcpreply(ievent.nick, 'VERSION %s' % getversion())
     if ievent.txt.find('PING') != -1:
         try:
             pingtime = ievent.txt.split()[1]
             pingtitl = ievent.txt.split()[2]
             if pingtime:
                 self.ctcpreply(ievent.nick, 'PING ' + pingtime + ' ' + pingtitl)
         except IndexError:
             pass
Esempio n. 3
0
 def handle_notice(self, ievent):
     """ handle notice event .. check for version request. """
     if ievent.txt and ievent.txt.find('VERSION') != -1:
         from tl.version import getversion
         self.say(ievent.nick, getversion(), None, 'notice')
         return 1
Esempio n. 4
0
def useragent():
    """ provide useragent string """
    from tl.version import getversion
    (name, version) = getversion().split()[0:2]
    return 'Mozilla/5.0 (X11; Linux x86_64); %s %s; http:///docs/tl)' % (name, version)