170 """ |
170 """ |
171 Public method to check, if the user is allowed to change the topic. |
171 Public method to check, if the user is allowed to change the topic. |
172 |
172 |
173 @return flag indicating that the topic can be changed (boolean) |
173 @return flag indicating that the topic can be changed (boolean) |
174 """ |
174 """ |
175 return(bool(self.__privilege & IrcUserItem.Operator) or \ |
175 return(bool(self.__privilege & IrcUserItem.Operator) or |
176 bool(self.__privilege & IrcUserItem.Admin) or \ |
176 bool(self.__privilege & IrcUserItem.Admin) or |
177 bool(self.__privilege & IrcUserItem.Owner)) |
177 bool(self.__privilege & IrcUserItem.Owner)) |
178 |
178 |
179 |
179 |
180 class IrcChannelWidget(QWidget, Ui_IrcChannelWidget): |
180 class IrcChannelWidget(QWidget, Ui_IrcChannelWidget): |
181 """ |
181 """ |
349 msg = self.messageEdit.text() |
349 msg = self.messageEdit.text() |
350 if msg: |
350 if msg: |
351 self.messages.append( |
351 self.messages.append( |
352 '<font color="{0}">{2} <b><</b><font color="{1}">{3}</font>' |
352 '<font color="{0}">{2} <b><</b><font color="{1}">{3}</font>' |
353 '<b>></b> {4}</font>'.format( |
353 '<b>></b> {4}</font>'.format( |
354 Preferences.getIrc("ChannelMessageColour"), |
354 Preferences.getIrc("ChannelMessageColour"), |
355 Preferences.getIrc("OwnNickColour"), |
355 Preferences.getIrc("OwnNickColour"), |
356 ircTimestamp(), self.__userName, Utilities.html_encode(msg))) |
356 ircTimestamp(), self.__userName, |
|
357 Utilities.html_encode(msg))) |
357 if msg.startswith("/"): |
358 if msg.startswith("/"): |
358 if self.__private: |
359 if self.__private: |
359 E5MessageBox.information( |
360 E5MessageBox.information( |
360 self, |
361 self, |
361 self.trUtf8("Send Message"), |
362 self.trUtf8("Send Message"), |
386 ok = E5MessageBox.yesNo( |
387 ok = E5MessageBox.yesNo( |
387 self, |
388 self, |
388 self.trUtf8("Leave IRC channel"), |
389 self.trUtf8("Leave IRC channel"), |
389 self.trUtf8( |
390 self.trUtf8( |
390 """Do you really want to leave the IRC channel <b>{0}</b>?""") |
391 """Do you really want to leave the IRC channel <b>{0}</b>?""") |
391 .format(self.__name)) |
392 .format(self.__name)) |
392 if ok: |
393 if ok: |
393 if not self.__private: |
394 if not self.__private: |
394 self.sendData.emit( |
395 self.sendData.emit( |
395 "PART " + self.__name + " :" + self.__partMessage) |
396 "PART " + self.__name + " :" + self.__partMessage) |
396 self.channelClosed.emit(self.__name) |
397 self.channelClosed.emit(self.__name) |
517 @param msg message received from sender (string) |
518 @param msg message received from sender (string) |
518 """ |
519 """ |
519 self.__appendMessage( |
520 self.__appendMessage( |
520 '<font color="{0}">{2} <b><</b><font color="{1}">{3}</font>' |
521 '<font color="{0}">{2} <b><</b><font color="{1}">{3}</font>' |
521 '<b>></b> {4}</font>'.format( |
522 '<b>></b> {4}</font>'.format( |
522 Preferences.getIrc("ChannelMessageColour"), |
523 Preferences.getIrc("ChannelMessageColour"), |
523 Preferences.getIrc("NickColour"), |
524 Preferences.getIrc("NickColour"), |
524 ircTimestamp(), sender, ircFilter(msg))) |
525 ircTimestamp(), sender, ircFilter(msg))) |
525 if Preferences.getIrc("ShowNotifications"): |
526 if Preferences.getIrc("ShowNotifications"): |
526 if Preferences.getIrc("NotifyMessage"): |
527 if Preferences.getIrc("NotifyMessage"): |
527 self.__ui.showNotification( |
528 self.__ui.showNotification( |
528 UI.PixmapCache.getPixmap("irc48.png"), |
529 UI.PixmapCache.getPixmap("irc48.png"), |
529 self.trUtf8("Channel Message"), msg) |
530 self.trUtf8("Channel Message"), msg) |
530 elif Preferences.getIrc("NotifyNick") and \ |
531 elif Preferences.getIrc("NotifyNick") and \ |
531 self.__userName.lower() in msg.lower(): |
532 self.__userName.lower() in msg.lower(): |
532 self.__ui.showNotification( |
533 self.__ui.showNotification( |
533 UI.PixmapCache.getPixmap("irc48.png"), |
534 UI.PixmapCache.getPixmap("irc48.png"), |
534 self.trUtf8("Nick mentioned"), msg) |
535 self.trUtf8("Nick mentioned"), msg) |
535 |
536 |
536 def addUsers(self, users): |
537 def addUsers(self, users): |
554 if match.group(3).lower() == self.__name.lower(): |
555 if match.group(3).lower() == self.__name.lower(): |
555 if self.__userName != match.group(1): |
556 if self.__userName != match.group(1): |
556 IrcUserItem(match.group(1), self.usersList) |
557 IrcUserItem(match.group(1), self.usersList) |
557 msg = self.trUtf8( |
558 msg = self.trUtf8( |
558 "{0} has joined the channel {1} ({2}).").format( |
559 "{0} has joined the channel {1} ({2}).").format( |
559 match.group(1), self.__name, match.group(2)) |
560 match.group(1), self.__name, match.group(2)) |
560 self.__addManagementMessage( |
561 self.__addManagementMessage( |
561 IrcChannelWidget.JoinIndicator, msg) |
562 IrcChannelWidget.JoinIndicator, msg) |
562 else: |
563 else: |
563 msg = self.trUtf8( |
564 msg = self.trUtf8( |
564 "You have joined the channel {0} ({1}).").format( |
565 "You have joined the channel {0} ({1}).").format( |
565 self.__name, match.group(2)) |
566 self.__name, match.group(2)) |
566 self.__addManagementMessage( |
567 self.__addManagementMessage( |
567 IrcChannelWidget.JoinIndicator, msg) |
568 IrcChannelWidget.JoinIndicator, msg) |
568 if Preferences.getIrc("ShowNotifications") and \ |
569 if Preferences.getIrc("ShowNotifications") and \ |
569 Preferences.getIrc("NotifyJoinPart"): |
570 Preferences.getIrc("NotifyJoinPart"): |
570 self.__ui.showNotification( |
571 self.__ui.showNotification( |
726 """ |
727 """ |
727 if match.group(1).lower() == self.__name.lower(): |
728 if match.group(1).lower() == self.__name.lower(): |
728 self.__addManagementMessage( |
729 self.__addManagementMessage( |
729 IrcChannelWidget.MessageIndicator, |
730 IrcChannelWidget.MessageIndicator, |
730 self.trUtf8("The topic was set by {0} on {1}.").format( |
731 self.trUtf8("The topic was set by {0} on {1}.").format( |
731 match.group(2), QDateTime.fromTime_t(int(match.group(3)))\ |
732 match.group(2), QDateTime.fromTime_t(int(match.group(3))) |
732 .toString("yyyy-MM-dd hh:mm"))) |
733 .toString("yyyy-MM-dd hh:mm"))) |
733 return True |
734 return True |
734 |
735 |
735 return False |
736 return False |
736 |
737 |
737 def __channelUrl(self, match): |
738 def __channelUrl(self, match): |
795 """ |
796 """ |
796 if match.group(1).lower() == self.__name.lower(): |
797 if match.group(1).lower() == self.__name.lower(): |
797 self.__addManagementMessage( |
798 self.__addManagementMessage( |
798 IrcChannelWidget.MessageIndicator, |
799 IrcChannelWidget.MessageIndicator, |
799 self.trUtf8("This channel was created on {0}.").format( |
800 self.trUtf8("This channel was created on {0}.").format( |
800 QDateTime.fromTime_t(int(match.group(2)))\ |
801 QDateTime.fromTime_t(int(match.group(2))) |
801 .toString("yyyy-MM-dd hh:mm"))) |
802 .toString("yyyy-MM-dd hh:mm"))) |
802 return True |
803 return True |
803 |
804 |
804 return False |
805 return False |
805 |
806 |
806 def __updateChannelModes(self, match): |
807 def __updateChannelModes(self, match): |
1023 if ctcpRequest == "version": |
1024 if ctcpRequest == "version": |
1024 msg = "Eric IRC client {0}, {1}".format(Version, Copyright) |
1025 msg = "Eric IRC client {0}, {1}".format(Version, Copyright) |
1025 self.__addManagementMessage( |
1026 self.__addManagementMessage( |
1026 self.trUtf8("CTCP"), |
1027 self.trUtf8("CTCP"), |
1027 self.trUtf8("Received Version request from {0}.").format( |
1028 self.trUtf8("Received Version request from {0}.").format( |
1028 match.group(1))) |
1029 match.group(1))) |
1029 self.sendCtcpReply.emit(match.group(1), "VERSION " + msg) |
1030 self.sendCtcpReply.emit(match.group(1), "VERSION " + msg) |
1030 elif ctcpRequest == "ping": |
1031 elif ctcpRequest == "ping": |
1031 self.__addManagementMessage( |
1032 self.__addManagementMessage( |
1032 self.trUtf8("CTCP"), |
1033 self.trUtf8("CTCP"), |
1033 self.trUtf8( |
1034 self.trUtf8( |
1107 color = Preferences.getIrc("LeaveChannelColour") |
1108 color = Preferences.getIrc("LeaveChannelColour") |
1108 else: |
1109 else: |
1109 color = Preferences.getIrc("ChannelInfoColour") |
1110 color = Preferences.getIrc("ChannelInfoColour") |
1110 self.__appendMessage( |
1111 self.__appendMessage( |
1111 '<font color="{0}">{1} <b>[</b>{2}<b>]</b> {3}</font>'.format( |
1112 '<font color="{0}">{1} <b>[</b>{2}<b>]</b> {3}</font>'.format( |
1112 color, ircTimestamp(), indicator, message)) |
1113 color, ircTimestamp(), indicator, message)) |
1113 |
1114 |
1114 def __appendMessage(self, message): |
1115 def __appendMessage(self, message): |
1115 """ |
1116 """ |
1116 Private slot to append a message. |
1117 Private slot to append a message. |
1117 |
1118 |
1235 self, |
1236 self, |
1236 self.trUtf8("Error saving Messages"), |
1237 self.trUtf8("Error saving Messages"), |
1237 self.trUtf8( |
1238 self.trUtf8( |
1238 """<p>The messages contents could not be written""" |
1239 """<p>The messages contents could not be written""" |
1239 """ to <b>{0}</b></p><p>Reason: {1}</p>""") |
1240 """ to <b>{0}</b></p><p>Reason: {1}</p>""") |
1240 .format(fname, str(err))) |
1241 .format(fname, str(err))) |
1241 |
1242 |
1242 def __initMessagesMenu(self): |
1243 def __initMessagesMenu(self): |
1243 """ |
1244 """ |
1244 Private slot to initialize the context menu of the messages pane. |
1245 Private slot to initialize the context menu of the messages pane. |
1245 """ |
1246 """ |
1488 channelList = match.group(2).split() |
1489 channelList = match.group(2).split() |
1489 for channel in channelList: |
1490 for channel in channelList: |
1490 if channel.startswith(("*", "&")): |
1491 if channel.startswith(("*", "&")): |
1491 adminChannels.append(channel[1:]) |
1492 adminChannels.append(channel[1:]) |
1492 elif channel.startswith(("!", "~")) and \ |
1493 elif channel.startswith(("!", "~")) and \ |
1493 self.__ircWidget.isChannelName(channel[1:]): |
1494 self.__ircWidget.isChannelName(channel[1:]): |
1494 ownerChannels.append(channel[1:]) |
1495 ownerChannels.append(channel[1:]) |
1495 elif channel.startswith("@+"): |
1496 elif channel.startswith("@+"): |
1496 opChannels.append(channel[2:]) |
1497 opChannels.append(channel[2:]) |
1497 elif channel.startswith("@"): |
1498 elif channel.startswith("@"): |
1498 opChannels.append(channel[1:]) |
1499 opChannels.append(channel[1:]) |
1506 # show messages |
1507 # show messages |
1507 if userChannels: |
1508 if userChannels: |
1508 self.__addManagementMessage( |
1509 self.__addManagementMessage( |
1509 self.trUtf8("Whois"), |
1510 self.trUtf8("Whois"), |
1510 self.trUtf8("{0} is a user on channels: {1}").format( |
1511 self.trUtf8("{0} is a user on channels: {1}").format( |
1511 match.group(1), " ".join(userChannels))) |
1512 match.group(1), " ".join(userChannels))) |
1512 if voiceChannels: |
1513 if voiceChannels: |
1513 self.__addManagementMessage( |
1514 self.__addManagementMessage( |
1514 self.trUtf8("Whois"), |
1515 self.trUtf8("Whois"), |
1515 self.trUtf8("{0} has voice on channels: {1}").format( |
1516 self.trUtf8("{0} has voice on channels: {1}").format( |
1516 match.group(1), " ".join(voiceChannels))) |
1517 match.group(1), " ".join(voiceChannels))) |
1517 if halfopChannels: |
1518 if halfopChannels: |
1518 self.__addManagementMessage( |
1519 self.__addManagementMessage( |
1519 self.trUtf8("Whois"), |
1520 self.trUtf8("Whois"), |
1520 self.trUtf8("{0} is a halfop on channels: {1}").format( |
1521 self.trUtf8("{0} is a halfop on channels: {1}").format( |
1521 match.group(1), " ".join(halfopChannels))) |
1522 match.group(1), " ".join(halfopChannels))) |
1522 if opChannels: |
1523 if opChannels: |
1523 self.__addManagementMessage( |
1524 self.__addManagementMessage( |
1524 self.trUtf8("Whois"), |
1525 self.trUtf8("Whois"), |
1525 self.trUtf8("{0} is an operator on channels: {1}").format( |
1526 self.trUtf8("{0} is an operator on channels: {1}").format( |
1526 match.group(1), " ".join(opChannels))) |
1527 match.group(1), " ".join(opChannels))) |
1527 if ownerChannels: |
1528 if ownerChannels: |
1528 self.__addManagementMessage( |
1529 self.__addManagementMessage( |
1529 self.trUtf8("Whois"), |
1530 self.trUtf8("Whois"), |
1530 self.trUtf8("{0} is owner of channels: {1}").format( |
1531 self.trUtf8("{0} is owner of channels: {1}").format( |
1531 match.group(1), " ".join(ownerChannels))) |
1532 match.group(1), " ".join(ownerChannels))) |
1532 if adminChannels: |
1533 if adminChannels: |
1533 self.__addManagementMessage( |
1534 self.__addManagementMessage( |
1534 self.trUtf8("Whois"), |
1535 self.trUtf8("Whois"), |
1535 self.trUtf8("{0} is admin on channels: {1}").format( |
1536 self.trUtf8("{0} is admin on channels: {1}").format( |
1536 match.group(1), " ".join(adminChannels))) |
1537 match.group(1), " ".join(adminChannels))) |
1537 return True |
1538 return True |
1538 |
1539 |
1539 return False |
1540 return False |
1540 |
1541 |
1541 def __whoIsServer(self, match): |
1542 def __whoIsServer(self, match): |
1618 hoursString = self.trUtf8("%n hour(s)", "", hours) |
1619 hoursString = self.trUtf8("%n hour(s)", "", hours) |
1619 minutesString = self.trUtf8("%n minute(s)", "", minutes) |
1620 minutesString = self.trUtf8("%n minute(s)", "", minutes) |
1620 secondsString = self.trUtf8("%n second(s)", "", seconds) |
1621 secondsString = self.trUtf8("%n second(s)", "", seconds) |
1621 self.__addManagementMessage( |
1622 self.__addManagementMessage( |
1622 self.trUtf8("Whois"), |
1623 self.trUtf8("Whois"), |
1623 self.trUtf8("{0} has been idle for {1}, {2}, and {3}.", |
1624 self.trUtf8( |
1624 "{0} = name of person, {1} = (x hours), " |
1625 "{0} has been idle for {1}, {2}, and {3}.", |
1625 "{2} = (x minutes), {3} = (x seconds)").format( |
1626 "{0} = name of person, {1} = (x hours), " |
1626 match.group(1), hoursString, minutesString, secondsString)) |
1627 "{2} = (x minutes), {3} = (x seconds)") |
|
1628 .format(match.group(1), hoursString, minutesString, |
|
1629 secondsString)) |
1627 elif minutes: |
1630 elif minutes: |
1628 minutesString = self.trUtf8("%n minute(s)", "", minutes) |
1631 minutesString = self.trUtf8("%n minute(s)", "", minutes) |
1629 secondsString = self.trUtf8("%n second(s)", "", seconds) |
1632 secondsString = self.trUtf8("%n second(s)", "", seconds) |
1630 self.__addManagementMessage( |
1633 self.__addManagementMessage( |
1631 self.trUtf8("Whois"), |
1634 self.trUtf8("Whois"), |
1632 self.trUtf8("{0} has been idle for {1} and {2}.", |
1635 self.trUtf8( |
1633 "{0} = name of person, {1} = (x minutes), " |
1636 "{0} has been idle for {1} and {2}.", |
1634 "{3} = (x seconds)").format( |
1637 "{0} = name of person, {1} = (x minutes), " |
1635 match.group(1), minutesString, secondsString)) |
1638 "{3} = (x seconds)") |
|
1639 .format(match.group(1), minutesString, secondsString)) |
1636 else: |
1640 else: |
1637 self.__addManagementMessage( |
1641 self.__addManagementMessage( |
1638 self.trUtf8("Whois"), |
1642 self.trUtf8("Whois"), |
1639 self.trUtf8( |
1643 self.trUtf8( |
1640 "{0} has been idle for %n second(s).", "", |
1644 "{0} has been idle for %n second(s).", "", |
1642 |
1646 |
1643 if not signonTime.isNull(): |
1647 if not signonTime.isNull(): |
1644 self.__addManagementMessage( |
1648 self.__addManagementMessage( |
1645 self.trUtf8("Whois"), |
1649 self.trUtf8("Whois"), |
1646 self.trUtf8("{0} has been online since {1}.").format( |
1650 self.trUtf8("{0} has been online since {1}.").format( |
1647 match.group(1), |
1651 match.group(1), |
1648 signonTime.toString("yyyy-MM-dd, hh:mm:ss"))) |
1652 signonTime.toString("yyyy-MM-dd, hh:mm:ss"))) |
1649 return True |
1653 return True |
1650 |
1654 |
1651 return False |
1655 return False |
1652 |
1656 |
1653 def __whoIsEnd(self, match): |
1657 def __whoIsEnd(self, match): |
1772 # group(3) IP |
1776 # group(3) IP |
1773 if match.group(1) == self.__whoIsNick: |
1777 if match.group(1) == self.__whoIsNick: |
1774 self.__addManagementMessage( |
1778 self.__addManagementMessage( |
1775 self.trUtf8("Whois"), |
1779 self.trUtf8("Whois"), |
1776 self.trUtf8("{0} is connecting from {1} (IP: {2}).").format( |
1780 self.trUtf8("{0} is connecting from {1} (IP: {2}).").format( |
1777 match.group(1), match.group(2), match.group(3))) |
1781 match.group(1), match.group(2), match.group(3))) |
1778 return True |
1782 return True |
1779 |
1783 |
1780 return False |
1784 return False |
1781 |
1785 |
1782 def __setEditTopicButton(self): |
1786 def __setEditTopicButton(self): |