annotate participant.py @ 178:891195c47350

catch all exceptions in commands.py Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 08 Feb 2010 18:55:36 +0100
parents c158ad24ef3c
children 102f895347ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
1 #!/usr/bin/env python
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
3
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
4 # This program is free software: you can redistribute it and/or modify
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
5 # it under the terms of the GNU General Public License as published by
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
6 # the Free Software Foundation, either version 3 of the License, or
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
7 # (at your option) any later version.
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
8 #
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
9 # This program is distributed in the hope that it will be useful,
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
12 # GNU General Public License for more details.
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
13 #
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
14 # You should have received a copy of the GNU General Public License
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
16
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
17
124
99f3dee1fad7 code cleaning
Charly COSTE <changaco@changaco.net>
parents: 123
diff changeset
18 import re
99f3dee1fad7 code cleaning
Charly COSTE <changaco@changaco.net>
parents: 123
diff changeset
19 from time import sleep
99f3dee1fad7 code cleaning
Charly COSTE <changaco@changaco.net>
parents: 123
diff changeset
20
99f3dee1fad7 code cleaning
Charly COSTE <changaco@changaco.net>
parents: 123
diff changeset
21 from irclib import ServerNotConnectedError, ServerConnection
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
22 import muc
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
23 xmpp = muc.xmpp
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
24 del muc
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
25
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
26
124
99f3dee1fad7 code cleaning
Charly COSTE <changaco@changaco.net>
parents: 123
diff changeset
27 class Participant:
103
23416c27b592 New command system
Charly COSTE <changaco@changaco.net>
parents: 98
diff changeset
28 def __init__(self, owner_bridge, protocol, nickname, real_jid=None):
23416c27b592 New command system
Charly COSTE <changaco@changaco.net>
parents: 98
diff changeset
29 self.bot_admin = False
23416c27b592 New command system
Charly COSTE <changaco@changaco.net>
parents: 98
diff changeset
30 self.real_jid = real_jid
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
31 self.bridge = owner_bridge
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
32 self.protocol = protocol
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
33 self.nickname = nickname
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
34 self.duplicate_nickname = self.nickname
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
35 self.irc_connection = None
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
36 self.xmpp_c = None
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
37 self.muc = None
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
38 if protocol == 'xmpp' and self.bridge.mode in ['normal', 'bypass']:
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
39 self.createDuplicateOnIRC()
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
40 elif protocol == 'irc' and self.bridge.mode != 'minimal':
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
41 self.createDuplicateOnXMPP()
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
42
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
43
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
44 def _get_new_duplicate_nickname(self):
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
45 new_duplicate_nickname = self.duplicate_nickname
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
46 for i in xrange(5):
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
47 new_duplicate_nickname = new_duplicate_nickname+'_'
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
48 if not self.bridge.hasParticipant(new_duplicate_nickname):
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
49 return new_duplicate_nickname
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
50 return None
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
51
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
52
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
53 def createDuplicateOnXMPP(self):
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
54 if isinstance(self.xmpp_c, xmpp.client.Client) or isinstance(self.irc_connection, ServerConnection):
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
55 return
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
56 self.xmpp_c = self.bridge.bot.get_xmpp_connection(self.duplicate_nickname)
103
23416c27b592 New command system
Charly COSTE <changaco@changaco.net>
parents: 98
diff changeset
57 self.muc = xmpp.muc(self.bridge.xmpp_room_jid)
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
58 self.join_muc()
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
59
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
60
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
61 def join_muc(self):
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
62 self.muc.join(self.xmpp_c, self.duplicate_nickname, status='From IRC', callback=self._xmpp_join_callback)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
63
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
64
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
65 def _xmpp_join_callback(self, errors):
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
66 if len(errors) == 0:
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
67 m = '===> Debug: "'+self.nickname+'" duplicate succesfully created on XMPP side of bridge "'+str(self.bridge)+'"'
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
68 if self.nickname != self.duplicate_nickname:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
69 m += ' using nickname "'+self.duplicate_nickname+'"'
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
70 self.bridge.say('[Info] "'+self.nickname+'" will appear as "'+self.duplicate_nickname+'" on XMPP because its real nickname is reserved or contains unauthorized characters')
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
71 self.bridge.bot.error(m, debug=True)
82
90baff5dedb2 Fixed callbacks in participant.py
Charly COSTE <changaco@changaco.net>
parents: 78
diff changeset
72 elif self.xmpp_c != 'both':
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
73 for error in errors:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
74 try:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
75 raise error
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
76 except xmpp.muc.NicknameConflict as e:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
77 if xmpp.protocol.JID(e.args[0]).getResource() != self.duplicate_nickname:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
78 return
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
79
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
80 if self.bridge.mode == 'bypass':
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
81 new_duplicate_nickname = self._get_new_duplicate_nickname()
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
82 if new_duplicate_nickname != None:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
83 self.bridge.bot.error('===> Debug: "'+self.duplicate_nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self.bridge)+'", trying "'+new_duplicate_nickname+'"', debug=True)
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
84 if self.duplicate_nickname == self.nickname:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
85 self.bridge.say('[Info] The nickname "'+self.duplicate_nickname+'" is used on both rooms or reserved on the XMPP server')
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
86 self.duplicate_nickname = new_duplicate_nickname
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
87 if isinstance(self.xmpp_c, xmpp.client.Client):
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
88 self.bridge.bot.close_xmpp_connection(self.nickname)
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
89 self.xmpp_c = None
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
90 self.createDuplicateOnXMPP()
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
91 return
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
92
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
93 else:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
94 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the XMPP server', log=True)
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
95 if self.muc.connected == True:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
96 self.muc.leave('Changed nickname to "'+self.nickname+'"')
82
90baff5dedb2 Fixed callbacks in participant.py
Charly COSTE <changaco@changaco.net>
parents: 78
diff changeset
97 except xmpp.muc.RoomIsFull:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
98 self.bridge.say('[Warning] XMPP room is full', log=True)
135
922858915907 handle xmpp.muc.RemoteServerNotFound
Charly COSTE <changaco@changaco.net>
parents: 132
diff changeset
99 except xmpp.muc.RemoteServerNotFound:
922858915907 handle xmpp.muc.RemoteServerNotFound
Charly COSTE <changaco@changaco.net>
parents: 132
diff changeset
100 self.bridge._RemoteServerNotFound_handler()
98
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
101
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
102 if isinstance(self.xmpp_c, xmpp.client.Client):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
103 self.bridge.bot.close_xmpp_connection(self.nickname)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
104 self.xmpp_c = None
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
105
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
106
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
107 def createDuplicateOnIRC(self):
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
108 if isinstance(self.xmpp_c, xmpp.client.Client) or isinstance(self.irc_connection, ServerConnection):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
109 return
125
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
110 self.irc_connection = self.bridge.bot.irc.open_connection(self.bridge.irc_server, self.bridge.irc_port, self.duplicate_nickname)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
111 self.irc_connection.connect(nick_callback=self._irc_nick_callback)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
112
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
113
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
114 def _irc_nick_callback(self, error, arguments=[]):
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
115 if error == None:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
116 self.irc_connection.join(self.bridge.irc_room)
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
117 m = '===> Debug: "'+self.nickname+'" duplicate succesfully created on IRC side of bridge "'+str(self.bridge)+'"'
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
118 if self.nickname != self.duplicate_nickname:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
119 m += ' using nickname "'+self.duplicate_nickname+'"'
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
120 self.bridge.say('[Info] "'+self.nickname+'" will appear as "'+self.duplicate_nickname+'" on IRC because its real nickname is reserved or contains unauthorized characters')
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
121 self.bridge.bot.error(m, debug=True)
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
122
82
90baff5dedb2 Fixed callbacks in participant.py
Charly COSTE <changaco@changaco.net>
parents: 78
diff changeset
123 elif self.irc_connection != 'both':
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
124
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
125 if error in ['nicknameinuse', 'nickcollision']:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
126 if arguments[0].arguments()[0] != self.duplicate_nickname:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
127 return
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
128
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
129 if self.bridge.mode == 'bypass':
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
130 new_duplicate_nickname = self._get_new_duplicate_nickname()
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
131 if new_duplicate_nickname != None:
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
132 self.bridge.bot.error('===> Debug: "'+self.duplicate_nickname+'" is already used or reserved on the IRC server of bridge "'+str(self.bridge)+'", trying "'+new_duplicate_nickname+'"', debug=True)
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
133 if self.duplicate_nickname == self.nickname:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
134 self.bridge.say('[Info] The nickname "'+self.duplicate_nickname+'" is used or reserved on the IRC server')
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
135 self.duplicate_nickname = new_duplicate_nickname
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
136 if isinstance(self.irc_connection, ServerConnection):
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
137 self.irc_connection.close('')
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
138 self.irc_connection = error
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
139 self.createDuplicateOnIRC()
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
140 return
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
141
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
142 else:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
143 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used or reserved on the IRC server', log=True)
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
144
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
145 elif error == 'erroneusnickname':
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
146 if self.bridge.mode == 'bypass':
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
147 self.duplicate_nickname = re.sub('[^a-zA-Z]', '', self.nickname)
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
148 if isinstance(self.irc_connection, ServerConnection):
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
149 self.irc_connection.close('')
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
150 self.irc_connection = error
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
151 self.createDuplicateOnIRC()
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
152 return
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
153 else:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
154 self.bridge.say('[Warning] The nickname "'+self.nickname+'" contains unauthorized characters and cannot be used in the IRC channel', log=True)
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
155
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
156 elif error == 'nicknametoolong':
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
157 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is too long (limit seems to be '+str(arguments[0])+') and cannot be used in the IRC channel', log=True)
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
158
82
90baff5dedb2 Fixed callbacks in participant.py
Charly COSTE <changaco@changaco.net>
parents: 78
diff changeset
159 else:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
160 self.bridge.say('[Warning] unknown error while adding "'+self.nickname+'" to IRC side of bridge', log=True)
98
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
161
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
162 if isinstance(self.irc_connection, ServerConnection):
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
163 self.irc_connection.close('')
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
164 self.irc_connection = error
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
165
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
166
123
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
167 def set_both_sides(self):
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
168 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both sides of the bridge', log=True)
123
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
169 if isinstance(self.irc_connection, ServerConnection):
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
170 self.irc_connection.close('')
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
171 if self.irc_connection != 'both':
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
172 self.irc_connection = 'both'
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
173 if isinstance(self.muc, xmpp.muc):
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
174 self.muc.leave('')
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
175 self.bridge.bot.close_xmpp_connection(self.nickname)
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
176 if self.xmpp_c != 'both':
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
177 self.xmpp_c = 'both'
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
178
75a03f10a863 Code refactoring (new method participant.set_both_sides())
Charly COSTE <changaco@changaco.net>
parents: 118
diff changeset
179
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
180 def changeNickname(self, newnick, on_protocol):
29
a694ffe6a973 Fixed nickname change.
Charly COSTE <changaco@changaco.net>
parents: 26
diff changeset
181 """Change participant's nickname."""
a694ffe6a973 Fixed nickname change.
Charly COSTE <changaco@changaco.net>
parents: 26
diff changeset
182
145
ddc87b605019 minor fix in Participant.changeNickname()
Charly COSTE <changaco@changaco.net>
parents: 137
diff changeset
183 p = None
29
a694ffe6a973 Fixed nickname change.
Charly COSTE <changaco@changaco.net>
parents: 26
diff changeset
184 oldnick = self.nickname
a694ffe6a973 Fixed nickname change.
Charly COSTE <changaco@changaco.net>
parents: 26
diff changeset
185
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
186 if self.protocol == 'xmpp':
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
187 if on_protocol == 'xmpp':
94
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
188 self._close_irc_connection('unwanted nick change')
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
189 self.irc_connection = 'unwanted nick change'
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
190
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
191 else:
125
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
192 try:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
193 p = self.bridge.getParticipant(newnick)
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
194 except self.bridge.NoSuchParticipantException:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
195 self.nickname = newnick
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
196 self.duplicate_nickname = newnick
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
197 has_connection = self.bridge.bot.irc.has_connection(self.bridge.irc_server, self.bridge.irc_port, self.duplicate_nickname)
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
198 if isinstance(self.irc_connection, ServerConnection):
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
199 if not has_connection and self.irc_connection.used_by == 1:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
200 self.irc_connection.nick(newnick, callback=self._irc_nick_callback)
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
201 else:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
202 self._close_irc_connection('Changed nickname')
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
203 self.createDuplicateOnIRC()
98
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
204 else:
125
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
205 if self.irc_connection == 'both':
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
206 self.bridge.addParticipant('irc', oldnick)
98
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
207 self.createDuplicateOnIRC()
125
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
208 return
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
209
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
210 elif self.protocol == 'irc':
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
211 if on_protocol == 'irc':
94
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
212 self._close_xmpp_connection('unwanted nick change')
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
213 self.xmpp_c = 'unwanted nick change'
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
214
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
215 else:
125
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
216 try:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
217 p = self.bridge.getParticipant(newnick)
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
218 except self.bridge.NoSuchParticipantException:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
219 self.nickname = newnick
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
220 self.duplicate_nickname = newnick
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
221 if isinstance(self.xmpp_c, xmpp.client.Client):
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
222 for b in self.bridge.bot.bridges:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
223 if b.hasParticipant(oldnick) and b.irc_server != self.bridge.irc_server:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
224 self.muc.leave(message='Changed nickname to "'+self.nickname+'"')
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
225 self.xmpp_c = None
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
226 self.bridge.bot.close_xmpp_connection(oldnick)
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
227 self.createDuplicateOnXMPP()
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
228 return
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
229
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
230 if not self.bridge.bot.xmpp_connections.has_key(newnick):
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
231 if self.bridge.bot.xmpp_connections.has_key(oldnick):
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
232 self.bridge.bot.xmpp_connections.pop(oldnick)
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
233 self.bridge.bot.xmpp_connections[newnick] = self.xmpp_c
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
234
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
235 self.muc.change_nick(newnick, status='From IRC', callback=self._xmpp_join_callback)
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
236 else:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
237 if self.xmpp_c == 'both':
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
238 self.bridge.addParticipant('xmpp', oldnick)
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
239 self.createDuplicateOnXMPP()
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
240 return
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
241
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
242 self.nickname = newnick
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
243 self.duplicate_nickname = newnick
145
ddc87b605019 minor fix in Participant.changeNickname()
Charly COSTE <changaco@changaco.net>
parents: 137
diff changeset
244
ddc87b605019 minor fix in Participant.changeNickname()
Charly COSTE <changaco@changaco.net>
parents: 137
diff changeset
245 if not isinstance(p, Participant):
ddc87b605019 minor fix in Participant.changeNickname()
Charly COSTE <changaco@changaco.net>
parents: 137
diff changeset
246 return
ddc87b605019 minor fix in Participant.changeNickname()
Charly COSTE <changaco@changaco.net>
parents: 137
diff changeset
247
125
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
248 if p.nickname == newnick:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
249 if p.protocol == self.protocol:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
250 # should never happen
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
251 raise Exception('WTF ?')
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
252 else:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
253 self.set_both_sides()
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
254 elif p.duplicate_nickname == newnick:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
255 if p.protocol != self.protocol:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
256 # should never happen
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
257 raise Exception('WTF ?')
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
258 else:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
259 if self.protocol == 'xmpp':
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
260 self.irc_connection = p.irc_connection
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
261 p.irc_connection = None
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
262 else:
125
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
263 self.xmpp_c = p.xmpp_c
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
264 self.muc = p.muc
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
265 p.xmpp_c = None
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
266 p.muc = None
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
267 p.duplicate_nickname = p._get_new_duplicate_nickname()
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
268 p.createDuplicateOnXMPP()
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
269 else:
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
270 # should never happen
efdc038e757a fixed participant.changeNickname(), renamed IRC.server() to IRC.open_connection(), created IRC.get_connection() and IRC.has_connection(), removed irclib.SimpleIRCClient (we don't need it)
Charly COSTE <changaco@changaco.net>
parents: 124
diff changeset
271 raise Exception('WTF ?')
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
272
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
273
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
274 def sayOnIRC(self, message):
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
275 try:
95
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
276 bot_say = False
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
277 if message[:4] == '/me ':
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
278 action = True
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
279 message = message[4:]
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
280 else:
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
281 action = False
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
282 if isinstance(self.irc_connection, ServerConnection):
65
75604669fcd9 Some fault tolerance
Charly COSTE <changaco@changaco.net>
parents: 64
diff changeset
283 try:
95
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
284 if action:
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
285 self.irc_connection.action(self.bridge.irc_room, message)
73
fa291fd20480 Handle /me the XMPP to IRC way
Charly COSTE <changaco@changaco.net>
parents: 72
diff changeset
286 else:
fa291fd20480 Handle /me the XMPP to IRC way
Charly COSTE <changaco@changaco.net>
parents: 72
diff changeset
287 self.irc_connection.privmsg(self.bridge.irc_room, message)
65
75604669fcd9 Some fault tolerance
Charly COSTE <changaco@changaco.net>
parents: 64
diff changeset
288 except ServerNotConnectedError:
136
7dc6a1764c4f handle irclib.ServerNotConnectedError
Charly COSTE <changaco@changaco.net>
parents: 135
diff changeset
289 self.irc_connection.connect()
95
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
290 bot_say = True
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
291 elif not isinstance(self.xmpp_c, xmpp.client.Client):
95
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
292 bot_say = True
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
293 if bot_say:
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
294 if action:
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
295 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '* '+self.nickname+' '+message)
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
296 else:
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
297 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
298 except EncodingException:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
299 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding', log=True)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
300
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
301
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
302 def sayOnIRCTo(self, to, message):
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
303 if isinstance(self.irc_connection, ServerConnection):
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
304 try:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
305 self.irc_connection.privmsg(to, message)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
306 except EncodingException:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
307 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding', log=True)
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
308 elif not isinstance(self.xmpp_c, xmpp.client.Client):
26
1691ab4d131f Fixed participant's "say" functions.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
309 if self.bridge.mode != 'normal':
1691ab4d131f Fixed participant's "say" functions.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
310 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
1691ab4d131f Fixed participant's "say" functions.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
311 else:
1691ab4d131f Fixed participant's "say" functions.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
312 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.')
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
313
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
314
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
315 def sayOnXMPP(self, message):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
316 try:
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
317 if isinstance(self.xmpp_c, xmpp.client.Client):
172
64a0e9636ae6 removed encoding.py, charsets handling is now in irclib and custom charsets can be set per server in the configuration file
Charly COSTE <changaco@changaco.net>
parents: 150
diff changeset
318 self.muc.say(message)
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
319 elif not isinstance(self.irc_connection, ServerConnection):
95
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
320 if message[:4] == '/me ':
172
64a0e9636ae6 removed encoding.py, charsets handling is now in irclib and custom charsets can be set per server in the configuration file
Charly COSTE <changaco@changaco.net>
parents: 150
diff changeset
321 self.bridge.xmpp_room.say('* '+self.nickname+' '+message[4:])
95
f27de569f5db Improved /me handling
Charly COSTE <changaco@changaco.net>
parents: 94
diff changeset
322 else:
172
64a0e9636ae6 removed encoding.py, charsets handling is now in irclib and custom charsets can be set per server in the configuration file
Charly COSTE <changaco@changaco.net>
parents: 150
diff changeset
323 self.bridge.xmpp_room.say('<'+self.nickname+'> '+message)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
324 except EncodingException:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
325 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding', log=True)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
326
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
327
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
328 def sayOnXMPPTo(self, to, message):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
329 try:
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
330 if isinstance(self.xmpp_c, xmpp.client.Client):
172
64a0e9636ae6 removed encoding.py, charsets handling is now in irclib and custom charsets can be set per server in the configuration file
Charly COSTE <changaco@changaco.net>
parents: 150
diff changeset
331 self.muc.sayTo(to, message)
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
332 elif not isinstance(self.irc_connection, ServerConnection):
26
1691ab4d131f Fixed participant's "say" functions.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
333 if self.bridge.mode != 'normal':
1691ab4d131f Fixed participant's "say" functions.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
334 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
1691ab4d131f Fixed participant's "say" functions.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
335 else:
1691ab4d131f Fixed participant's "say" functions.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
336 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an XMPP duplicate with your nickname.')
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
337 except EncodingException:
137
9f39cead20cb reduced duplication of error messages
Charly COSTE <changaco@changaco.net>
parents: 136
diff changeset
338 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding', log=True)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
339
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
340
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
341 def leave(self, message):
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
342 if message == None:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
343 message = ''
94
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
344 self._close_xmpp_connection(message)
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
345 self._close_irc_connection(message)
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
346
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
347
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
348 def _close_xmpp_connection(self, message):
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
349 if isinstance(self.xmpp_c, xmpp.client.Client):
172
64a0e9636ae6 removed encoding.py, charsets handling is now in irclib and custom charsets can be set per server in the configuration file
Charly COSTE <changaco@changaco.net>
parents: 150
diff changeset
350 self.muc.leave(message)
132
6a6885dbed25 handle more mode changing cases (added bridge.createDuplicatesOn())
Charly COSTE <changaco@changaco.net>
parents: 125
diff changeset
351 self.xmpp_c = None
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
352 self.bridge.bot.close_xmpp_connection(self.nickname)
94
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
353
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
354
810a6bed6c9c Tried to fix participant.changeNickname
Charly COSTE <changaco@changaco.net>
parents: 86
diff changeset
355 def _close_irc_connection(self, message):
72
6c4b841144f6 Better handling of participants
Charly COSTE <changaco@changaco.net>
parents: 68
diff changeset
356 if isinstance(self.irc_connection, ServerConnection):
83
5115ba7d5983 Leave chan only if (really) connected
Charly COSTE <changaco@changaco.net>
parents: 82
diff changeset
357 if self.irc_connection.really_connected == True:
5115ba7d5983 Leave chan only if (really) connected
Charly COSTE <changaco@changaco.net>
parents: 82
diff changeset
358 self.irc_connection.part(self.bridge.irc_room, message=message)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
359 self.irc_connection.used_by -= 1
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
360 if self.irc_connection.used_by < 1:
64
8fc496eaa17b Handle IRC "nickcollision" event
Charly COSTE <changaco@changaco.net>
parents: 63
diff changeset
361 self.irc_connection.close(message)
5
cb0daec4b778 Added support for IRC "nick" event, fixed participant.changeNickname(), fixed handling of IRC "namreply" event, removed muc._check() because waiting does not solve the problem if it is blocking incoming messages handling
Charly COSTE <changaco@changaco.net>
parents: 4
diff changeset
362 self.irc_connection = None
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
363
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
364
98
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
365 def __str__(self):
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
366 r = 'self.protocol='+str(self.protocol)+'\n'+'self.nickname='+str(self.nickname)
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
367 if isinstance(self.irc_connection, ServerConnection):
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
368 r += '\nself.irc_connection='+str(self.irc_connection)+'\n'+'self.irc_connection.really_connected='+str(self.irc_connection.really_connected)
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
369 if isinstance(self.xmpp_c, xmpp.client.Client):
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
370 r += '\nself.muc.connected='+str(self.muc.connected)
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
371 return r
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
372
35e0ddf3b13c Code cleaning, participant.changeNickname improvement, added participant.__str__
Charly COSTE <changaco@changaco.net>
parents: 95
diff changeset
373
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
374 def __del__(self):
118
b29fd5696a78 new mode bypass and new method bridge.changeMode
Charly COSTE <changaco@changaco.net>
parents: 117
diff changeset
375 self.leave('')