コード例 #1
0
ファイル: server.py プロジェクト: Screwperman/pyirc
 def _handle_command(self, command):
     cmd = wireproto.decode(command)
     if cmd.command in self._command_handlers:
         self._command_handlers[cmd.command](cmd)
     else:
         print 'Ignored %s' % cmd.command
     if cmd.command == '376':
         self._conn.output(wireproto.encode('QUIT'))
コード例 #2
0
ファイル: wireproto_test.py プロジェクト: Screwperman/pyirc
 def testEncoding(self):
     """Message encoding"""
     self.assertEquals(
         wireproto.encode('notice'), 'NOTICE\r\n')
     # Single argument commands end up having two spaces between
     # command and arguments. According to the IRC protocol, this is
     # fine, so it's just a little oddity of our encoder.
     self.assertEquals(
         wireproto.encode('join', '#bleh'), 'JOIN  :#bleh\r\n')
     self.assertEquals(
         wireproto.encode('privmsg', 'arg1', 'arg2'),
         'PRIVMSG arg1 :arg2\r\n')
     self.assertEquals(
         wireproto.encode('privmsg', 'arg1', 'arg2 with spaces'),
         'PRIVMSG arg1 :arg2 with spaces\r\n')
     self.assertRaises(wireproto.EncodeArgumentError, wireproto.encode,
                       'privmsg', 'arg1 with spaces', 'arg2')
     self.assertEquals(
         wireproto.encode('PRIVMSG', 'arg1', u'arg2', u'arg3 with €'),
         'PRIVMSG arg1 arg2 :arg3 with \xe2\x82\xac\r\n')
コード例 #3
0
ファイル: server.py プロジェクト: Screwperman/pyirc
 def _handle_connect(self):
     self._conn.output(wireproto.encode('NICK', self.nick))
     self._conn.output(wireproto.encode(
         'USER', self.user, '0', '*', self.realname))