Add on|off setting to sounds.py
This commit is contained in:
36
sounds.py
36
sounds.py
@@ -21,12 +21,15 @@ def _play_sound(soundfile):
|
||||
|
||||
def _cmd_sounds(arg1=None, arg2=None, arg3=None):
|
||||
if not arg1:
|
||||
enabled = prof.settings_boolean_get("sounds", "enabled", False)
|
||||
chatsound = prof.settings_string_get("sounds", "chat", None)
|
||||
roomsound = prof.settings_string_get("sounds", "room", None)
|
||||
privatesound = prof.settings_string_get("sounds", "private", None)
|
||||
|
||||
if chatsound or roomsound or privatesound:
|
||||
prof.cons_show("Sounds:")
|
||||
if enabled:
|
||||
prof.cons_show("Sounds: ON")
|
||||
else:
|
||||
prof.cons_show("Sounds: OFF")
|
||||
if chatsound:
|
||||
prof.cons_show(" Chat : " + chatsound)
|
||||
if roomsound:
|
||||
@@ -38,6 +41,16 @@ def _cmd_sounds(arg1=None, arg2=None, arg3=None):
|
||||
|
||||
return
|
||||
|
||||
if arg1 == "on":
|
||||
prof.settings_boolean_set("sounds", "enabled", True)
|
||||
prof.cons_show("Sounds enabled")
|
||||
return
|
||||
|
||||
if arg1 == "off":
|
||||
prof.settings_boolean_set("sounds", "enabled", False)
|
||||
prof.cons_show("Sounds disabled")
|
||||
return
|
||||
|
||||
if arg1 == "set":
|
||||
if arg2 == "chat":
|
||||
prof.settings_string_set("sounds", "chat", arg3)
|
||||
@@ -74,6 +87,7 @@ def _cmd_sounds(arg1=None, arg2=None, arg3=None):
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [
|
||||
"/sounds",
|
||||
"/sounds on|off",
|
||||
"/sounds set chat <file>",
|
||||
"/sounds set room <file>",
|
||||
"/sounds set private <file>",
|
||||
@@ -83,6 +97,7 @@ def prof_init(version, status, account_name, fulljid):
|
||||
]
|
||||
description = "Play mp3 sounds on various Profanity events. Calling with no args shows current sound files."
|
||||
args = [
|
||||
[ "on|off", "Enable or disable playing sounds." ],
|
||||
[ "set chat <file>", "Path to mp3 file to play on chat messages." ],
|
||||
[ "set room <file>", "Path to mp3 file to play on room messages." ],
|
||||
[ "set private <file>", "Path to mp3 file to play on private room messages." ],
|
||||
@@ -94,29 +109,42 @@ def prof_init(version, status, account_name, fulljid):
|
||||
"/sounds set chat ~/sounds/woof.mp3",
|
||||
"/sounds set room ~/sounds/meow.mp3",
|
||||
"/sounds set private ~/sounds/shhh.mp3",
|
||||
"/sounds remove private"
|
||||
"/sounds remove private",
|
||||
"/sounds on",
|
||||
]
|
||||
|
||||
prof.register_command("/sounds", 0, 3, synopsis, description, args, examples, _cmd_sounds)
|
||||
|
||||
prof.completer_add("/sounds", [ "set", "clear" ])
|
||||
prof.completer_add("/sounds", [ "set", "clear", "on", "off" ])
|
||||
prof.completer_add("/sounds set", [ "chat", "room", "private" ])
|
||||
prof.completer_add("/sounds clear", [ "chat", "room", "private" ])
|
||||
|
||||
|
||||
def prof_post_chat_message_display(barejid, resource, message):
|
||||
enabled = prof.settings_boolean_get("sounds", "enabled", False)
|
||||
if not enabled:
|
||||
return
|
||||
|
||||
soundfile = prof.settings_string_get("sounds", "chat", None)
|
||||
if soundfile:
|
||||
_play_sound(soundfile)
|
||||
|
||||
|
||||
def prof_post_room_message_display(barejid, nick, message):
|
||||
enabled = prof.settings_boolean_get("sounds", "enabled", False)
|
||||
if not enabled:
|
||||
return
|
||||
|
||||
soundfile = prof.settings_string_get("sounds", "room", None)
|
||||
if soundfile:
|
||||
_play_sound(soundfile)
|
||||
|
||||
|
||||
def prof_post_priv_message_display(barejid, nick, message):
|
||||
enabled = prof.settings_boolean_get("sounds", "enabled", False)
|
||||
if not enabled:
|
||||
return
|
||||
|
||||
soundfile = prof.settings_string_get("sounds", "private", None)
|
||||
if soundfile:
|
||||
_play_sound(soundfile)
|
||||
|
||||
Reference in New Issue
Block a user