Network/IRC/IrcChannelWidget.py

branch
5_3_x
changeset 2477
5d706fb30a10
parent 2449
b5b9d235e2cd
child 2525
8b507a9a2d40
child 2631
06f866e83d3a
equal deleted inserted replaced
2475:c74e1cff7f3f 2477:5d706fb30a10
461 """ 461 """
462 # group(1) sender user name 462 # group(1) sender user name
463 # group(2) sender user@host 463 # group(2) sender user@host
464 # group(3) target nick 464 # group(3) target nick
465 # group(4) message 465 # group(4) message
466 if match.group(3).lower() == self.__name: 466 if match.group(3).lower() == self.__name.lower():
467 if match.group(4).startswith("\x01"): 467 if match.group(4).startswith("\x01"):
468 return self.__handleCtcp(match) 468 return self.__handleCtcp(match)
469 469
470 self.addMessage(match.group(1), match.group(4)) 470 self.addMessage(match.group(1), match.group(4))
471 if self.__private and not self.topicLabel.text(): 471 if self.__private and not self.topicLabel.text():
512 Private method to handle a user joining the channel. 512 Private method to handle a user joining the channel.
513 513
514 @param match match object that matched the pattern 514 @param match match object that matched the pattern
515 @return flag indicating whether the message was handled (boolean) 515 @return flag indicating whether the message was handled (boolean)
516 """ 516 """
517 if match.group(3).lower() == self.__name: 517 if match.group(3).lower() == self.__name.lower():
518 if self.__userName != match.group(1): 518 if self.__userName != match.group(1):
519 IrcUserItem(match.group(1), self.usersList) 519 IrcUserItem(match.group(1), self.usersList)
520 msg = self.trUtf8("{0} has joined the channel {1} ({2}).").format( 520 msg = self.trUtf8("{0} has joined the channel {1} ({2}).").format(
521 match.group(1), self.__name, match.group(2)) 521 match.group(1), self.__name, match.group(2))
522 self.__addManagementMessage(IrcChannelWidget.JoinIndicator, msg) 522 self.__addManagementMessage(IrcChannelWidget.JoinIndicator, msg)
537 Private method to handle a user leaving the channel. 537 Private method to handle a user leaving the channel.
538 538
539 @param match match object that matched the pattern 539 @param match match object that matched the pattern
540 @return flag indicating whether the message was handled (boolean) 540 @return flag indicating whether the message was handled (boolean)
541 """ 541 """
542 if match.group(2).lower() == self.__name: 542 if match.group(2).lower() == self.__name.lower():
543 itm = self.__findUser(match.group(1)) 543 itm = self.__findUser(match.group(1))
544 self.usersList.takeItem(self.usersList.row(itm)) 544 self.usersList.takeItem(self.usersList.row(itm))
545 del itm 545 del itm
546 if match.lastindex == 2: 546 if match.lastindex == 2:
547 msg = self.trUtf8("{0} has left {1}.").format( 547 msg = self.trUtf8("{0} has left {1}.").format(
617 Private method to handle the receipt of a list of users of the channel. 617 Private method to handle the receipt of a list of users of the channel.
618 618
619 @param match match object that matched the pattern 619 @param match match object that matched the pattern
620 @return flag indicating whether the message was handled (boolean) 620 @return flag indicating whether the message was handled (boolean)
621 """ 621 """
622 if match.group(1).lower() == self.__name: 622 if match.group(1).lower() == self.__name.lower():
623 users = match.group(2).split() 623 users = match.group(2).split()
624 for user in users: 624 for user in users:
625 userPrivileges, userName = self.__extractPrivilege(user) 625 userPrivileges, userName = self.__extractPrivilege(user)
626 itm = self.__findUser(userName) 626 itm = self.__findUser(userName)
627 if itm is None: 627 if itm is None:
639 Private method to handle a topic change of the channel. 639 Private method to handle a topic change of the channel.
640 640
641 @param match match object that matched the pattern 641 @param match match object that matched the pattern
642 @return flag indicating whether the message was handled (boolean) 642 @return flag indicating whether the message was handled (boolean)
643 """ 643 """
644 if match.group(1).lower() == self.__name: 644 if match.group(1).lower() == self.__name.lower():
645 self.__addManagementMessage(self.trUtf8("Away"), 645 self.__addManagementMessage(self.trUtf8("Away"),
646 self.trUtf8("{0} is away: {1}").format(match.group(2), match.group(3))) 646 self.trUtf8("{0} is away: {1}").format(match.group(2), match.group(3)))
647 return True 647 return True
648 648
649 return False 649 return False
653 Private method to handle a topic change of the channel. 653 Private method to handle a topic change of the channel.
654 654
655 @param match match object that matched the pattern 655 @param match match object that matched the pattern
656 @return flag indicating whether the message was handled (boolean) 656 @return flag indicating whether the message was handled (boolean)
657 """ 657 """
658 if match.group(1).lower() == self.__name: 658 if match.group(1).lower() == self.__name.lower():
659 self.topicLabel.setText(match.group(2)) 659 self.topicLabel.setText(match.group(2))
660 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 660 self.__addManagementMessage(IrcChannelWidget.MessageIndicator,
661 ircFilter(self.trUtf8('The channel topic is: "{0}".').format( 661 ircFilter(self.trUtf8('The channel topic is: "{0}".').format(
662 match.group(2)))) 662 match.group(2))))
663 return True 663 return True
669 Private method to handle a topic created message. 669 Private method to handle a topic created message.
670 670
671 @param match match object that matched the pattern 671 @param match match object that matched the pattern
672 @return flag indicating whether the message was handled (boolean) 672 @return flag indicating whether the message was handled (boolean)
673 """ 673 """
674 if match.group(1).lower() == self.__name: 674 if match.group(1).lower() == self.__name.lower():
675 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 675 self.__addManagementMessage(IrcChannelWidget.MessageIndicator,
676 self.trUtf8("The topic was set by {0} on {1}.").format( 676 self.trUtf8("The topic was set by {0} on {1}.").format(
677 match.group(2), QDateTime.fromTime_t(int(match.group(3)))\ 677 match.group(2), QDateTime.fromTime_t(int(match.group(3)))\
678 .toString("yyyy-MM-dd hh:mm"))) 678 .toString("yyyy-MM-dd hh:mm")))
679 return True 679 return True
685 Private method to handle a channel URL message. 685 Private method to handle a channel URL message.
686 686
687 @param match match object that matched the pattern 687 @param match match object that matched the pattern
688 @return flag indicating whether the message was handled (boolean) 688 @return flag indicating whether the message was handled (boolean)
689 """ 689 """
690 if match.group(1).lower() == self.__name: 690 if match.group(1).lower() == self.__name.lower():
691 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 691 self.__addManagementMessage(IrcChannelWidget.MessageIndicator,
692 ircFilter(self.trUtf8("Channel URL: {0}").format(match.group(2)))) 692 ircFilter(self.trUtf8("Channel URL: {0}").format(match.group(2))))
693 return True 693 return True
694 694
695 return False 695 return False
699 Private method to handle a message reporting the channel modes. 699 Private method to handle a message reporting the channel modes.
700 700
701 @param match match object that matched the pattern 701 @param match match object that matched the pattern
702 @return flag indicating whether the message was handled (boolean) 702 @return flag indicating whether the message was handled (boolean)
703 """ 703 """
704 if match.group(1).lower() == self.__name: 704 if match.group(1).lower() == self.__name.lower():
705 modesDict = getChannelModesDict() 705 modesDict = getChannelModesDict()
706 modesParameters = match.group(2).split() 706 modesParameters = match.group(2).split()
707 modeString = modesParameters.pop(0) 707 modeString = modesParameters.pop(0)
708 modes = [] 708 modes = []
709 for modeChar in modeString: 709 for modeChar in modeString:
734 Private method to handle a channel created message. 734 Private method to handle a channel created message.
735 735
736 @param match match object that matched the pattern 736 @param match match object that matched the pattern
737 @return flag indicating whether the message was handled (boolean) 737 @return flag indicating whether the message was handled (boolean)
738 """ 738 """
739 if match.group(1).lower() == self.__name: 739 if match.group(1).lower() == self.__name.lower():
740 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 740 self.__addManagementMessage(IrcChannelWidget.MessageIndicator,
741 self.trUtf8("This channel was created on {0}.").format( 741 self.trUtf8("This channel was created on {0}.").format(
742 QDateTime.fromTime_t(int(match.group(2)))\ 742 QDateTime.fromTime_t(int(match.group(2)))\
743 .toString("yyyy-MM-dd hh:mm"))) 743 .toString("yyyy-MM-dd hh:mm")))
744 return True 744 return True
753 @return flag indicating whether the message was handled (boolean) 753 @return flag indicating whether the message was handled (boolean)
754 """ 754 """
755 # group(1) user or server 755 # group(1) user or server
756 # group(2) channel 756 # group(2) channel
757 # group(3) modes and parameter list 757 # group(3) modes and parameter list
758 if match.group(2).lower() == self.__name: 758 if match.group(2).lower() == self.__name.lower():
759 nick = match.group(1) 759 nick = match.group(1)
760 modesParameters = match.group(3).split() 760 modesParameters = match.group(3).split()
761 modeString = modesParameters.pop(0) 761 modeString = modesParameters.pop(0)
762 isPlus = True 762 isPlus = True
763 message = "" 763 message = ""
895 Private method to handle a change of user privileges for the channel. 895 Private method to handle a change of user privileges for the channel.
896 896
897 @param match match object that matched the pattern 897 @param match match object that matched the pattern
898 @return flag indicating whether the message was handled (boolean) 898 @return flag indicating whether the message was handled (boolean)
899 """ 899 """
900 if match.group(2).lower() == self.__name: 900 if match.group(2).lower() == self.__name.lower():
901 itm = self.__findUser(match.group(4)) 901 itm = self.__findUser(match.group(4))
902 if itm: 902 if itm:
903 itm.changePrivilege(match.group(3)) 903 itm.changePrivilege(match.group(3))
904 self.__setEditTopicButton() 904 self.__setEditTopicButton()
905 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 905 self.__addManagementMessage(IrcChannelWidget.MessageIndicator,
914 Private method to handle a channel message we are not interested in. 914 Private method to handle a channel message we are not interested in.
915 915
916 @param match match object that matched the pattern 916 @param match match object that matched the pattern
917 @return flag indicating whether the message was handled (boolean) 917 @return flag indicating whether the message was handled (boolean)
918 """ 918 """
919 if match.group(1).lower() == self.__name: 919 if match.group(1).lower() == self.__name.lower():
920 return True 920 return True
921 921
922 return False 922 return False
923 923
924 def __help(self, match): 924 def __help(self, match):
1325 Private method to handle the end of the WHO list. 1325 Private method to handle the end of the WHO list.
1326 1326
1327 @param match match object that matched the pattern 1327 @param match match object that matched the pattern
1328 @return flag indicating whether the message was handled (boolean) 1328 @return flag indicating whether the message was handled (boolean)
1329 """ 1329 """
1330 if match.group(1).lower() == self.__name: 1330 if match.group(1).lower() == self.__name.lower():
1331 if self.__autoWhoRequested: 1331 if self.__autoWhoRequested:
1332 self.__autoWhoRequested = False 1332 self.__autoWhoRequested = False
1333 self.initAutoWho() 1333 self.initAutoWho()
1334 else: 1334 else:
1335 self.__addManagementMessage(self.trUtf8("Who"), 1335 self.__addManagementMessage(self.trUtf8("Who"),
1350 # group(2) user 1350 # group(2) user
1351 # group(3) host 1351 # group(3) host
1352 # group(4) nick 1352 # group(4) nick
1353 # group(5) user flags 1353 # group(5) user flags
1354 # group(6) real name 1354 # group(6) real name
1355 if match.group(1).lower() == self.__name: 1355 if match.group(1).lower() == self.__name.lower():
1356 away = self.trUtf8(" (Away)") if match.group(5).startswith("G") else "" 1356 away = self.trUtf8(" (Away)") if match.group(5).startswith("G") else ""
1357 self.__addManagementMessage(self.trUtf8("Who"), 1357 self.__addManagementMessage(self.trUtf8("Who"),
1358 self.trUtf8("{0} is {1}@{2} ({3}){4}").format( 1358 self.trUtf8("{0} is {1}@{2} ({3}){4}").format(
1359 match.group(4), match.group(2), match.group(3), match.group(6), away)) 1359 match.group(4), match.group(2), match.group(3), match.group(6), away))
1360 return True 1360 return True

eric ide

mercurial