Example #1
0
def handle_broadcast(bot, ievent):
    """ arguments: <txt> - broadcast txt to all joined channels. """
    if not ievent.rest:
         ievent.missing('<txt>')
         return
    ievent.reply('broadcasting')
    getfleet().broadcast(ievent.rest)
    partyline.say_broadcast(ievent.rest)
    ievent.reply('done')
Example #2
0
 def _dccloop(self, sock, nick, userhost, channel=None):
     """ loop for dcc commands. """
     sockfile = sock.makefile('r')
     sock.setblocking(True)
     res = ""
     partyline.add_party(self, sock, nick, userhost, channel)
     while 1:
         time.sleep(0.01)
         try:
             res = sockfile.readline()
             logging.warn("%s got %s (%s)" % ( userhost, res, self.cfg.name))
             if self.stopped or not res:
                 logging.warn('closing dcc with %s (%s)' % (nick, self.cfg.name))
                 partyline.del_party(nick)
                 return
         except socket.timeout:
             continue
         except socket.error as ex:
             try:
                 (errno, errstr) = ex
             except:
                 errno = 0
                 errstr = str(ex)
             if errno == 35 or errno == 11:
                 continue
             else:
                 raise
         except Exception as ex:
             handle_exception()
             logging.warn('closing dcc with %s' % (nick, self.cfg.name))
             partyline.del_party(nick)
             return
         try:
             res = self.normalize(res)
             ievent = IrcEvent()
             ievent.printto = sock
             ievent.bottype = "irc"
             ievent.nick = nick
             ievent.userhost = userhost
             ievent.auth = userhost
             ievent.channel = channel or ievent.userhost
             ievent.origtxt = res
             ievent.txt = res
             ievent.cmnd = 'DCC'
             ievent.cbtype = 'DCC'
             ievent.bot = self
             ievent.sock = sock
             ievent.speed = 1
             ievent.isdcc = True
             ievent.msg = True
             logging.debug("%s - dcc - constructed event" % self.cfg.name)
             ievent.bind()
             if ievent.hascc():
                 ievent.iscommand = True
                 ievent.showall = True
                 ievent.nodispatch = False
                 ievent.bind()
                 self.put(ievent)
                 continue
             elif ievent.txt[0] == "@":
                 partyline.say_broadcast_notself(ievent.nick, "[%s] %s" % (ievent.nick, ievent.txt))
                 q = queue.Queue()
                 ievent.queues = [q]
                 ievent.txt = ievent.txt[1:]
                 self.doevent(ievent)
                 result = waitforqueue(q, 3000)
                 if result:
                     for i in result:
                         partyline.say_broadcast("[bot] %s" % i)
                 continue
             else:
                 partyline.say_broadcast_notself(ievent.nick, "[%s] %s" % (ievent.nick, ievent.txt))
         except socket.error as ex:
             try:
                 (errno, errstr) = ex
             except:
                 errno = 0
                 errstr = str(ex)
             if errno == 35 or errno == 11:
                 continue
         except Exception as ex:
             handle_exception()
     sockfile.close()
     logging.warn('closing dcc with %s (%s)' %  (nick, self.cfg.name))