247 (re.compile(r":.*\s354\s[^ ]+\s42\s([^ ]+)\s(.*)"), self.__autoWhoEntry), |
249 (re.compile(r":.*\s354\s[^ ]+\s42\s([^ ]+)\s(.*)"), self.__autoWhoEntry), |
248 # :zelazny.freenode.net 366 foo_ #eric-ide :End of /NAMES list. |
250 # :zelazny.freenode.net 366 foo_ #eric-ide :End of /NAMES list. |
249 (re.compile(r":.*\s366\s.*\s([^ ]+)\s:(.*)"), self.__ignore), |
251 (re.compile(r":.*\s366\s.*\s([^ ]+)\s:(.*)"), self.__ignore), |
250 # :sturgeon.freenode.net 704 foo_ index :Help topics available to users: |
252 # :sturgeon.freenode.net 704 foo_ index :Help topics available to users: |
251 (re.compile(r":.*\s70[456]\s[^ ]+\s([^ ]+)\s:(.*)"), self.__help), |
253 (re.compile(r":.*\s70[456]\s[^ ]+\s([^ ]+)\s:(.*)"), self.__help), |
|
254 |
|
255 # WHOIS replies |
|
256 # :sturgeon.freenode.net 311 foo_ bar ~bar barhost.foo.net * :Bar User |
|
257 (re.compile(r":.*\s311\s[^ ]+\s([^ ]+)\s([^ ]+)\s([^ ]+)\s\*\s:(.*)"), |
|
258 self.__whoIsUser), |
|
259 # :sturgeon.freenode.net 319 foo_ bar :@#eric-ide |
|
260 (re.compile(r":.*\s319\s[^ ]+\s([^ ]+)\s:(.*)"), self.__whoIsChannels), |
|
261 # :sturgeon.freenode.net 312 foo_ bar sturgeon.freenode.net :London, UK |
|
262 (re.compile(r":.*\s312\s[^ ]+\s([^ ]+)\s([^ ]+)\s:(.*)"), self.__whoIsServer), |
|
263 # :sturgeon.freenode.net 671 foo_ bar :is using a secure connection |
|
264 (re.compile(r":.*\s671\s[^ ]+\s([^ ]+)\s:.*"), self.__whoIsSecure), |
|
265 # :sturgeon.freenode.net 317 foo_ bar 3758 1355046912 :seconds idle, signon time |
|
266 (re.compile(r":.*\s317\s[^ ]+\s([^ ]+)\s(\d+)\s(\d+)\s:.*"), |
|
267 self.__whoIsIdle), |
|
268 # :sturgeon.freenode.net 330 foo_ bar bar :is logged in as |
|
269 (re.compile(r":.*\s330\s[^ ]+\s([^ ]+)\s([^ ]+)\s:.*"), self.__whoIsAccount), |
|
270 # :sturgeon.freenode.net 318 foo_ bar :End of /WHOIS list. |
|
271 (re.compile(r":.*\s318\s[^ ]+\s([^ ]+)\s:(.*)"), self.__whoIsEnd), |
|
272 # :sturgeon.freenode.net 307 foo_ bar :is an identified user |
|
273 (re.compile(r":.*\s307\s[^ ]+\s([^ ]+)\s:(.*)"), self.__whoIsIdentify), |
|
274 # :sturgeon.freenode.net 320 foo_ bar :is an identified user |
|
275 (re.compile(r":.*\s320\s[^ ]+\s([^ ]+)\s:(.*)"), self.__whoIsIdentify), |
|
276 # :sturgeon.freenode.net 310 foo_ bar :is available for help |
|
277 (re.compile(r":.*\s310\s[^ ]+\s([^ ]+)\s:(.*)"), self.__whoIsHelper), |
|
278 # :sturgeon.freenode.net 338 foo_ bar real.ident@real.host 12.34.56.78 :Actual user@host, Actual IP |
|
279 (re.compile(r":.*\s338\s[^ ]+\s([^ ]+)\s([^ ]+)\s([^ ]+)\s:.*"), |
|
280 self.__whoIsActually), |
|
281 # :sturgeon.freenode.net 313 foo_ bar :is an IRC Operator |
|
282 (re.compile(r":.*\s313\s[^ ]+\s([^ ]+)\s:(.*)"), self.__whoIsOperator), |
|
283 # :sturgeon.freenode.net 378 foo_ bar :is connecting from *@mnch-4d044d5a.pool.mediaWays.net 77.4.77.90 |
|
284 (re.compile(r":.*\s311\s[^ ]+\s([^ ]+)\s:.*\s([^ ]+)\s([^ ]+)"), |
|
285 self.__whoIsConnection), |
252 ] |
286 ] |
|
287 # group(1) nick |
|
288 # group(2) host name |
|
289 # group(3) IP |
|
290 # group(4) real name |
|
291 # group(5) |
253 |
292 |
254 self.__autoWhoTemplate = "WHO {0} %tnf,42" |
293 self.__autoWhoTemplate = "WHO {0} %tnf,42" |
255 self.__autoWhoTimer = QTimer() |
294 self.__autoWhoTimer = QTimer() |
256 self.__autoWhoTimer.setSingleShot(True) |
295 self.__autoWhoTimer.setSingleShot(True) |
257 self.__autoWhoTimer.timeout.connect(self.__sendAutoWhoCommand) |
296 self.__autoWhoTimer.timeout.connect(self.__sendAutoWhoCommand) |
1243 self.trUtf8("{0} is {1}@{2} ({3}){4}").format( |
1282 self.trUtf8("{0} is {1}@{2} ({3}){4}").format( |
1244 match.group(4), match.group(2), match.group(3), match.group(6), away)) |
1283 match.group(4), match.group(2), match.group(3), match.group(6), away)) |
1245 return True |
1284 return True |
1246 |
1285 |
1247 return False |
1286 return False |
1248 |
1287 |
|
1288 def __whoIsUser(self, match): |
|
1289 """ |
|
1290 Private method to handle the WHOIS user reply. |
|
1291 |
|
1292 @param match match object that matched the pattern |
|
1293 @return flag indicating whether the message was handled (boolean) |
|
1294 """ |
|
1295 # group(1) nick |
|
1296 # group(2) user |
|
1297 # group(3) host |
|
1298 # group(4) real name |
|
1299 if match.group(1) == self.__whoIsNick: |
|
1300 realName = match.group(4).replace("<", "<").replace(">", ">") |
|
1301 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1302 self.trUtf8("{0} is {1}@{2} ({3}).").format(match.group(1), |
|
1303 match.group(2), match.group(3), realName)) |
|
1304 return True |
|
1305 |
|
1306 return False |
|
1307 |
|
1308 def __whoIsChannels(self, match): |
|
1309 """ |
|
1310 Private method to handle the WHOIS channels reply. |
|
1311 |
|
1312 @param match match object that matched the pattern |
|
1313 @return flag indicating whether the message was handled (boolean) |
|
1314 """ |
|
1315 # group(1) nick |
|
1316 # group(2) channels |
|
1317 if match.group(1) == self.__whoIsNick: |
|
1318 userChannels = [] |
|
1319 voiceChannels = [] |
|
1320 opChannels = [] |
|
1321 halfopChannels = [] |
|
1322 ownerChannels = [] |
|
1323 adminChannels = [] |
|
1324 |
|
1325 # generate the list of channels the user is in |
|
1326 channelList = match.group(2).split() |
|
1327 for channel in channelList: |
|
1328 if channel.startswith(("*", "&")): |
|
1329 adminChannels.append(channel[1:]) |
|
1330 elif channel.startswith(("!", "~")) and \ |
|
1331 self.__ircWidget.isChannelName(channel[1:]): |
|
1332 ownerChannels.append(channel[1:]) |
|
1333 elif channel.startswith("@+"): |
|
1334 opChannels.append(channel[2:]) |
|
1335 elif channel.startswith("@"): |
|
1336 opChannels.append(channel[1:]) |
|
1337 elif channel.startswith("%"): |
|
1338 halfopChannels.append(channel[1:]) |
|
1339 elif channel.startswith("+"): |
|
1340 voiceChannels.append(channel[1:]) |
|
1341 else: |
|
1342 userChannels.append(channel) |
|
1343 |
|
1344 # show messages |
|
1345 if userChannels: |
|
1346 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1347 self.trUtf8("{0} is a user on channels: {1}").format( |
|
1348 match.group(1), " ".join(userChannels))) |
|
1349 if voiceChannels: |
|
1350 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1351 self.trUtf8("{0} has voice on channels: {1}").format( |
|
1352 match.group(1), " ".join(voiceChannels))) |
|
1353 if halfopChannels: |
|
1354 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1355 self.trUtf8("{0} is a halfop on channels: {1}").format( |
|
1356 match.group(1), " ".join(halfopChannels))) |
|
1357 if opChannels: |
|
1358 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1359 self.trUtf8("{0} is an operator on channels: {1}").format( |
|
1360 match.group(1), " ".join(opChannels))) |
|
1361 if ownerChannels: |
|
1362 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1363 self.trUtf8("{0} is owner of channels: {1}").format( |
|
1364 match.group(1), " ".join(ownerChannels))) |
|
1365 if adminChannels: |
|
1366 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1367 self.trUtf8("{0} is admin on channels: {1}").format( |
|
1368 match.group(1), " ".join(adminChannels))) |
|
1369 return True |
|
1370 |
|
1371 return False |
|
1372 |
|
1373 def __whoIsServer(self, match): |
|
1374 """ |
|
1375 Private method to handle the WHOIS server reply. |
|
1376 |
|
1377 @param match match object that matched the pattern |
|
1378 @return flag indicating whether the message was handled (boolean) |
|
1379 """ |
|
1380 # group(1) nick |
|
1381 # group(2) server |
|
1382 # group(3) server info |
|
1383 if match.group(1) == self.__whoIsNick: |
|
1384 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1385 self.trUtf8("{0} is online via {1} ({2}).").format(match.group(1), |
|
1386 match.group(2), match.group(3))) |
|
1387 return True |
|
1388 |
|
1389 return False |
|
1390 |
|
1391 def __whoIsOperator(self, match): |
|
1392 """ |
|
1393 Private method to handle the WHOIS operator reply. |
|
1394 |
|
1395 @param match match object that matched the pattern |
|
1396 @return flag indicating whether the message was handled (boolean) |
|
1397 """ |
|
1398 # group(1) nick |
|
1399 # group(2) message |
|
1400 if match.group(1) == self.__whoIsNick: |
|
1401 if match.group(2).lower().startswith("is an irc operator"): |
|
1402 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1403 self.trUtf8("{0} is an IRC Operator.").format(match.group(1))) |
|
1404 else: |
|
1405 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1406 "{0} {1}".format(match.group(1), match.group(2))) |
|
1407 return True |
|
1408 |
|
1409 return False |
|
1410 |
|
1411 def __whoIsIdle(self, match): |
|
1412 """ |
|
1413 Private method to handle the WHOIS idle reply. |
|
1414 |
|
1415 @param match match object that matched the pattern |
|
1416 @return flag indicating whether the message was handled (boolean) |
|
1417 """ |
|
1418 # group(1) nick |
|
1419 # group(2) idle seconds |
|
1420 # group(3) signon time |
|
1421 if match.group(1) == self.__whoIsNick: |
|
1422 seconds = int(match.group(2)) |
|
1423 minutes = seconds // 60 |
|
1424 hours = minutes // 60 |
|
1425 days = hours // 24 |
|
1426 |
|
1427 signonTimestamp = int(match.group(3)) |
|
1428 signonTime = QDateTime() |
|
1429 signonTime.setTime_t(signonTimestamp) |
|
1430 |
|
1431 if days: |
|
1432 daysString = self.trUtf8("%n day(s)", "", days) |
|
1433 hoursString = self.trUtf8("%n hour(s)", "", hours) |
|
1434 minutesString = self.trUtf8("%n minute(s)", "", minutes) |
|
1435 secondsString = self.trUtf8("%n second(s)", "", seconds) |
|
1436 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1437 self.trUtf8("{0} has been idle for {1}, {2}, {3}, and {4}.", |
|
1438 "{0} = name of person, {1} = (x days), {2} = (x hours)," |
|
1439 " {3} = (x minutes), {4} = (x seconds)").format( |
|
1440 match.group(1), daysString, hoursString, minutesString, |
|
1441 secondsString)) |
|
1442 elif hours: |
|
1443 hoursString = self.trUtf8("%n hour(s)", "", hours) |
|
1444 minutesString = self.trUtf8("%n minute(s)", "", minutes) |
|
1445 secondsString = self.trUtf8("%n second(s)", "", seconds) |
|
1446 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1447 self.trUtf8("{0} has been idle for {1}, {2}, and {3}.", |
|
1448 "{0} = name of person, {1} = (x hours), " |
|
1449 "{2} = (x minutes), {3} = (x seconds)").format( |
|
1450 match.group(1), hoursString, minutesString, secondsString)) |
|
1451 elif minutes: |
|
1452 minutesString = self.trUtf8("%n minute(s)", "", minutes) |
|
1453 secondsString = self.trUtf8("%n second(s)", "", seconds) |
|
1454 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1455 self.trUtf8("{0} has been idle for {1} and {2}.", |
|
1456 "{0} = name of person, {1} = (x minutes), " |
|
1457 "{3} = (x seconds)").format( |
|
1458 match.group(1), minutesString, secondsString)) |
|
1459 else: |
|
1460 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1461 self.trUtf8("{0} has been idle for %n second(s).", "", |
|
1462 seconds).format(match.group(1))) |
|
1463 |
|
1464 if not signonTime.isNull(): |
|
1465 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1466 self.trUtf8("{0} has been online since {1}.").format( |
|
1467 match.group(1), signonTime.toString("yyyy-MM-dd, hh:mm:ss"))) |
|
1468 return True |
|
1469 |
|
1470 return False |
|
1471 |
|
1472 def __whoIsEnd(self, match): |
|
1473 """ |
|
1474 Private method to handle the end of WHOIS reply. |
|
1475 |
|
1476 @param match match object that matched the pattern |
|
1477 @return flag indicating whether the message was handled (boolean) |
|
1478 """ |
|
1479 # group(1) nick |
|
1480 # group(2) end message |
|
1481 if match.group(1) == self.__whoIsNick: |
|
1482 self.__whoIsNick = "" |
|
1483 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1484 self.trUtf8("End of WHOIS list for {0}.").format(match.group(1))) |
|
1485 return True |
|
1486 |
|
1487 return False |
|
1488 |
|
1489 def __whoIsIdentify(self, match): |
|
1490 """ |
|
1491 Private method to handle the WHOIS identify and identified replies. |
|
1492 |
|
1493 @param match match object that matched the pattern |
|
1494 @return flag indicating whether the message was handled (boolean) |
|
1495 """ |
|
1496 # group(1) nick |
|
1497 # group(2) identified message |
|
1498 if match.group(1) == self.__whoIsNick: |
|
1499 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1500 self.trUtf8("{0} is an identified user.").format(match.group(1))) |
|
1501 return True |
|
1502 |
|
1503 return False |
|
1504 |
|
1505 def __whoIsHelper(self, match): |
|
1506 """ |
|
1507 Private method to handle the WHOIS helper reply. |
|
1508 |
|
1509 @param match match object that matched the pattern |
|
1510 @return flag indicating whether the message was handled (boolean) |
|
1511 """ |
|
1512 # group(1) nick |
|
1513 # group(2) helper message |
|
1514 if match.group(1) == self.__whoIsNick: |
|
1515 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1516 self.trUtf8("{0} is available for help.").format(match.group(1))) |
|
1517 return True |
|
1518 |
|
1519 return False |
|
1520 |
|
1521 def __whoIsAccount(self, match): |
|
1522 """ |
|
1523 Private method to handle the WHOIS account reply. |
|
1524 |
|
1525 @param match match object that matched the pattern |
|
1526 @return flag indicating whether the message was handled (boolean) |
|
1527 """ |
|
1528 # group(1) nick |
|
1529 # group(2) login name |
|
1530 if match.group(1) == self.__whoIsNick: |
|
1531 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1532 self.trUtf8("{0} is logged in as {1}.").format(match.group(1), |
|
1533 match.group(2))) |
|
1534 return True |
|
1535 |
|
1536 return False |
|
1537 |
|
1538 def __whoIsActually(self, match): |
|
1539 """ |
|
1540 Private method to handle the WHOIS actually reply. |
|
1541 |
|
1542 @param match match object that matched the pattern |
|
1543 @return flag indicating whether the message was handled (boolean) |
|
1544 """ |
|
1545 # group(1) nick |
|
1546 # group(2) actual user@host |
|
1547 # group(3) actual IP |
|
1548 if match.group(1) == self.__whoIsNick: |
|
1549 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1550 self.trUtf8("{0} is actually using the host {1} (IP: {2}).").format( |
|
1551 match.group(1), match.group(2), match.group(3))) |
|
1552 return True |
|
1553 |
|
1554 return False |
|
1555 |
|
1556 def __whoIsSecure(self, match): |
|
1557 """ |
|
1558 Private method to handle the WHOIS secure reply. |
|
1559 |
|
1560 @param match match object that matched the pattern |
|
1561 @return flag indicating whether the message was handled (boolean) |
|
1562 """ |
|
1563 # group(1) nick |
|
1564 if match.group(1) == self.__whoIsNick: |
|
1565 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1566 self.trUtf8("{0} is using a secure connection.").format(match.group(1))) |
|
1567 return True |
|
1568 |
|
1569 return False |
|
1570 |
|
1571 def __whoIsConnection(self, match): |
|
1572 """ |
|
1573 Private method to handle the WHOIS connection reply. |
|
1574 |
|
1575 @param match match object that matched the pattern |
|
1576 @return flag indicating whether the message was handled (boolean) |
|
1577 """ |
|
1578 # group(1) nick |
|
1579 # group(2) host name |
|
1580 # group(3) IP |
|
1581 if match.group(1) == self.__whoIsNick: |
|
1582 self.__addManagementMessage(self.trUtf8("Whois"), |
|
1583 self.trUtf8("{0} is connecting from {1} (IP: {2}).").format( |
|
1584 match.group(1), match.group(2), match.group(3))) |
|
1585 return True |
|
1586 |
|
1587 return False |