Reimplemeted the /dtmf command
This commit is contained in:
parent
6a50a96be2
commit
d9c7fca2de
|
@ -182,4 +182,11 @@ class CommandTools:
|
||||||
"""
|
"""
|
||||||
Get the current connection object.
|
Get the current connection object.
|
||||||
"""
|
"""
|
||||||
return gajim.connections[self.account]
|
return gajim.connections[self.account]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def full_jid(self):
|
||||||
|
"""
|
||||||
|
Get a full JID of the contact.
|
||||||
|
"""
|
||||||
|
return self.contact.get_full_jid()
|
|
@ -181,19 +181,17 @@ class StandardCommonChatCommands(CommandContainer):
|
||||||
gajim.connections[self.account].sendPing(self.contact)
|
gajim.connections[self.account].sendPing(self.contact)
|
||||||
|
|
||||||
@command
|
@command
|
||||||
@doc(_("Send DTMF events through an open audio session"))
|
@doc(_("Send DTMF sequence through an open audio session"))
|
||||||
def dtmf(self, events):
|
def dtmf(self, sequence):
|
||||||
if not self.audio_sid:
|
if not self.audio_sid:
|
||||||
raise CommandError(_("There is no open audio session with this contact"))
|
raise CommandError(_("No open audio sessions with the contact"))
|
||||||
# Valid values for DTMF tones are *, # or a number.
|
for tone in sequence:
|
||||||
events = [e for e in events if e in ('*', '#') or e.isdigit()]
|
if not (tone in ("*", "#") or tone.isdigit()):
|
||||||
if events:
|
raise CommandError(_("%s is not a valid tone") % tone)
|
||||||
session = gajim.connections[self.account].get_jingle_session(
|
gjs = self.connection.get_jingle_session
|
||||||
self.contact.get_full_jid(), self.audio_sid)
|
session = gjs(self.full_jid, self.audio_sid)
|
||||||
content = session.get_content('audio')
|
content = session.get_content("audio")
|
||||||
content.batch_dtmf(events)
|
content.batch_dtmf(sequence)
|
||||||
else:
|
|
||||||
raise CommandError(_("No valid DTMF event specified"))
|
|
||||||
|
|
||||||
@command
|
@command
|
||||||
@doc(_("Toggle audio session"))
|
@doc(_("Toggle audio session"))
|
||||||
|
|
Loading…
Reference in New Issue