コード例 #1
0
ファイル: botbase.py プロジェクト: buzzworkers/Jsonbot
 def outmonitor(self, origin, channel, txt, event=None, plugorigin=None):
     """ create an OUTPUT event with provided txt and send it to callbacks. """
     if event and event.outmonitored: logging.info("event is already outmonitored") ; return
     if event: e = cpy(event)
     else: e = EventBase()
     if e.status == "done":
         logging.debug("%s - outmonitor - event is done .. ignoring" % self.cfg.name)
         return
     e.bot = self
     e.outmonitored = True
     e.origin = origin
     e.userhost = str(self.cfg.name) +'@' + str(self.cfg.uuid)
     e.auth = e.userhost
     e.channel = channel
     e.txt = txt
     e.cbtype = 'OUTPUT'
     e.nodispatch = True
     e.ttl = 1
     e.nick = self.cfg.nick or self.cfg.name
     e.bonded = True
     e.isoutput = True
     e.dontbind = True
     e.plugorigin = plugorigin or (event and event.plugorigin)
     logging.info("plug origin is %s" % e.plugorigin) 
     #first_callbacks.check(self, e)
     self.doevent(e)
コード例 #2
0
 def docmnd(self,
            origin,
            channel,
            txt,
            event=None,
            wait=0,
            showall=False,
            nooutput=False):
     """ do a command. """
     if event: e = cpy(event)
     else: e = EventBase()
     e.cbtype = "CMND"
     e.bot = self
     e.origin = origin
     e.auth = origin
     e.userhost = origin
     e.channel = channel
     e.txt = unicode(txt)
     e.nick = e.userhost.split('@')[0]
     e.usercmnd = e.txt.split()[0]
     e.allowqueues = True
     e.closequeue = True
     e.showall = showall
     e.nooutput = nooutput
     e.bind(self)
     if cmnds.woulddispatch(self, e) or e.txt[0] == "?":
         return self.doevent(e)
コード例 #3
0
 def outmonitor(self, origin, channel, txt, event=None, plugorigin=None):
     """ create an OUTPUT event with provided txt and send it to callbacks. """
     if event and event.outmonitored:
         logging.info("event is already outmonitored")
         return
     if event: e = cpy(event)
     else: e = EventBase()
     if e.status == "done":
         logging.debug("%s - outmonitor - event is done .. ignoring" %
                       self.cfg.name)
         return
     e.bot = self
     e.outmonitored = True
     e.origin = origin
     e.userhost = str(self.cfg.name) + '@' + str(self.cfg.uuid)
     e.auth = e.userhost
     e.channel = channel
     e.txt = txt
     e.cbtype = 'OUTPUT'
     e.nodispatch = True
     e.ttl = 1
     e.nick = self.cfg.nick or self.cfg.name
     e.bonded = True
     e.isoutput = True
     e.dontbind = True
     e.plugorigin = plugorigin or (event and event.plugorigin)
     logging.info("plug origin is %s" % e.plugorigin)
     #first_callbacks.check(self, e)
     self.doevent(e)
コード例 #4
0
 def make_event(self,
                origin,
                channel,
                txt,
                event=None,
                wait=0,
                showall=False,
                nooutput=False,
                cbtype=""):
     """ insert an event into the callbacks chain. """
     if event: e = cpy(event)
     else: e = EventBase(bot=self)
     e.cbtype = cbtype or "CMND"
     e.origin = origin or "test@test"
     e.auth = e.origin
     e.userhost = e.origin
     e.channel = channel
     if 'socket' in repr(channel): e.socket = channel
     e.txt = unicode(txt)
     e.nick = (event and event.nick) or stripident(e.userhost.split('@')[0])
     e.showall = showall
     e.nooutput = nooutput
     e.wait = wait
     e.closequeue = False
     e.bind(self)
     return e
コード例 #5
0
ファイル: botbase.py プロジェクト: code2u/jsb
 def putevent(self, origin, channel, txt, event=None, wait=0, showall=False, nooutput=False):
     """ insert an event into the callbacks chain. """
     assert origin
     if event: e = cpy(event) ; e.addwaiting(event)
     else: e = EventBase()
     e.cbtype = "CMND"
     e.bot = self
     e.origin = origin
     e.ruserhost = origin
     e.auth = origin
     e.userhost = origin
     e.channel = channel
     e.txt = unicode(txt)
     e.nick = e.userhost.split('@')[0]
     e.usercmnd = e.txt.split()[0]
     e.iscommand = False
     #e.iscallback = False
     e.allowqueues = True
     e.onlyqueues = False
     e.closequeue = True
     e.showall = showall
     e.nooutput = nooutput
     e.wait = wait
     e.bind(self)
     self.put(e)
     return e
コード例 #6
0
 def putevent(self,
              origin,
              channel,
              txt,
              event=None,
              wait=0,
              showall=False,
              nooutput=False):
     """ insert an event into the callbacks chain. """
     assert origin
     if event: e = cpy(event)
     else: e = EventBase()
     e.cbtype = "CMND"
     e.bot = self
     e.origin = origin
     e.ruserhost = origin
     e.auth = origin
     e.userhost = origin
     e.channel = channel
     e.txt = unicode(txt)
     e.nick = e.userhost.split('@')[0]
     e.usercmnd = e.txt.split()[0]
     e.iscommand = False
     #e.iscallback = False
     e.allowqueues = True
     e.onlyqueues = False
     e.closequeue = True
     e.showall = showall
     e.nooutput = nooutput
     e.wait = wait
     e.bind(self)
     self.put(e)
     return e
コード例 #7
0
ファイル: botbase.py プロジェクト: buzzworkers/Jsonbot
 def dostart(self, botname=None, bottype=None, *args, **kwargs):
     """ create an START event and send it to callbacks. """
     e = EventBase()
     e.bot = self
     e.botname = botname or self.cfg.name
     e.bottype = bottype or self.type
     e.origin = e.botname
     e.userhost = self.cfg.name +'@' + self.cfg.uuid
     e.nolog = True
     e.channel = botname
     e.txt = "%s.%s - %s" % (e.botname, e.bottype, str(time.time()))
     e.cbtype = 'START'
     e.ttl = 1
     e.nick = self.cfg.nick or self.cfg.name
     self.doevent(e)
     logging.debug("%s - START event send to callbacks" % self.cfg.name)
コード例 #8
0
 def dostart(self, botname=None, bottype=None, *args, **kwargs):
     """ create an START event and send it to callbacks. """
     e = EventBase()
     e.bot = self
     e.botname = botname or self.cfg.name
     e.bottype = bottype or self.type
     e.origin = e.botname
     e.userhost = self.cfg.name + '@' + self.cfg.uuid
     e.nolog = True
     e.channel = botname
     e.txt = "%s.%s - %s" % (e.botname, e.bottype, str(time.time()))
     e.cbtype = 'START'
     e.ttl = 1
     e.nick = self.cfg.nick or self.cfg.name
     self.doevent(e)
     logging.debug("%s - START event send to callbacks" % self.cfg.name)
コード例 #9
0
ファイル: botbase.py プロジェクト: buzzworkers/Jsonbot
 def make_event(self, origin, channel, txt, event=None, wait=0, showall=False, nooutput=False, cbtype=""):
     """ insert an event into the callbacks chain. """
     if event: e = cpy(event)
     else: e = EventBase(bot=self)
     e.cbtype = cbtype or "CMND"
     e.origin = origin or "test@test"
     e.auth = e.origin
     e.userhost = e.origin
     e.channel = channel
     if 'socket' in repr(channel): e.socket = channel
     e.txt = unicode(txt)
     e.nick = (event and event.nick) or stripident(e.userhost.split('@')[0])
     e.showall = showall
     e.nooutput = nooutput
     e.wait = wait
     e.closequeue = False
     e.bind(self)
     return e
コード例 #10
0
ファイル: botbase.py プロジェクト: melmothx/jsonbot
 def dostart(self, botname=None, bottype=None, *args, **kwargs):
     """ create an START event and send it to callbacks. """
     e = EventBase()
     e.bot = self
     e.botname = botname or self.name
     e.bottype = bottype or self.type
     e.origin = botname
     e.ruserhost = self.botname +'@' + self.uuid
     e.userhost = e.ruserhost
     e.channel = botname
     e.origtxt = str(time.time())
     e.txt = e.origtxt
     e.cbtype = 'START'
     e.botoutput = False
     e.ttl = 1
     e.nick = self.nick or self.botname
     self.doevent(e)
     logging.debug("%s - START event send to callbacks" % botname)
コード例 #11
0
 def dostart(self, botname=None, bottype=None, *args, **kwargs):
     """ create an START event and send it to callbacks. """
     e = EventBase()
     e.bot = self
     e.botname = botname or self.name
     e.bottype = bottype or self.type
     e.origin = botname
     e.ruserhost = self.botname + '@' + self.uuid
     e.userhost = e.ruserhost
     e.channel = botname
     e.origtxt = str(time.time())
     e.txt = e.origtxt
     e.cbtype = 'START'
     e.botoutput = False
     e.ttl = 1
     e.nick = self.nick or self.botname
     self.doevent(e)
     logging.debug("%s - START event send to callbacks" % botname)
コード例 #12
0
ファイル: botbase.py プロジェクト: buzzworkers/Jsonbot
 def docmnd(self, origin, channel, txt, event=None, wait=0, showall=False, nooutput=False):
     """ do a command. """
     if event: e = cpy(event)
     else: e = EventBase()   
     e.cbtype = "CMND"
     e.bot = self
     e.origin = origin
     e.auth = origin
     e.userhost = origin
     e.channel = channel
     e.txt = unicode(txt)
     e.nick = e.userhost.split('@')[0]
     e.usercmnd = e.txt.split()[0]
     e.allowqueues = True
     e.closequeue = True 
     e.showall = showall 
     e.nooutput = nooutput
     e.bind(self)
     if cmnds.woulddispatch(self, e) or e.txt[0] == "?": return self.doevent(e)
コード例 #13
0
ファイル: botbase.py プロジェクト: melmothx/jsonbot
 def outmonitor(self, origin, channel, txt, event=None):
     """ create an OUTPUT event with provided txt and send it to callbacks. """
     if event: e = cpy(event)
     else: e = EventBase()
     if e.status == "done":
         logging.debug("%s - outmonitor - event is done .. ignoring" % self.name)
         return
     e.bot = self
     e.origin = origin
     e.ruserhost = self.botname +'@' + self.uuid
     e.userhost = e.ruserhost
     e.auth = e.userhost
     e.channel = channel
     e.origtxt = txt
     e.txt = txt
     e.cbtype = 'OUTPUT'
     e.botoutput = True
     e.nodispatch = True
     e.ttl = 1
     e.nick = self.nick or self.botname
     e.bind(self)
     first_callbacks.check(self, e)
コード例 #14
0
 def outmonitor(self, origin, channel, txt, event=None):
     """ create an OUTPUT event with provided txt and send it to callbacks. """
     if event: e = cpy(event)
     else: e = EventBase()
     if e.status == "done":
         logging.debug("%s - outmonitor - event is done .. ignoring" %
                       self.name)
         return
     e.bot = self
     e.origin = origin
     e.ruserhost = self.botname + '@' + self.uuid
     e.userhost = e.ruserhost
     e.auth = e.userhost
     e.channel = channel
     e.origtxt = txt
     e.txt = txt
     e.cbtype = 'OUTPUT'
     e.botoutput = True
     e.nodispatch = True
     e.ttl = 1
     e.nick = self.nick or self.botname
     e.bind(self)
     first_callbacks.check(self, e)