annotate src/plugins/plugin_xep_0045.py @ 926:d609581bf74a

plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve: - registerTextCommands can be called by a plugin in its __init__ method, it looks for methods starting with "cmd_" and register them as new commands - addWhoIsCb: add a callback to /whois command, the callback can complete whois informations - plugins parrot, XEP-0045 and XEP-0092 now manage their own commands
author Goffi <goffi@goffi.org>
date Mon, 24 Mar 2014 10:57:15 +0100
parents 1a759096ccbd
children 73873e9b56f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
4 # SAT plugin for managing xep-0045
811
1fe00f0c9a91 dates update
Goffi <goffi@goffi.org>
parents: 801
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
10 # (at your option) any later version.
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
15 # GNU Affero General Public License for more details.
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 599
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 743
diff changeset
20 from sat.core.i18n import _
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
21 from sat.core.constants import Const as C
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from logging import debug, info, warning, error
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
23 from twisted.internet import defer
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
24 from twisted.words.protocols.jabber import jid
505
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
25
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
26 from sat.core import exceptions
801
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
27 from sat.memory import memory
505
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
28
319
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
29 import uuid
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
31 from wokkel import muc
801
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
32 from sat.tools import xml_tools
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
33
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
34
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
35 try:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from twisted.words.protocols.xmlstream import XMPPHandler
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37 except ImportError:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38 from wokkel.subprotocols import XMPPHandler
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
40 PLUGIN_INFO = {
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
41 "name": "XEP 0045 Plugin",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
42 "import_name": "XEP-0045",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
43 "type": "XEP",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
44 "protocols": ["XEP-0045"],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
45 "dependencies": [],
926
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
46 "recommendations": [C.TEXT_CMDS],
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
47 "main": "XEP_0045",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
48 "handler": "yes",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
49 "description": _("""Implementation of Multi-User Chat""")
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
50 }
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
51
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
52
505
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
53 class UnknownRoom(Exception):
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
54 pass
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
55
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
56
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
57 class XEP_0045(object):
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
59 def __init__(self, host):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
60 info(_("Plugin XEP_0045 initialization"))
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
61 self.host = host
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
62 self.clients = {}
801
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
63 self._sessions = memory.Sessions()
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
64 host.bridge.addMethod("joinMUC", ".plugin", in_sign='ssa{ss}s', out_sign='s', method=self._join)
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
65 host.bridge.addMethod("mucNick", ".plugin", in_sign='sss', out_sign='', method=self.mucNick)
801
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
66 host.bridge.addMethod("mucLeave", ".plugin", in_sign='ss', out_sign='', method=self.mucLeave, async=True)
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
67 host.bridge.addMethod("getRoomsJoined", ".plugin", in_sign='s', out_sign='a(sass)', method=self.getRoomsJoined)
450
afe9cfd2ddbb plugins: radio collective first draft
Goffi <goffi@goffi.org>
parents: 409
diff changeset
68 host.bridge.addMethod("getRoomsSubjects", ".plugin", in_sign='s', out_sign='a(ss)', method=self.getRoomsSubjects)
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
69 host.bridge.addMethod("getUniqueRoomName", ".plugin", in_sign='ss', out_sign='s', method=self.getUniqueName)
801
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
70 host.bridge.addMethod("configureRoom", ".plugin", in_sign='ss', out_sign='s', method=self._configureRoom, async=True)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
71 host.bridge.addSignal("roomJoined", ".plugin", signature='sasss') # args: room_jid, room_nicks, user_nick, profile
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
72 host.bridge.addSignal("roomLeft", ".plugin", signature='ss') # args: room_jid, profile
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
73 host.bridge.addSignal("roomUserJoined", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
74 host.bridge.addSignal("roomUserLeft", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
75 host.bridge.addSignal("roomUserChangedNick", ".plugin", signature='ssss') # args: room_jid, old_nick, new_nick, profile
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
76 host.bridge.addSignal("roomNewSubject", ".plugin", signature='sss') # args: room_jid, subject, profile
801
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
77 self.__submit_conf_id = host.registerCallback(self._submitConfiguration, with_data=True)
926
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
78 try:
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
79 self.host.plugins[C.TEXT_CMDS].registerTextCommands(self)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
80 except KeyError:
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
81 info(_("Text commands not available"))
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
82
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
83 def __check_profile(self, profile):
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 74
diff changeset
84 """check if profile is used and connected
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 74
diff changeset
85 if profile known but disconnected, remove it from known profiles
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 74
diff changeset
86 @param profile: profile to check
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 74
diff changeset
87 @return: True if the profile is known and connected, else False"""
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
88 if not profile or profile not in self.clients or not self.host.isConnected(profile):
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
89 error(_('Unknown or disconnected profile (%s)') % profile)
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
90 if profile in self.clients:
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
91 del self.clients[profile]
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
92 return False
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
93 return True
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
94
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
95 def __room_joined(self, room, profile):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
96 """Called when the user is in the requested room"""
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
97
319
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
98 def _sendBridgeSignal(ignore=None):
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
99 self.host.bridge.roomJoined(room.roomJID.userhost(), [user.nick for user in room.roster.values()], room.nick, profile)
319
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
100
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
101 room_jid_s = room.roomJID.userhost()
488
6edb4219fcf7 plugin xep-0045: entity type is changer to chatroom for room joined
Goffi <goffi@goffi.org>
parents: 480
diff changeset
102 self.host.memory.updateEntityData(room.roomJID, "type", "chatroom", profile)
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
103 self.clients[profile].joined_rooms[room_jid_s] = room
452
fd455b3ca6d4 plugin XEP-0045: room unlocking fix
Goffi <goffi@goffi.org>
parents: 451
diff changeset
104 if room.locked:
319
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
105 #FIXME: the current behaviour is to create an instant room
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
106 #and send the signal only when the room is unlocked
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
107 #a proper configuration management should be done
452
fd455b3ca6d4 plugin XEP-0045: room unlocking fix
Goffi <goffi@goffi.org>
parents: 451
diff changeset
108 print "room locked !"
fd455b3ca6d4 plugin XEP-0045: room unlocking fix
Goffi <goffi@goffi.org>
parents: 451
diff changeset
109 self.clients[profile].configure(room.roomJID, {}).addCallbacks(_sendBridgeSignal, lambda x: error(_('Error while configuring the room')))
319
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
110 else:
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
111 _sendBridgeSignal()
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
112 return room
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
113
528
f899f6e2a9d1 plugin XEP-0045: in case of nickname conflict when entering a room, a new one is automaticaly assigned
Goffi <goffi@goffi.org>
parents: 522
diff changeset
114 def __err_joining_room(self, failure, room_jid, nick, history_options, password, profile):
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
115 """Called when something is going wrong when joining the room"""
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
116 if hasattr(failure.value, "condition") and failure.value.condition == 'conflict':
528
f899f6e2a9d1 plugin XEP-0045: in case of nickname conflict when entering a room, a new one is automaticaly assigned
Goffi <goffi@goffi.org>
parents: 522
diff changeset
117 # we have a nickname conflict, we try again with "_" suffixed to current nickname
f899f6e2a9d1 plugin XEP-0045: in case of nickname conflict when entering a room, a new one is automaticaly assigned
Goffi <goffi@goffi.org>
parents: 522
diff changeset
118 nick += '_'
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
119 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile])
743
5a131930348d plugin XEP-0045: remove redondant errback from _join
souliane <souliane@mailoo.org>
parents: 742
diff changeset
120 mess = _("Error while joining the room %s" % room_jid.userhost())
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
121 error(mess)
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 134
diff changeset
122 self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile)
450
afe9cfd2ddbb plugins: radio collective first draft
Goffi <goffi@goffi.org>
parents: 409
diff changeset
123 raise failure
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
124
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
125 def getRoomsJoined(self, profile_key=C.PROF_KEY_NONE):
78
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
126 """Return room where user is"""
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
127 profile = self.host.memory.getProfileName(profile_key)
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
128 result = []
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
129 if not self.__check_profile(profile):
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
130 return result
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
131 for room in self.clients[profile].joined_rooms.values():
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
132 result.append((room.roomJID.userhost(), [user.nick for user in room.roster.values()], room.nick))
78
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
133 return result
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
134
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
135 def getRoomNick(self, room_jid_s, profile_key=C.PROF_KEY_NONE):
93
2f87651a5ad8 Tarot game: basic trick
Goffi <goffi@goffi.org>
parents: 91
diff changeset
136 """return nick used in room by user
509
64ff046dc201 plugin text commands: added /join command
Goffi <goffi@goffi.org>
parents: 507
diff changeset
137 @param room_jid_s: unicode room id
93
2f87651a5ad8 Tarot game: basic trick
Goffi <goffi@goffi.org>
parents: 91
diff changeset
138 @profile_key: profile
2f87651a5ad8 Tarot game: basic trick
Goffi <goffi@goffi.org>
parents: 91
diff changeset
139 @return: nick or empty string in case of error"""
2f87651a5ad8 Tarot game: basic trick
Goffi <goffi@goffi.org>
parents: 91
diff changeset
140 profile = self.host.memory.getProfileName(profile_key)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
141 if not self.__check_profile(profile) or room_jid_s not in self.clients[profile].joined_rooms:
93
2f87651a5ad8 Tarot game: basic trick
Goffi <goffi@goffi.org>
parents: 91
diff changeset
142 return ''
509
64ff046dc201 plugin text commands: added /join command
Goffi <goffi@goffi.org>
parents: 507
diff changeset
143 return self.clients[profile].joined_rooms[room_jid_s].nick
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
144
715
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
145 def getRoomNickOfUser(self, room, user_jid, secure=True):
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
146 """Returns the nick of the given user in the room.
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
147 @room: instance of wokkel.muc.Room
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
148 @user: JID or unicode (JID userhost).
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
149 @param secure: set to True for a secure check
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
150 @return: the nick or None if the user didn't join the room.
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
151 """
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
152 if not isinstance(user_jid, jid.JID):
791
23b0c949b86c plugins room games, XEP-0045: small fixes, improved docstrings
souliane <souliane@mailoo.org>
parents: 771
diff changeset
153 user_jid = jid.JID(user_jid).userhostJID()
715
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
154 for user in room.roster.values():
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
155 if user.entity is not None:
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
156 if user.entity.userhostJID() == user_jid.userhostJID():
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
157 return user.nick
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
158 elif not secure:
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
159 # FIXME: this is NOT ENOUGH to check an identity!!
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
160 # See in which conditions user.entity could be None.
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
161 if user.nick == user_jid.user:
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
162 return user.nick
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
163 return None
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
164
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
165 def getRoomNicksOfUsers(self, room, users=[], secure=True):
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
166 """Returns the nicks of the given users in the room.
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
167 @room: instance of wokkel.muc.Room
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
168 @users: list of JID or unicode (JID userhost).
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
169 @param secure: set to True for a secure check
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
170 @return: (x, y) with x a list containing the nicks of
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
171 the users who are in the room, and y the missing users.
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
172 """
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
173 nicks = []
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
174 missing = []
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
175 for user in users:
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
176 nick = self.getRoomNickOfUser(room, user, secure)
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
177 if nick is None:
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
178 missing.append(user)
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
179 else:
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
180 nicks.append(nick)
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
181 return nicks, missing
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
182
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
183 def _configureRoom(self, room_jid_s, profile_key=C.PROF_KEY_NONE):
801
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
184 d = self.configureRoom(jid.JID(room_jid_s), profile_key)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
185 d.addCallback(lambda xmlui: xmlui.toXml())
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
186 return d
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
187
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
188 def configureRoom(self, room_jid, profile_key=C.PROF_KEY_NONE):
801
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
189 """ return the room configuration form
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
190 @param room: jid of the room to configure
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
191 @param profile_key: %(doc_profile_key)s
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
192 @return: configuration form as XMLUI
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
193
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
194 """
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
195 profile = self.host.memory.getProfileName(profile_key)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
196 if not self.__check_profile(profile):
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
197 raise exceptions.ProfileUnknownError("Unknown or disconnected profile")
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
198 if room_jid.userhost() not in self.clients[profile].joined_rooms:
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
199 raise UnknownRoom("This room has not been joined")
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
200
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
201 def config2XMLUI(result):
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
202 if not result:
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
203 return ""
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
204 session_id, session_data = self._sessions.newSession(profile=profile)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
205 session_data["room_jid"] = room_jid
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
206 xmlui = xml_tools.dataForm2XMLUI(result, submit_id=self.__submit_conf_id)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
207 xmlui.session_id = session_id
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
208 return xmlui
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
209
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
210 d = self.clients[profile].getConfiguration(room_jid)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
211 d.addCallback(config2XMLUI)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
212 return d
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
213
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
214 def _submitConfiguration(self, raw_data, profile):
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
215 try:
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
216 session_data = self._sessions.profileGet(raw_data["session_id"], profile)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
217 except KeyError:
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
218 warning ("session id doesn't exist, session has probably expired")
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
219 # TODO: send error dialog
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
220 return defer.succeed({})
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
221
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
222 data = xml_tools.XMLUIResult2DataFormResult(raw_data)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
223 d = self.clients[profile].configure(session_data['room_jid'], data)
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
224 d.addCallback(lambda ignore: {})
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
225 del self._sessions[raw_data["session_id"]]
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
226 return d
02ee9ef95277 plugin XEP-0045, primitivus: added MUC configuration
Goffi <goffi@goffi.org>
parents: 791
diff changeset
227
522
3446ce33247d plugin XEP-0045: added isNickInRoom method
Goffi <goffi@goffi.org>
parents: 519
diff changeset
228 def isNickInRoom(self, room_jid, nick, profile):
3446ce33247d plugin XEP-0045: added isNickInRoom method
Goffi <goffi@goffi.org>
parents: 519
diff changeset
229 """Tell if a nick is currently present in a room"""
528
f899f6e2a9d1 plugin XEP-0045: in case of nickname conflict when entering a room, a new one is automaticaly assigned
Goffi <goffi@goffi.org>
parents: 522
diff changeset
230 profile = self.host.memory.getProfileName(profile)
522
3446ce33247d plugin XEP-0045: added isNickInRoom method
Goffi <goffi@goffi.org>
parents: 519
diff changeset
231 if not self.__check_profile(profile):
713
8bd63daecdbf plugin XEP-0045: fixed incorrect exceptions name
souliane <souliane@mailoo.org>
parents: 712
diff changeset
232 raise exceptions.ProfileUnknownError("Unknown or disconnected profile")
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
233 if room_jid.userhost() not in self.clients[profile].joined_rooms:
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
234 raise UnknownRoom("This room has not been joined")
599
8d8a2ad163e2 plugin XEP-0045: fixed isNickInRoom
Goffi <goffi@goffi.org>
parents: 596
diff changeset
235 return self.clients[profile].joined_rooms[room_jid.userhost()].inRoster(muc.User(nick))
93
2f87651a5ad8 Tarot game: basic trick
Goffi <goffi@goffi.org>
parents: 91
diff changeset
236
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
237 def getRoomsSubjects(self, profile_key=C.PROF_KEY_NONE):
78
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
238 """Return received subjects of rooms"""
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
239 profile = self.host.memory.getProfileName(profile_key)
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
240 if not self.__check_profile(profile):
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
241 return []
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
242 return self.clients[profile].rec_subjects.values()
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
243
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
244 def getMUCService(self, profile):
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
245 """Return the MUC service or None"""
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
246 muc_service = None
742
03744d9ebc13 plugin XEP-0033: implementation of the addressing feature:
souliane <souliane@mailoo.org>
parents: 715
diff changeset
247 for service in self.host.memory.getServerServiceEntities("conference", "text", profile=profile):
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
248 if not ".irc." in service.userhost():
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
249 #FIXME:
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
250 #This awfull ugly hack is here to avoid an issue with openfire: the irc gateway
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
251 #use "conference/text" identity (instead of "conference/irc"), there is certainly a better way
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
252 #to manage this, but this hack fill do it for test purpose
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
253 muc_service = service
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
254 break
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
255 return muc_service
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
256
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
257 def getUniqueName(self, muc_service="", profile_key=C.PROF_KEY_NONE):
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
258 """Return unique name for room, avoiding collision
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
259 @param muc_service: leave empty string to use the default service
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
260 @return: unique room userhost, or '' if an error occured.
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
261 """
319
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
262 #TODO: we should use #RFC-0045 10.1.4 when available here
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
263 profile = self.host.memory.getProfileName(profile_key)
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
264 if not profile:
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
265 error(_("Unknown profile"))
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
266 return ""
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
267 room_name = uuid.uuid1()
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
268 print "\n\n===> room_name:", room_name
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
269 if muc_service == "":
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
270 muc_service = self.getMUCService(profile)
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
271 if not muc_service:
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
272 error(_("Can't find a MUC service"))
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
273 return ""
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
274 muc_service = muc_service.userhost()
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
275 return "%s@%s" % (room_name, muc_service)
319
5bb1cfc105d0 plugin xep-0045: misc improvments
Goffi <goffi@goffi.org>
parents: 291
diff changeset
276
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
277 def join(self, room_jid, nick, options, profile_key=C.PROF_KEY_NONE):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
278 def _errDeferred(exc_obj=Exception, txt='Error while joining room'):
350
abe08fcb42d7 plugin XEP-0045: added error callback to join's deferred, and a callback is created if join fail before calling MUCClient's join
Goffi <goffi@goffi.org>
parents: 319
diff changeset
279 d = defer.Deferred()
abe08fcb42d7 plugin XEP-0045: added error callback to join's deferred, and a callback is created if join fail before calling MUCClient's join
Goffi <goffi@goffi.org>
parents: 319
diff changeset
280 d.errback(exc_obj(txt))
451
4f196e2d3781 plugin xep-0045: fixed missing return deferred
Goffi <goffi@goffi.org>
parents: 450
diff changeset
281 return d
350
abe08fcb42d7 plugin XEP-0045: added error callback to join's deferred, and a callback is created if join fail before calling MUCClient's join
Goffi <goffi@goffi.org>
parents: 319
diff changeset
282
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
283 profile = self.host.memory.getProfileName(profile_key)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
284 if not self.__check_profile(profile):
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
285 return _errDeferred()
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
286 if room_jid.userhost() in self.clients[profile].joined_rooms:
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
287 warning(_('%(profile)s is already in room %(room_jid)s') % {'profile': profile, 'room_jid': room_jid.userhost()})
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
288 return _errDeferred()
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
289 info(_("[%(profile)s] is joining room %(room)s with nick %(nick)s") % {'profile': profile, 'room': room_jid.userhost(), 'nick': nick})
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
290
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
291 history_options = options["history"] == "True" if "history" in options else None
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
292 password = options["password"] if "password" in options else None
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
293
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
294 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile])
743
5a131930348d plugin XEP-0045: remove redondant errback from _join
souliane <souliane@mailoo.org>
parents: 742
diff changeset
295 # FIXME: how to set the cancel method on the Deferred created by wokkel?
5a131930348d plugin XEP-0045: remove redondant errback from _join
souliane <souliane@mailoo.org>
parents: 742
diff changeset
296 # This happens when the room is not reachable, e.g. no internet connection:
5a131930348d plugin XEP-0045: remove redondant errback from _join
souliane <souliane@mailoo.org>
parents: 742
diff changeset
297 # > /usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py(480)_startRunCallbacks()
5a131930348d plugin XEP-0045: remove redondant errback from _join
souliane <souliane@mailoo.org>
parents: 742
diff changeset
298 # -> raise AlreadyCalledError(extra)
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
299
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
300 def _join(self, room_jid_s, nick, options={}, profile_key=C.PROF_KEY_NONE):
743
5a131930348d plugin XEP-0045: remove redondant errback from _join
souliane <souliane@mailoo.org>
parents: 742
diff changeset
301 """join method used by bridge: use the join method, but doesn't return any deferred
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
302 @return the room userhost (given value or unique generated name)
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
303 """
406
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
304 profile = self.host.memory.getProfileName(profile_key)
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
305 if not self.__check_profile(profile):
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
306 return
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
307 if room_jid_s == "":
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
308 room_jid_s = self.getUniqueName(profile_key=profile_key)
406
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
309 try:
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
310 room_jid = jid.JID(room_jid_s)
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
311 except:
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
312 mess = _("Invalid room jid: %s") % room_jid_s
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
313 warning(mess)
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
314 self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile)
b03b38b20c18 plugin XEP-0045: send error on invalid room jid on _join
Goffi <goffi@goffi.org>
parents: 405
diff changeset
315 return
407
b4edea06ae12 plugin XEP-0045: fix method call
Goffi <goffi@goffi.org>
parents: 406
diff changeset
316 d = self.join(room_jid, nick, options, profile)
743
5a131930348d plugin XEP-0045: remove redondant errback from _join
souliane <souliane@mailoo.org>
parents: 742
diff changeset
317 # TODO: error management + signal in bridge
712
f610864eb7a5 plugins (MUC, tools, games): generalize the generation of a unique room name when joining a MUC and no room is specified:
souliane <souliane@mailoo.org>
parents: 609
diff changeset
318 return room_jid_s
505
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
319
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
320 def nick(self, room_jid, nick, profile_key):
505
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
321 profile = self.host.memory.getProfileName(profile_key)
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
322 if not self.__check_profile(profile):
713
8bd63daecdbf plugin XEP-0045: fixed incorrect exceptions name
souliane <souliane@mailoo.org>
parents: 712
diff changeset
323 raise exceptions.ProfileUnknownError("Unknown or disconnected profile")
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
324 if room_jid.userhost() not in self.clients[profile].joined_rooms:
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
325 raise UnknownRoom("This room has not been joined")
505
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
326 return self.clients[profile].nick(room_jid, nick)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
327
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
328 def leave(self, room_jid, profile_key):
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
329 profile = self.host.memory.getProfileName(profile_key)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
330 if not self.__check_profile(profile):
713
8bd63daecdbf plugin XEP-0045: fixed incorrect exceptions name
souliane <souliane@mailoo.org>
parents: 712
diff changeset
331 raise exceptions.ProfileUnknownError("Unknown or disconnected profile")
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
332 if room_jid.userhost() not in self.clients[profile].joined_rooms:
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
333 raise UnknownRoom("This room has not been joined")
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
334 return self.clients[profile].leave(room_jid)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
335
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
336 def subject(self, room_jid, subject, profile_key):
515
29b5ef129488 plugin XEP-0045, plugin text commands: added '/title' command
Goffi <goffi@goffi.org>
parents: 509
diff changeset
337 profile = self.host.memory.getProfileName(profile_key)
29b5ef129488 plugin XEP-0045, plugin text commands: added '/title' command
Goffi <goffi@goffi.org>
parents: 509
diff changeset
338 if not self.__check_profile(profile):
713
8bd63daecdbf plugin XEP-0045: fixed incorrect exceptions name
souliane <souliane@mailoo.org>
parents: 712
diff changeset
339 raise exceptions.ProfileUnknownError("Unknown or disconnected profile")
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
340 if room_jid.userhost() not in self.clients[profile].joined_rooms:
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
341 raise UnknownRoom("This room has not been joined")
515
29b5ef129488 plugin XEP-0045, plugin text commands: added '/title' command
Goffi <goffi@goffi.org>
parents: 509
diff changeset
342 return self.clients[profile].subject(room_jid, subject)
29b5ef129488 plugin XEP-0045, plugin text commands: added '/title' command
Goffi <goffi@goffi.org>
parents: 509
diff changeset
343
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
344 def mucNick(self, room_jid_s, nick, profile_key=C.PROF_KEY_NONE):
505
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
345 """Change nickname in a room"""
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
346 return self.nick(jid.JID(room_jid_s), nick, profile_key)
2402668b5d05 plugin xep-0045: nick change management
Goffi <goffi@goffi.org>
parents: 488
diff changeset
347
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 811
diff changeset
348 def mucLeave(self, room_jid_s, profile_key=C.PROF_KEY_NONE):
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
349 """Leave a room"""
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
350 return self.leave(jid.JID(room_jid_s), profile_key)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
351
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
352 def getHandler(self, profile):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
353 self.clients[profile] = SatMUCClient(self)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
354 return self.clients[profile]
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
355
926
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
356 # Text commands #
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
357
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
358 def cmd_nick(self, mess_data, profile):
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
359 """change nickname"""
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
360 debug("Catched nick command")
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
361
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
362 if mess_data['type'] != "groupchat":
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
363 #/nick command does nothing if we are not on a group chat
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
364 info("Ignoring /nick command on a non groupchat message")
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
365
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
366 return True
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
367
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
368 nick = mess_data["unparsed"].strip()
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
369 room = mess_data["to"]
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
370
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
371 self.nick(room, nick, profile)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
372
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
373 return False
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
374
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
375 def cmd_join(self, mess_data, profile):
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
376 """join a new room (on the same service if full jid is not specified)"""
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
377 debug("Catched join command")
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
378
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
379 if mess_data['type'] != "groupchat":
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
380 #/leave command does nothing if we are not on a group chat
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
381 info("Ignoring /join command on a non groupchat message")
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
382 return True
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
383
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
384 if mess_data["unparsed"].strip():
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
385 room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
386 nick = (self.getRoomNick(mess_data["to"].userhost(), profile) or
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
387 self.host.getClient(profile).jid.user)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
388 self.join(room, nick, {}, profile)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
389
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
390 return False
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
391
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
392 def cmd_leave(self, mess_data, profile):
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
393 """quit a room"""
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
394 debug("Catched leave command")
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
395
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
396 if mess_data['type'] != "groupchat":
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
397 #/leave command does nothing if we are not on a group chat
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
398 info("Ignoring /leave command on a non groupchat message")
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
399 return True
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
400
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
401 if mess_data["unparsed"].strip():
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
402 room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
403 else:
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
404 room = mess_data["to"]
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
405
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
406 self.leave(room, profile)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
407
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
408 return False
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
409
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
410 def cmd_part(self, mess_data, profile):
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
411 """just a synonym of /leave"""
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
412 return self.cmd_leave(mess_data, profile)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
413
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
414 def cmd_title(self, mess_data, profile):
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
415 """change room's subject"""
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
416 debug("Catched title command")
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
417
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
418 if mess_data['type'] != "groupchat":
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
419 #/leave command does nothing if we are not on a group chat
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
420 info("Ignoring /title command on a non groupchat message")
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
421 return True
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
422
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
423 subject = mess_data["unparsed"].strip()
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
424
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
425 if subject:
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
426 room = mess_data["to"]
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
427 self.subject(room, subject, profile)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
428
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
429 return False
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
430
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
431 def cmd_topic(self, mess_data, profile):
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
432 """just a synonym of /title"""
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
433 return self.cmd_title(mess_data, profile)
d609581bf74a plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
434
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
435
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
436 class SatMUCClient (muc.MUCClient):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
437 #implements(iwokkel.IDisco)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
438
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
439 def __init__(self, plugin_parent):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
440 self.plugin_parent = plugin_parent
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
441 self.host = plugin_parent.host
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
442 muc.MUCClient.__init__(self)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
443 self.joined_rooms = {} # FIXME: seem to do the same thing as MUCClient's _rooms attribute, must be removed
78
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
444 self.rec_subjects = {}
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
445 self.__changing_nicks = set() # used to keep trace of who is changing nick,
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
446 # and to discard userJoinedRoom signal in this case
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
447 print "init SatMUCClient OK"
515
29b5ef129488 plugin XEP-0045, plugin text commands: added '/title' command
Goffi <goffi@goffi.org>
parents: 509
diff changeset
448
29b5ef129488 plugin XEP-0045, plugin text commands: added '/title' command
Goffi <goffi@goffi.org>
parents: 509
diff changeset
449 def subject(self, room, subject):
29b5ef129488 plugin XEP-0045, plugin text commands: added '/title' command
Goffi <goffi@goffi.org>
parents: 509
diff changeset
450 return muc.MUCClientProtocol.subject(self, room, subject)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
451
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
452 def unavailableReceived(self, presence):
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
453 #XXX: we override this method to manage nickname change
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
454 #TODO: feed this back to Wokkel
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
455 """
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
456 Unavailable presence was received.
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
457
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
458 If this was received from a MUC room occupant JID, that occupant has
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
459 left the room.
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
460 """
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
461 room, user = self._getRoomUser(presence)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
462
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
463 if room is None or user is None:
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
464 return
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
465
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
466 room.removeUser(user)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
467
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
468 if muc.STATUS_CODE.NEW_NICK in presence.mucStatuses:
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
469 self.__changing_nicks.add(presence.nick)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
470 self.userChangedNick(room, user, presence.nick)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
471 else:
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
472 self.__changing_nicks.discard(presence.nick)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
473 self.userLeftRoom(room, user)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
474
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
475 def receivedGroupChat(self, room, user, body):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
476 debug('receivedGroupChat: room=%s user=%s body=%s', room, user, body)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
477
74
6e3a06b4dd36 plugin xep-0045: added roomUserJoined and roomUserLeft signals
Goffi <goffi@goffi.org>
parents: 73
diff changeset
478 def userJoinedRoom(self, room, user):
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
479 if user.nick in self.__changing_nicks:
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
480 self.__changing_nicks.remove(user.nick)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
481 else:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
482 debug(_("user %(nick)s has joined room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()})
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
483 if not self.host.trigger.point("MUC user joined", room, user, self.parent.profile):
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
484 return
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
485 user_data = {'entity': user.entity.full() if user.entity else '', 'affiliation': user.affiliation, 'role': user.role}
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
486 self.host.bridge.roomUserJoined(room.roomJID.userhost(), user.nick, user_data, self.parent.profile)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
487
74
6e3a06b4dd36 plugin xep-0045: added roomUserJoined and roomUserLeft signals
Goffi <goffi@goffi.org>
parents: 73
diff changeset
488 def userLeftRoom(self, room, user):
715
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
489 if not self.host.trigger.point("MUC user left", room, user, self.parent.profile):
f47d7c09c60b plugins XEP-0045: added methods to get room nicks and "MUC user left" trigger
souliane <souliane@mailoo.org>
parents: 713
diff changeset
490 return
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
491 if user.nick == room.nick:
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
492 # we left the room
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
493 room_jid_s = room.roomJID.userhost()
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
494 info(_("Room [%(room)s] left (%(profile)s))") % {"room": room_jid_s,
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
495 "profile": self.parent.profile})
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
496 self.host.memory.delEntityCache(room.roomJID, self.parent.profile)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
497 del self.plugin_parent.clients[self.parent.profile].joined_rooms[room_jid_s]
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
498 self.host.bridge.roomLeft(room.roomJID.userhost(), self.parent.profile)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
499 else:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
500 debug(_("user %(nick)s left room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()})
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
501 user_data = {'entity': user.entity.full() if user.entity else '', 'affiliation': user.affiliation, 'role': user.role}
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
502 self.host.bridge.roomUserLeft(room.roomJID.userhost(), user.nick, user_data, self.parent.profile)
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
503
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 505
diff changeset
504 def userChangedNick(self, room, user, new_nick):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
505 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
506
77
1ae680f9682e wix: MUC groupchat management + short nick shown in chat window instead of full jid when possible
Goffi <goffi@goffi.org>
parents: 76
diff changeset
507 def userUpdatedStatus(self, room, user, show, status):
1ae680f9682e wix: MUC groupchat management + short nick shown in chat window instead of full jid when possible
Goffi <goffi@goffi.org>
parents: 76
diff changeset
508 print("FIXME: MUC status not managed yet")
522
3446ce33247d plugin XEP-0045: added isNickInRoom method
Goffi <goffi@goffi.org>
parents: 519
diff changeset
509 #FIXME:
77
1ae680f9682e wix: MUC groupchat management + short nick shown in chat window instead of full jid when possible
Goffi <goffi@goffi.org>
parents: 76
diff changeset
510
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
511 def receivedSubject(self, room, user, subject):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
512 debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject})
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
513 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject)
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 372
diff changeset
514 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile)