Пример #1
0
 def handle(self, origin, args):
     # Parse mode string if exists, and any option arguments
     if origin[1] == None:
         modes = []
         if args[5][0] == "+":
             nextarg = 6
             for mode in args[5][1:]:
                 if mode == "r" or mode == "h":
                     modes.append(('+' + mode, args[nextarg]))
                     nextarg = nextarg + 1
                 else:
                     modes.append(('+' + mode, None))
         self._state.new_user(
             origin,
             parse_numeric(args[-2], self._state.max_client_numerics),
             args[0],
             args[3],
             args[4],
             modes,
             to_int(args[-3]),
             args[1],
             args[2],
             args[-1]
         )
     else:
         self._state.change_nick(origin, origin, args[0], args[1])
Пример #2
0
 def handle(self, origin, args):
     numeric = to_int(args[5][0:2])
     name = args[0]
     maxclients = to_int(args[5][2:5])
     boot_ts = int(args[2])
     link_ts = int(args[3])
     protocol = args[4]
     hops = int(args[1])
     modes = []
     flag = "+"
     for mode in args[6]:
         if mode == "+" or mode == "-":
             flag = mode
         else:
             modes.append((flag + mode, None))
     desc = args[-1]
     self._state.new_server(origin, numeric, name, maxclients, boot_ts,
                            link_ts, protocol, hops, modes, desc)
     if self._connection != None:
         self._connection.register_numeric(numeric)
Пример #3
0
 def handle(self, origin, line):
     if line[0] == "*":
         target = None
     else:
         target = to_int(line[0])
     # We don't care if it's forced or not
     if line[1][0] == "!":
         line[1] = line[1][1:]
     mask = line[1][1:]
     mode = line[1][0]
     if len(line) == 4:
         ts = self._state.ts
     else:
         ts = int(line[3])
     
     if mode == "+":
         duration = int(line[2])
         description = line[-1]
         self._state.add_gline(
             origin, mask, target, duration + self._state.ts, ts,
             description
         )
     else:
         self._state.remove_gline(origin, mask, target, ts)
Пример #4
0
 def testSingleCharParse(self):
     self.assertEqual(0, to_int('A'))
     self.assertEqual(26, to_int('a'))
     self.assertEqual(63, to_int(']'))
Пример #5
0
 def testMultipleCharParse(self):
     self.assertEqual(0, to_int('AA'))
     self.assertEqual(64, to_int('BA'))
     self.assertEqual(90, to_int('Ba'))
     self.assertEqual(127, to_int('B]'))