Commit f601ca0d authored by Philipp Hörist's avatar Philipp Hörist

Add dedicated announce/motd module

parent 9dbac0f0
Pipeline #3508 passed with stages
in 3 minutes and 19 seconds
......@@ -277,9 +277,7 @@ def on_update_motd(action, param):
def on_delete_motd(action, param):
account = param.get_string()
server = app.config.get_per('accounts', account, 'hostname')
server += '/announce/motd/delete'
app.connections[account].send_motd(server)
app.connections[account].get_module('Announce').delete_motd()
# Help Actions
......
......@@ -1566,14 +1566,6 @@ class Connection(CommonConnection, ConnectionHandlers):
app.nec.push_incoming_event(OurShowEvent(None, conn=self,
show=show))
def send_motd(self, jid, subject='', msg='', xhtml=None):
if not app.account_is_connected(self.name):
return
msg_iq = nbxmpp.Message(to=jid, body=msg, subject=subject,
xhtml=xhtml)
self.connection.send(msg_iq)
def _nec_message_outgoing(self, obj):
if obj.account != self.name:
return
......
......@@ -73,6 +73,7 @@ MODULES = [
'user_tune',
'vcard_avatars',
'vcard_temp',
'announce',
]
_imported_modules = [] # type: List[tuple]
......
# This file is part of Gajim.
#
# Gajim is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 only.
#
# Gajim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
# Server MOTD and Announce
import nbxmpp
from gajim.common.modules.base import BaseModule
class Announce(BaseModule):
def __init__(self, con):
BaseModule.__init__(self, con)
def delete_motd(self):
server = self._con.get_own_jid().getDomain()
jid = '%s/announce/motd/delete' % server
self.set_announce(jid)
def set_announce(self, jid, subject=None, body=None):
message = nbxmpp.Message(to=jid, body=body, subject=subject)
self._nbxmpp().send(message)
def get_instance(*args, **kwargs):
return Announce(*args, **kwargs), 'Announce'
......@@ -308,8 +308,9 @@ class SingleMessageWindow(Gtk.ApplicationWindow):
return True
if '/announce/' in to_whom_jid:
app.connections[self.account].send_motd(to_whom_jid, subject,
message)
con = app.connections[self.account]
con.get_module('Announce').set_announce(
to_whom_jid, subject, message)
continue
recipient_list.append(to_whom_jid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment