Network/IRC/IrcChannelWidget.py

changeset 3022
57179e4cdadd
parent 3020
542e97d4ecb3
child 3034
7ce719013078
child 3058
0a02c433f52d
equal deleted inserted replaced
3021:801289962f4e 3022:57179e4cdadd
188 sendData = pyqtSignal(str) 188 sendData = pyqtSignal(str)
189 sendCtcpReply = pyqtSignal(str, str) 189 sendCtcpReply = pyqtSignal(str, str)
190 channelClosed = pyqtSignal(str) 190 channelClosed = pyqtSignal(str)
191 openPrivateChat = pyqtSignal(str) 191 openPrivateChat = pyqtSignal(str)
192 192
193 UrlRe = re.compile(r"""((?:http|ftp|https):\/\/[\w\-_]+(?:\.[\w\-_]+)+""" 193 UrlRe = re.compile(
194 r"""((?:http|ftp|https):\/\/[\w\-_]+(?:\.[\w\-_]+)+"""
194 r"""(?:[\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)""") 195 r"""(?:[\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)""")
195 196
196 JoinIndicator = "-->" 197 JoinIndicator = "-->"
197 LeaveIndicator = "<--" 198 LeaveIndicator = "<--"
198 MessageIndicator = "***" 199 MessageIndicator = "***"
643 """ 644 """
644 itm = self.__findUser(match.group(1)) 645 itm = self.__findUser(match.group(1))
645 if itm: 646 if itm:
646 itm.setName(match.group(2)) 647 itm.setName(match.group(2))
647 if match.group(1) == self.__userName: 648 if match.group(1) == self.__userName:
648 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 649 self.__addManagementMessage(
650 IrcChannelWidget.MessageIndicator,
649 self.trUtf8("You are now known as {0}.").format( 651 self.trUtf8("You are now known as {0}.").format(
650 match.group(2))) 652 match.group(2)))
651 self.__userName = match.group(2) 653 self.__userName = match.group(2)
652 else: 654 else:
653 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 655 self.__addManagementMessage(
656 IrcChannelWidget.MessageIndicator,
654 self.trUtf8("User {0} is now known as {1}.").format( 657 self.trUtf8("User {0} is now known as {1}.").format(
655 match.group(1), match.group(2))) 658 match.group(1), match.group(2)))
656 659
657 # always return False for other channels and server to process 660 # always return False for other channels and server to process
658 return False 661 return False
685 688
686 @param match match object that matched the pattern 689 @param match match object that matched the pattern
687 @return flag indicating whether the message was handled (boolean) 690 @return flag indicating whether the message was handled (boolean)
688 """ 691 """
689 if match.group(1).lower() == self.__name.lower(): 692 if match.group(1).lower() == self.__name.lower():
690 self.__addManagementMessage(self.trUtf8("Away"), 693 self.__addManagementMessage(
694 self.trUtf8("Away"),
691 self.trUtf8("{0} is away: {1}").format( 695 self.trUtf8("{0} is away: {1}").format(
692 match.group(2), match.group(3))) 696 match.group(2), match.group(3)))
693 return True 697 return True
694 698
695 return False 699 return False
701 @param match match object that matched the pattern 705 @param match match object that matched the pattern
702 @return flag indicating whether the message was handled (boolean) 706 @return flag indicating whether the message was handled (boolean)
703 """ 707 """
704 if match.group(1).lower() == self.__name.lower(): 708 if match.group(1).lower() == self.__name.lower():
705 self.topicLabel.setText(match.group(2)) 709 self.topicLabel.setText(match.group(2))
706 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 710 self.__addManagementMessage(
711 IrcChannelWidget.MessageIndicator,
707 ircFilter(self.trUtf8('The channel topic is: "{0}".').format( 712 ircFilter(self.trUtf8('The channel topic is: "{0}".').format(
708 match.group(2)))) 713 match.group(2))))
709 return True 714 return True
710 715
711 return False 716 return False
716 721
717 @param match match object that matched the pattern 722 @param match match object that matched the pattern
718 @return flag indicating whether the message was handled (boolean) 723 @return flag indicating whether the message was handled (boolean)
719 """ 724 """
720 if match.group(1).lower() == self.__name.lower(): 725 if match.group(1).lower() == self.__name.lower():
721 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 726 self.__addManagementMessage(
727 IrcChannelWidget.MessageIndicator,
722 self.trUtf8("The topic was set by {0} on {1}.").format( 728 self.trUtf8("The topic was set by {0} on {1}.").format(
723 match.group(2), QDateTime.fromTime_t(int(match.group(3)))\ 729 match.group(2), QDateTime.fromTime_t(int(match.group(3)))\
724 .toString("yyyy-MM-dd hh:mm"))) 730 .toString("yyyy-MM-dd hh:mm")))
725 return True 731 return True
726 732
732 738
733 @param match match object that matched the pattern 739 @param match match object that matched the pattern
734 @return flag indicating whether the message was handled (boolean) 740 @return flag indicating whether the message was handled (boolean)
735 """ 741 """
736 if match.group(1).lower() == self.__name.lower(): 742 if match.group(1).lower() == self.__name.lower():
737 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 743 self.__addManagementMessage(
744 IrcChannelWidget.MessageIndicator,
738 ircFilter(self.trUtf8("Channel URL: {0}").format( 745 ircFilter(self.trUtf8("Channel URL: {0}").format(
739 match.group(2)))) 746 match.group(2))))
740 return True 747 return True
741 748
742 return False 749 return False
767 elif modeChar in modesDict: 774 elif modeChar in modesDict:
768 modes.append(modesDict[modeChar]) 775 modes.append(modesDict[modeChar])
769 else: 776 else:
770 modes.append(modeChar) 777 modes.append(modeChar)
771 778
772 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 779 self.__addManagementMessage(
780 IrcChannelWidget.MessageIndicator,
773 self.trUtf8("Channel modes: {0}.").format(", ".join(modes))) 781 self.trUtf8("Channel modes: {0}.").format(", ".join(modes)))
774 782
775 return True 783 return True
776 784
777 return False 785 return False
782 790
783 @param match match object that matched the pattern 791 @param match match object that matched the pattern
784 @return flag indicating whether the message was handled (boolean) 792 @return flag indicating whether the message was handled (boolean)
785 """ 793 """
786 if match.group(1).lower() == self.__name.lower(): 794 if match.group(1).lower() == self.__name.lower():
787 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 795 self.__addManagementMessage(
796 IrcChannelWidget.MessageIndicator,
788 self.trUtf8("This channel was created on {0}.").format( 797 self.trUtf8("This channel was created on {0}.").format(
789 QDateTime.fromTime_t(int(match.group(2)))\ 798 QDateTime.fromTime_t(int(match.group(2)))\
790 .toString("yyyy-MM-dd hh:mm"))) 799 .toString("yyyy-MM-dd hh:mm")))
791 return True 800 return True
792 801
957 if match.group(2).lower() == self.__name.lower(): 966 if match.group(2).lower() == self.__name.lower():
958 itm = self.__findUser(match.group(4)) 967 itm = self.__findUser(match.group(4))
959 if itm: 968 if itm:
960 itm.changePrivilege(match.group(3)) 969 itm.changePrivilege(match.group(3))
961 self.__setEditTopicButton() 970 self.__setEditTopicButton()
962 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 971 self.__addManagementMessage(
972 IrcChannelWidget.MessageIndicator,
963 self.trUtf8("{0} sets mode for {1}: {2}.").format( 973 self.trUtf8("{0} sets mode for {1}: {2}.").format(
964 match.group(1), match.group(4), match.group(3))) 974 match.group(1), match.group(4), match.group(3)))
965 return True 975 return True
966 976
967 return False 977 return False
983 Private method to handle a help message. 993 Private method to handle a help message.
984 994
985 @param match match object that matched the pattern 995 @param match match object that matched the pattern
986 @return flag indicating whether the message was handled (boolean) 996 @return flag indicating whether the message was handled (boolean)
987 """ 997 """
988 self.__addManagementMessage(self.trUtf8("Help"), 998 self.__addManagementMessage(
999 self.trUtf8("Help"),
989 "{0} {1}".format(match.group(1), ircFilter(match.group(2)))) 1000 "{0} {1}".format(match.group(1), ircFilter(match.group(2))))
990 return True 1001 return True
991 1002
992 def __handleCtcp(self, match): 1003 def __handleCtcp(self, match):
993 """ 1004 """
1007 else: 1018 else:
1008 ctcpRequest, ctcpArg = ctcpCommand, "" 1019 ctcpRequest, ctcpArg = ctcpCommand, ""
1009 ctcpRequest = ctcpRequest.lower() 1020 ctcpRequest = ctcpRequest.lower()
1010 if ctcpRequest == "version": 1021 if ctcpRequest == "version":
1011 msg = "Eric IRC client {0}, {1}".format(Version, Copyright) 1022 msg = "Eric IRC client {0}, {1}".format(Version, Copyright)
1012 self.__addManagementMessage(self.trUtf8("CTCP"), 1023 self.__addManagementMessage(
1024 self.trUtf8("CTCP"),
1013 self.trUtf8("Received Version request from {0}.").format( 1025 self.trUtf8("Received Version request from {0}.").format(
1014 match.group(1))) 1026 match.group(1)))
1015 self.sendCtcpReply.emit(match.group(1), "VERSION " + msg) 1027 self.sendCtcpReply.emit(match.group(1), "VERSION " + msg)
1016 elif ctcpRequest == "ping": 1028 elif ctcpRequest == "ping":
1017 self.__addManagementMessage(self.trUtf8("CTCP"), 1029 self.__addManagementMessage(
1018 self.trUtf8("Received CTCP-PING request from {0}," 1030 self.trUtf8("CTCP"),
1019 " sending answer.").format(match.group(1))) 1031 self.trUtf8(
1032 "Received CTCP-PING request from {0},"
1033 " sending answer.").format(match.group(1)))
1020 self.sendCtcpReply.emit( 1034 self.sendCtcpReply.emit(
1021 match.group(1), "PING {0}".format(ctcpArg)) 1035 match.group(1), "PING {0}".format(ctcpArg))
1022 elif ctcpRequest == "clientinfo": 1036 elif ctcpRequest == "clientinfo":
1023 self.__addManagementMessage(self.trUtf8("CTCP"), 1037 self.__addManagementMessage(
1024 self.trUtf8("Received CTCP-CLIENTINFO request from {0}," 1038 self.trUtf8("CTCP"),
1039 self.trUtf8(
1040 "Received CTCP-CLIENTINFO request from {0},"
1025 " sending answer.").format(match.group(1))) 1041 " sending answer.").format(match.group(1)))
1026 self.sendCtcpReply.emit(match.group(1), 1042 self.sendCtcpReply.emit(
1027 "CLIENTINFO CLIENTINFO PING VERSION") 1043 match.group(1), "CLIENTINFO CLIENTINFO PING VERSION")
1028 else: 1044 else:
1029 self.__addManagementMessage(self.trUtf8("CTCP"), 1045 self.__addManagementMessage(
1046 self.trUtf8("CTCP"),
1030 self.trUtf8("Received unknown CTCP-{0} request from {1}.") 1047 self.trUtf8("Received unknown CTCP-{0} request from {1}.")
1031 .format(ctcpRequest, match.group(1))) 1048 .format(ctcpRequest, match.group(1)))
1032 return True 1049 return True
1033 1050
1034 return False 1051 return False
1247 self.__saveMessagesAct = \ 1264 self.__saveMessagesAct = \
1248 self.__messagesMenu.addAction( 1265 self.__messagesMenu.addAction(
1249 UI.PixmapCache.getIcon("fileSave.png"), 1266 UI.PixmapCache.getIcon("fileSave.png"),
1250 self.trUtf8("Save"), self.__saveMessages) 1267 self.trUtf8("Save"), self.__saveMessages)
1251 self.__messagesMenu.addSeparator() 1268 self.__messagesMenu.addSeparator()
1252 self.__setMarkerMessagesAct = \ 1269 self.__setMarkerMessagesAct = self.__messagesMenu.addAction(
1253 self.__messagesMenu.addAction(self.trUtf8("Mark Current Position"), 1270 self.trUtf8("Mark Current Position"), self.setMarkerLine)
1254 self.setMarkerLine) 1271 self.__unsetMarkerMessagesAct = self.__messagesMenu.addAction(
1255 self.__unsetMarkerMessagesAct = \ 1272 self.trUtf8("Remove Position Marker"),
1256 self.__messagesMenu.addAction( 1273 self.unsetMarkerLine)
1257 self.trUtf8("Remove Position Marker"),
1258 self.unsetMarkerLine)
1259 1274
1260 self.on_messages_copyAvailable(False) 1275 self.on_messages_copyAvailable(False)
1261 1276
1262 @pyqtSlot(bool) 1277 @pyqtSlot(bool)
1263 def on_messages_copyAvailable(self, yes): 1278 def on_messages_copyAvailable(self, yes):
1301 def __initUsersMenu(self): 1316 def __initUsersMenu(self):
1302 """ 1317 """
1303 Private slot to initialize the users list context menu. 1318 Private slot to initialize the users list context menu.
1304 """ 1319 """
1305 self.__usersMenu = QMenu(self) 1320 self.__usersMenu = QMenu(self)
1306 self.__whoIsAct = \ 1321 self.__whoIsAct = self.__usersMenu.addAction(
1307 self.__usersMenu.addAction(self.trUtf8("Who Is"), 1322 self.trUtf8("Who Is"), self.__whoIs)
1308 self.__whoIs)
1309 self.__usersMenu.addSeparator() 1323 self.__usersMenu.addSeparator()
1310 self.__privateChatAct = \ 1324 self.__privateChatAct = self.__usersMenu.addAction(
1311 self.__usersMenu.addAction(self.trUtf8("Private Chat"), 1325 self.trUtf8("Private Chat"), self.__openPrivateChat)
1312 self.__openPrivateChat)
1313 self.__usersMenu.addSeparator() 1326 self.__usersMenu.addSeparator()
1314 self.__usersListRefreshAct = \ 1327 self.__usersListRefreshAct = self.__usersMenu.addAction(
1315 self.__usersMenu.addAction(self.trUtf8("Refresh"), 1328 self.trUtf8("Refresh"), self.__sendAutoWhoCommand)
1316 self.__sendAutoWhoCommand)
1317 1329
1318 @pyqtSlot(QPoint) 1330 @pyqtSlot(QPoint)
1319 def on_usersList_customContextMenuRequested(self, pos): 1331 def on_usersList_customContextMenuRequested(self, pos):
1320 """ 1332 """
1321 Private slot to show the context menu of the users list. 1333 Private slot to show the context menu of the users list.
1396 if match.group(1).lower() == self.__name.lower(): 1408 if match.group(1).lower() == self.__name.lower():
1397 if self.__autoWhoRequested: 1409 if self.__autoWhoRequested:
1398 self.__autoWhoRequested = False 1410 self.__autoWhoRequested = False
1399 self.initAutoWho() 1411 self.initAutoWho()
1400 else: 1412 else:
1401 self.__addManagementMessage(self.trUtf8("Who"), 1413 self.__addManagementMessage(
1414 self.trUtf8("Who"),
1402 self.trUtf8("End of WHO list for {0}.").format( 1415 self.trUtf8("End of WHO list for {0}.").format(
1403 match.group(1))) 1416 match.group(1)))
1404 return True 1417 return True
1405 1418
1406 return False 1419 return False
1420 # group(5) user flags 1433 # group(5) user flags
1421 # group(6) real name 1434 # group(6) real name
1422 if match.group(1).lower() == self.__name.lower(): 1435 if match.group(1).lower() == self.__name.lower():
1423 away = self.trUtf8(" (Away)") if match.group(5).startswith("G") \ 1436 away = self.trUtf8(" (Away)") if match.group(5).startswith("G") \
1424 else "" 1437 else ""
1425 self.__addManagementMessage(self.trUtf8("Who"), 1438 self.__addManagementMessage(
1439 self.trUtf8("Who"),
1426 self.trUtf8("{0} is {1}@{2} ({3}){4}").format( 1440 self.trUtf8("{0} is {1}@{2} ({3}){4}").format(
1427 match.group(4), match.group(2), match.group(3), 1441 match.group(4), match.group(2), match.group(3),
1428 match.group(6), away)) 1442 match.group(6), away))
1429 return True 1443 return True
1430 1444
1441 # group(2) user 1455 # group(2) user
1442 # group(3) host 1456 # group(3) host
1443 # group(4) real name 1457 # group(4) real name
1444 if match.group(1) == self.__whoIsNick: 1458 if match.group(1) == self.__whoIsNick:
1445 realName = match.group(4).replace("<", "&lt;").replace(">", "&gt;") 1459 realName = match.group(4).replace("<", "&lt;").replace(">", "&gt;")
1446 self.__addManagementMessage(self.trUtf8("Whois"), 1460 self.__addManagementMessage(
1447 self.trUtf8("{0} is {1}@{2} ({3}).").format(match.group(1), 1461 self.trUtf8("Whois"),
1448 match.group(2), match.group(3), realName)) 1462 self.trUtf8("{0} is {1}@{2} ({3}).").format(
1463 match.group(1), match.group(2), match.group(3), realName))
1449 return True 1464 return True
1450 1465
1451 return False 1466 return False
1452 1467
1453 def __whoIsChannels(self, match): 1468 def __whoIsChannels(self, match):
1486 else: 1501 else:
1487 userChannels.append(channel) 1502 userChannels.append(channel)
1488 1503
1489 # show messages 1504 # show messages
1490 if userChannels: 1505 if userChannels:
1491 self.__addManagementMessage(self.trUtf8("Whois"), 1506 self.__addManagementMessage(
1507 self.trUtf8("Whois"),
1492 self.trUtf8("{0} is a user on channels: {1}").format( 1508 self.trUtf8("{0} is a user on channels: {1}").format(
1493 match.group(1), " ".join(userChannels))) 1509 match.group(1), " ".join(userChannels)))
1494 if voiceChannels: 1510 if voiceChannels:
1495 self.__addManagementMessage(self.trUtf8("Whois"), 1511 self.__addManagementMessage(
1512 self.trUtf8("Whois"),
1496 self.trUtf8("{0} has voice on channels: {1}").format( 1513 self.trUtf8("{0} has voice on channels: {1}").format(
1497 match.group(1), " ".join(voiceChannels))) 1514 match.group(1), " ".join(voiceChannels)))
1498 if halfopChannels: 1515 if halfopChannels:
1499 self.__addManagementMessage(self.trUtf8("Whois"), 1516 self.__addManagementMessage(
1517 self.trUtf8("Whois"),
1500 self.trUtf8("{0} is a halfop on channels: {1}").format( 1518 self.trUtf8("{0} is a halfop on channels: {1}").format(
1501 match.group(1), " ".join(halfopChannels))) 1519 match.group(1), " ".join(halfopChannels)))
1502 if opChannels: 1520 if opChannels:
1503 self.__addManagementMessage(self.trUtf8("Whois"), 1521 self.__addManagementMessage(
1522 self.trUtf8("Whois"),
1504 self.trUtf8("{0} is an operator on channels: {1}").format( 1523 self.trUtf8("{0} is an operator on channels: {1}").format(
1505 match.group(1), " ".join(opChannels))) 1524 match.group(1), " ".join(opChannels)))
1506 if ownerChannels: 1525 if ownerChannels:
1507 self.__addManagementMessage(self.trUtf8("Whois"), 1526 self.__addManagementMessage(
1527 self.trUtf8("Whois"),
1508 self.trUtf8("{0} is owner of channels: {1}").format( 1528 self.trUtf8("{0} is owner of channels: {1}").format(
1509 match.group(1), " ".join(ownerChannels))) 1529 match.group(1), " ".join(ownerChannels)))
1510 if adminChannels: 1530 if adminChannels:
1511 self.__addManagementMessage(self.trUtf8("Whois"), 1531 self.__addManagementMessage(
1532 self.trUtf8("Whois"),
1512 self.trUtf8("{0} is admin on channels: {1}").format( 1533 self.trUtf8("{0} is admin on channels: {1}").format(
1513 match.group(1), " ".join(adminChannels))) 1534 match.group(1), " ".join(adminChannels)))
1514 return True 1535 return True
1515 1536
1516 return False 1537 return False
1524 """ 1545 """
1525 # group(1) nick 1546 # group(1) nick
1526 # group(2) server 1547 # group(2) server
1527 # group(3) server info 1548 # group(3) server info
1528 if match.group(1) == self.__whoIsNick: 1549 if match.group(1) == self.__whoIsNick:
1529 self.__addManagementMessage(self.trUtf8("Whois"), 1550 self.__addManagementMessage(
1551 self.trUtf8("Whois"),
1530 self.trUtf8("{0} is online via {1} ({2}).").format( 1552 self.trUtf8("{0} is online via {1} ({2}).").format(
1531 match.group(1), match.group(2), match.group(3))) 1553 match.group(1), match.group(2), match.group(3)))
1532 return True 1554 return True
1533 1555
1534 return False 1556 return False
1542 """ 1564 """
1543 # group(1) nick 1565 # group(1) nick
1544 # group(2) message 1566 # group(2) message
1545 if match.group(1) == self.__whoIsNick: 1567 if match.group(1) == self.__whoIsNick:
1546 if match.group(2).lower().startswith("is an irc operator"): 1568 if match.group(2).lower().startswith("is an irc operator"):
1547 self.__addManagementMessage(self.trUtf8("Whois"), 1569 self.__addManagementMessage(
1570 self.trUtf8("Whois"),
1548 self.trUtf8("{0} is an IRC Operator.").format( 1571 self.trUtf8("{0} is an IRC Operator.").format(
1549 match.group(1))) 1572 match.group(1)))
1550 else: 1573 else:
1551 self.__addManagementMessage(self.trUtf8("Whois"), 1574 self.__addManagementMessage(
1575 self.trUtf8("Whois"),
1552 "{0} {1}".format(match.group(1), match.group(2))) 1576 "{0} {1}".format(match.group(1), match.group(2)))
1553 return True 1577 return True
1554 1578
1555 return False 1579 return False
1556 1580
1577 if days: 1601 if days:
1578 daysString = self.trUtf8("%n day(s)", "", days) 1602 daysString = self.trUtf8("%n day(s)", "", days)
1579 hoursString = self.trUtf8("%n hour(s)", "", hours) 1603 hoursString = self.trUtf8("%n hour(s)", "", hours)
1580 minutesString = self.trUtf8("%n minute(s)", "", minutes) 1604 minutesString = self.trUtf8("%n minute(s)", "", minutes)
1581 secondsString = self.trUtf8("%n second(s)", "", seconds) 1605 secondsString = self.trUtf8("%n second(s)", "", seconds)
1582 self.__addManagementMessage(self.trUtf8("Whois"), 1606 self.__addManagementMessage(
1607 self.trUtf8("Whois"),
1583 self.trUtf8( 1608 self.trUtf8(
1584 "{0} has been idle for {1}, {2}, {3}, and {4}.", 1609 "{0} has been idle for {1}, {2}, {3}, and {4}.",
1585 "{0} = name of person, {1} = (x days)," 1610 "{0} = name of person, {1} = (x days),"
1586 " {2} = (x hours), {3} = (x minutes)," 1611 " {2} = (x hours), {3} = (x minutes),"
1587 " {4} = (x seconds)").format( 1612 " {4} = (x seconds)").format(
1589 secondsString)) 1614 secondsString))
1590 elif hours: 1615 elif hours:
1591 hoursString = self.trUtf8("%n hour(s)", "", hours) 1616 hoursString = self.trUtf8("%n hour(s)", "", hours)
1592 minutesString = self.trUtf8("%n minute(s)", "", minutes) 1617 minutesString = self.trUtf8("%n minute(s)", "", minutes)
1593 secondsString = self.trUtf8("%n second(s)", "", seconds) 1618 secondsString = self.trUtf8("%n second(s)", "", seconds)
1594 self.__addManagementMessage(self.trUtf8("Whois"), 1619 self.__addManagementMessage(
1620 self.trUtf8("Whois"),
1595 self.trUtf8("{0} has been idle for {1}, {2}, and {3}.", 1621 self.trUtf8("{0} has been idle for {1}, {2}, and {3}.",
1596 "{0} = name of person, {1} = (x hours), " 1622 "{0} = name of person, {1} = (x hours), "
1597 "{2} = (x minutes), {3} = (x seconds)").format( 1623 "{2} = (x minutes), {3} = (x seconds)").format(
1598 match.group(1), hoursString, minutesString, secondsString)) 1624 match.group(1), hoursString, minutesString, secondsString))
1599 elif minutes: 1625 elif minutes:
1600 minutesString = self.trUtf8("%n minute(s)", "", minutes) 1626 minutesString = self.trUtf8("%n minute(s)", "", minutes)
1601 secondsString = self.trUtf8("%n second(s)", "", seconds) 1627 secondsString = self.trUtf8("%n second(s)", "", seconds)
1602 self.__addManagementMessage(self.trUtf8("Whois"), 1628 self.__addManagementMessage(
1629 self.trUtf8("Whois"),
1603 self.trUtf8("{0} has been idle for {1} and {2}.", 1630 self.trUtf8("{0} has been idle for {1} and {2}.",
1604 "{0} = name of person, {1} = (x minutes), " 1631 "{0} = name of person, {1} = (x minutes), "
1605 "{3} = (x seconds)").format( 1632 "{3} = (x seconds)").format(
1606 match.group(1), minutesString, secondsString)) 1633 match.group(1), minutesString, secondsString))
1607 else: 1634 else:
1608 self.__addManagementMessage(self.trUtf8("Whois"), 1635 self.__addManagementMessage(
1609 self.trUtf8("{0} has been idle for %n second(s).", "", 1636 self.trUtf8("Whois"),
1637 self.trUtf8(
1638 "{0} has been idle for %n second(s).", "",
1610 seconds).format(match.group(1))) 1639 seconds).format(match.group(1)))
1611 1640
1612 if not signonTime.isNull(): 1641 if not signonTime.isNull():
1613 self.__addManagementMessage(self.trUtf8("Whois"), 1642 self.__addManagementMessage(
1643 self.trUtf8("Whois"),
1614 self.trUtf8("{0} has been online since {1}.").format( 1644 self.trUtf8("{0} has been online since {1}.").format(
1615 match.group(1), 1645 match.group(1),
1616 signonTime.toString("yyyy-MM-dd, hh:mm:ss"))) 1646 signonTime.toString("yyyy-MM-dd, hh:mm:ss")))
1617 return True 1647 return True
1618 1648
1627 """ 1657 """
1628 # group(1) nick 1658 # group(1) nick
1629 # group(2) end message 1659 # group(2) end message
1630 if match.group(1) == self.__whoIsNick: 1660 if match.group(1) == self.__whoIsNick:
1631 self.__whoIsNick = "" 1661 self.__whoIsNick = ""
1632 self.__addManagementMessage(self.trUtf8("Whois"), 1662 self.__addManagementMessage(
1663 self.trUtf8("Whois"),
1633 self.trUtf8("End of WHOIS list for {0}.").format( 1664 self.trUtf8("End of WHOIS list for {0}.").format(
1634 match.group(1))) 1665 match.group(1)))
1635 return True 1666 return True
1636 1667
1637 return False 1668 return False
1644 @return flag indicating whether the message was handled (boolean) 1675 @return flag indicating whether the message was handled (boolean)
1645 """ 1676 """
1646 # group(1) nick 1677 # group(1) nick
1647 # group(2) identified message 1678 # group(2) identified message
1648 if match.group(1) == self.__whoIsNick: 1679 if match.group(1) == self.__whoIsNick:
1649 self.__addManagementMessage(self.trUtf8("Whois"), 1680 self.__addManagementMessage(
1681 self.trUtf8("Whois"),
1650 self.trUtf8("{0} is an identified user.").format( 1682 self.trUtf8("{0} is an identified user.").format(
1651 match.group(1))) 1683 match.group(1)))
1652 return True 1684 return True
1653 1685
1654 return False 1686 return False
1661 @return flag indicating whether the message was handled (boolean) 1693 @return flag indicating whether the message was handled (boolean)
1662 """ 1694 """
1663 # group(1) nick 1695 # group(1) nick
1664 # group(2) helper message 1696 # group(2) helper message
1665 if match.group(1) == self.__whoIsNick: 1697 if match.group(1) == self.__whoIsNick:
1666 self.__addManagementMessage(self.trUtf8("Whois"), 1698 self.__addManagementMessage(
1699 self.trUtf8("Whois"),
1667 self.trUtf8("{0} is available for help.").format( 1700 self.trUtf8("{0} is available for help.").format(
1668 match.group(1))) 1701 match.group(1)))
1669 return True 1702 return True
1670 1703
1671 return False 1704 return False
1678 @return flag indicating whether the message was handled (boolean) 1711 @return flag indicating whether the message was handled (boolean)
1679 """ 1712 """
1680 # group(1) nick 1713 # group(1) nick
1681 # group(2) login name 1714 # group(2) login name
1682 if match.group(1) == self.__whoIsNick: 1715 if match.group(1) == self.__whoIsNick:
1683 self.__addManagementMessage(self.trUtf8("Whois"), 1716 self.__addManagementMessage(
1684 self.trUtf8("{0} is logged in as {1}.").format(match.group(1), 1717 self.trUtf8("Whois"),
1685 match.group(2))) 1718 self.trUtf8("{0} is logged in as {1}.").format(
1719 match.group(1), match.group(2)))
1686 return True 1720 return True
1687 1721
1688 return False 1722 return False
1689 1723
1690 def __whoIsActually(self, match): 1724 def __whoIsActually(self, match):
1696 """ 1730 """
1697 # group(1) nick 1731 # group(1) nick
1698 # group(2) actual user@host 1732 # group(2) actual user@host
1699 # group(3) actual IP 1733 # group(3) actual IP
1700 if match.group(1) == self.__whoIsNick: 1734 if match.group(1) == self.__whoIsNick:
1701 self.__addManagementMessage(self.trUtf8("Whois"), 1735 self.__addManagementMessage(
1736 self.trUtf8("Whois"),
1702 self.trUtf8( 1737 self.trUtf8(
1703 "{0} is actually using the host {1} (IP: {2}).").format( 1738 "{0} is actually using the host {1} (IP: {2}).").format(
1704 match.group(1), match.group(2), match.group(3))) 1739 match.group(1), match.group(2), match.group(3)))
1705 return True 1740 return True
1706 1741
1713 @param match match object that matched the pattern 1748 @param match match object that matched the pattern
1714 @return flag indicating whether the message was handled (boolean) 1749 @return flag indicating whether the message was handled (boolean)
1715 """ 1750 """
1716 # group(1) nick 1751 # group(1) nick
1717 if match.group(1) == self.__whoIsNick: 1752 if match.group(1) == self.__whoIsNick:
1718 self.__addManagementMessage(self.trUtf8("Whois"), 1753 self.__addManagementMessage(
1754 self.trUtf8("Whois"),
1719 self.trUtf8("{0} is using a secure connection.").format( 1755 self.trUtf8("{0} is using a secure connection.").format(
1720 match.group(1))) 1756 match.group(1)))
1721 return True 1757 return True
1722 1758
1723 return False 1759 return False
1731 """ 1767 """
1732 # group(1) nick 1768 # group(1) nick
1733 # group(2) host name 1769 # group(2) host name
1734 # group(3) IP 1770 # group(3) IP
1735 if match.group(1) == self.__whoIsNick: 1771 if match.group(1) == self.__whoIsNick:
1736 self.__addManagementMessage(self.trUtf8("Whois"), 1772 self.__addManagementMessage(
1773 self.trUtf8("Whois"),
1737 self.trUtf8("{0} is connecting from {1} (IP: {2}).").format( 1774 self.trUtf8("{0} is connecting from {1} (IP: {2}).").format(
1738 match.group(1), match.group(2), match.group(3))) 1775 match.group(1), match.group(2), match.group(3)))
1739 return True 1776 return True
1740 1777
1741 return False 1778 return False

eric ide

mercurial