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 |
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 |
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 |
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. |
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("<", "<").replace(">", ">") |
1459 realName = match.group(4).replace("<", "<").replace(">", ">") |
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 |
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 |
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): |