Пример #1
0
 def calcAvailableMsgLength(self, command):
     if self.prefixlen:
         # 510 = line terminator 508 = something else I'm not knowing about
         return 508 - self.prefixlen - len(
             lowQuote(command.encode(self.settings.encoding)))
     else:
         return self._safeMaximumLineLength(
             lowQuote(command.encode(
                 self.settings.encoding))) - 2  #line terminator
Пример #2
0
    def topic(self, t = None):
        if t is not None:
            self.topicmsg = str(t) if len(t) > 0 else None
            # for some reason, RPL_NOTOPIC is not a valid reply here! yeah... ask the rfc :P
            # we'll send this so there is at least an empty topic instead of none on clients which don't handle RPL_NOTOPIC here
            if len(t) == 0:
                self.server.sendMessage(irc.RPL_TOPIC, self.name, irc.lowQuote(str(t)))

        if self.topicmsg is not None:
            self.server.sendMessage(irc.RPL_TOPIC, self.name, irc.lowQuote(self.topicmsg))
        else:
            self.server.sendMessage(irc.RPL_NOTOPIC, self.name, irc.lowQuote("no topic is set"))
Пример #3
0
 def write(self, data):
   if data.split(' ')[0] == "ENBOT":
     self.enableBOT()
     return
  
   if self.__botIsEnable:
     database.client.write(self.__nickname, data)
   
   self.transport.write("%s\r\n" % irc.lowQuote(data.encode("utf-8")))
Пример #4
0
    def write(self, data):
        if data.split(' ')[0] == "ENBOT":
            self.enableBOT()
            return

        if self.__botIsEnable:
            database.client.write(self.__nickname, data)

        self.transport.write("%s\r\n" % irc.lowQuote(data.encode("utf-8")))
Пример #5
0
   def receive(self, sender, recipient, message):
      '''
      This is an override of the regular receive that always assumes
      it has been triggered by the PRIVMSG command. This one differs in that
      it checks for  the 'command' key in the message dict for UTM etc. and sends
      that command instead.

      Remember that sender and recipient are IChatClients, so use .user to get User
      '''
      if iwords.IGroup.providedBy(recipient):
         recipientName = '#' + recipient.name
      else:
         recipientName = recipient.name

      text = message.get('text', '<an unrepresentable message>')
      for line in text.splitlines():
         if 'command' not in message:
            assert False, 'need key: "command"'
         prefix = message.get('prefix', sender.avatar.getClientPrefix(message['command']))
         self.sendLine(":{0} {1} {2} {3}".format(prefix, message['command'],
                                                 recipientName,
                                                 line if 'raw' in message else ':'+lowQuote(line)))
Пример #6
0
 def write(self, data):
     self.transport.write(bytes("%s\r\n" % irc.lowQuote(data), 'utf-8'))
Пример #7
0
	def _reallySendLine(self, line):
		if self.debug >= 2: print "REALLY SENDING LINE:", repr(lowQuote(line) + self.delimiter)
		return LineReceiver.sendLine(self, lowQuote(line) + self.delimiter)
Пример #8
0
	def calcAvailableMsgLength(self, command):
		if self.prefixlen:
			# 510 = line terminator 508 = something else I'm not knowing about
			return 508 - self.prefixlen - len(lowQuote(command.encode(self.settings.encoding)))
		else:
			return self._safeMaximumLineLength(lowQuote(command.encode(self.settings.encoding))) - 2 #line terminator
Пример #9
0
 def test_lowquoteSanity(self):
     """Testing client-server level quote/dequote"""
     for s in stringSubjects:
         self.failUnlessEqual(s, irc.lowDequote(irc.lowQuote(s)))
Пример #10
0
 def write(self, data):
     self.transport.write("%s\r\n" % irc.lowQuote(data.encode("utf-8")))
Пример #11
0
 def test_lowquoteSanity(self):
     """Testing client-server level quote/dequote"""
     for s in stringSubjects:
         self.failUnlessEqual(s, irc.lowDequote(irc.lowQuote(s)))
Пример #12
0
 def write(self, data):
   self.transport.write("%s\r\n" % irc.lowQuote(data.encode("utf-8")))
Пример #13
0
	def _reallySendLine(self, line):
		return LineReceiver.sendLine(self, lowQuote(line) + self.delimiter)
Пример #14
0
 def _reallySendLine(self, line):
     if self.debug >= 2:
         print "REALLY SENDING LINE:", repr(lowQuote(line) + self.delimiter)
     return LineReceiver.sendLine(self, lowQuote(line) + self.delimiter)
Пример #15
0
 def notice(self, msg, prefix):
     self.server.sendMessage('NOTICE', irc.lowQuote(msg), frm=self.name, prefix=prefix)
Пример #16
0
 def msg(self, msg, prefix = None):
     self.server.sendMessage('PRIVMSG', irc.lowQuote(msg), frm=self.name, prefix=prefix if prefix is not None else self.server.hostname)
Пример #17
0
 def names(self):
     self.server.sendMessage(irc.RPL_NAMREPLY, self.name, irc.lowQuote(','.join([self.server.nick] + self.pusers.keys() )))
     self.server.sendMessage(irc.RPL_ENDOFNAMES, self.name, irc.lowQuote("End of /NAMES list"))