def Run(self): if self.conf.startAfterFetch: self.firstFetch() self.onPlug() self.onStartupComplete() # child thread 1~4 StartDaemonThread(self.pollForever) StartDaemonThread(self.intervalForever) StartDaemonThread( QTermServer(self.conf.termServerPort, self.onTermCommand).Run) self.scheduler.start() self.started = True try: MainLoop() except SystemExit as e: self.onExit(e.code, getReason(e.code), None) raise except Exception as e: ERROR('', exc_info=True) ERROR('Mainloop 发生未知错误:%r', e) self.onExit(1, 'unknown-error', e) raise SystemExit(1)
def Login(self, qq=None, user=None): session, contactdb, self.conf = QLogin(qq, user) # main thread self.SendTo = session.SendTo self.groupKick = session.GroupKick self.groupSetAdmin = session.GroupSetAdmin self.groupShut = session.GroupShut self.groupSetCard = session.GroupSetCard # main thread self.List = contactdb.List self.StrOfList = contactdb.StrOfList self.find = contactdb.Find self.deleteMember = contactdb.DeleteMember self.setMemberCard = contactdb.SetMemberCard self.firstFetch = contactdb.FirstFetch # child thread 1 self.poll = session.Copy().Poll # child thread 2 self.termForver = QTermServer(self.conf.termServerPort).Run # runs in main thread, but puts tasks into child thread 3 self.updateForever = contactdb.UpdateForever
def Login(self, qq=None, user=None): self.conf = QConf(qq, user) session, contactdb, self.conf = QLogin(conf=self.conf) # main thread self.SendTo = session.SendTo self.groupKick = session.GroupKick self.groupSetAdmin = session.GroupSetAdmin self.groupShut = session.GroupShut self.groupSetCard = session.GroupSetCard # main thread self.List = contactdb.List self.Update = contactdb.Update self.StrOfList = contactdb.StrOfList self.ObjOfList = contactdb.ObjOfList self.findSender = contactdb.FindSender self.firstFetch = contactdb.FirstFetch self.Delete = contactdb.db.Delete self.Modify = contactdb.db.Modify # child thread 1 self.poll = session.Copy().Poll # child thread 2 self.termForver = QTermServer(self.conf.termServerPort).Run
def __init__(self, qq=None, user=None, conf=None, ai=None): MessageFactory.__init__(self) self.conf = conf if conf else QConf(qq, user) ai = ai if ai else BasicAI() termServer = QTermServer(self.conf.termServerPort) self.On('qqmessage', ai.OnQQMessage) # main thread self.On('polltimeout', ai.OnPollTimeout) # main thread self.On('termmessage', ai.OnTermMessage) # main thread self.On('pollcomplete', QQBot.onPollComplete) # main thread self.AddGenerator(self.pollForever) # child thread 1 self.AddGenerator(termServer.Run) # child thread 2
def Login(self, qq=None, user=None): session, contactdb, self.conf = QLogin(qq, user) # main thread self.SendTo = session.SendTo self.List = contactdb.List self.StrOfList = contactdb.StrOfList self.find = contactdb.Find # child thread 1/2/3 self.poll = session.Copy().Poll self.updateForever = contactdb.UpdateForever self.termForver = QTermServer(self.conf.termServerPort).Run
def Run(self): self.started = False QQBot.initScheduler(self) import qqbot.qslots as _x _x for plugin in self.conf.plugins: self.Plug(plugin) if self.conf.startAfterFetch: self.firstFetch() self.onStartupComplete() StartDaemonThread(self.pollForever) StartDaemonThread(self.intervalForever) StartDaemonThread( QTermServer(self.conf.termServerPort, self.onTermCommand).Run) self.started = True MainLoop()