Beispiel #1
0
    def __init__(self, servername):
        viewHandler.__init__(self)
        serverDispatcher.__init__(self)
        self.model = model.ircModel()
        # local, view related state
        self.channels = casedict()
        self.queries = casedict()
        #
        # Add ourself to the model as a server
        self.serverState = model.server()
        # save serverid in case we ever need to refer to it
        self.serverid = self.model.addServer(self.serverState)
        self.view = ircView.getIrcView()
        self.viewtext = self.view.new_view(servername)
        self.viewtext.setname(servername)
        self.cfg = getCfg()
        self.logger = Log(servername)

        self.notify = self.cfg('servers.notify', [])
        for i in self.notify:
            self.viewtext.notify_offline(i)

        self.notify_delayer = delay.Delayed()
        self.notify_delayer.ticktime = 10 # 1 tick = 10 sec
        self.notify_delayer.loop(self.send_notify, 2)
        main.addDelayed(self.notify_delayer)
Beispiel #2
0
    def run(self):
        # load config?
	# load scripts?
        global_cfg = "../rc/mostrc"
        if os.environ.has_key('MOSTRC'):
            global_cfg = os.environ['MOSTRC']

        config = getCfg()
        try:
            config.load(global_cfg)
        except IOError:
            print "Failed to load global configuration file."
            print "Please set the MOSTRC environment variable appropriately."
            sys.exit()

        try:
            config.load_home(".mostrc")
        except IOError:
            print "Failed to load user configurationfile."

	if os.environ.has_key("IRCNICK"):
	    self.nick = os.environ["IRCNICK"]
	if os.environ.has_key("IRCNAME"):
	    self.ircname = os.environ["IRCNAME"]

	if os.environ.has_key("IRCSERVER"):
	    server = os.environ["IRCSERVER"]
            items = string.split(server, ":")
	    self.ircserver=items[0]
	    if len(items) > 1:
	        self.ircport = string.atoi(items[1])

        if len(sys.argv) > 1:
	    self.nick = sys.argv[1]
        if len(sys.argv) > 2:
	    server = sys.argv[2]
            items = string.split(server, ":")
	    self.ircserver=items[0]
	    if len(items) > 1:
	        self.ircport = string.atoi(items[1])


        # create main view. Importing must be done after initial loading of config 
        from view import ircView
        from controller import ircController, msnController

        ircView.parse_config()
	self.view = ircView.getIrcView()
	self.view.set_handler(self)

	c1 = ircController(self.ircserver)

        c1.run(config.globals['servers'].nick, self.ircname, 
	                    self.ircserver, self.ircport)
        c1.set_handler(self)
	self.controllers.append(c1)

        handle = config('msn.handle', None)
        password = config('msn.password', None)

        if handle and password:
            m1 = msnController(handle, password)
            m1.run()

	self.view.mainloop()