Custom command parsing fix

This commit is contained in:
Abhorrent_Anger 2019-10-29 16:16:13 +02:00
parent ab380cd297
commit dab9493d9c
2 changed files with 19 additions and 10 deletions

View File

@ -1,7 +1,11 @@
# Profanity LED notification
Sends new message notifications to a predefined LED. Inspired by a similar [Pidgin plugin](https://sites.google.com/site/simohmattila/led-notification).
Sends new message notifications to a predefined LED by running an user-set command. Inspired by a similar [Pidgin plugin](https://sites.google.com/site/simohmattila/led-notification). LED turns off once the chat or room window receives focus.
## Install:
As with other Profanity plugins, simply clone the repository and run:
```
/plugins install ~/profanity-led-notification/lednotification.py
```
For further configuration check:
```
/help lednotification
```

View File

@ -15,7 +15,7 @@ def call_command(state_on=True):
def enable_led(state_on=True): # Can be expanded for different ways to call LED changes
call_command(state_on)
def led_notify(sender):
def led_notify():
global focused
focused = False
blink = prof.settings_string_get("lednotification", "blink", "off")
@ -44,23 +44,24 @@ def on_focus():
def prof_post_chat_message_display(barejid, resource, message):
enabled = prof.settings_string_get("lednotification", "enabled", "on")
if enabled == "on":
led_notify(barejid)
led_notify()
return message
def prof_post_room_message_display(barejid, nick, message):
enabled = prof.settings_string_get("lednotification", "enabled", "on")
rooms = prof.settings_string_get("lednotification", "rooms", "off")
if enabled == "on" and rooms == "on":
led_notify(barejid)
user = prof.get_room_nick(barejid)
if enabled == "on" and rooms == "on" and user != nick:
led_notify()
return message
def prof_post_priv_message_display(barejid, nick, message):
enabled = prof.settings_string_get("lednotification", "enabled", "on")
if enabled == "on":
led_notify(barejid)
led_notify()
return message
def _cmd_say(arg1=None, arg2=None, arg3=None):
def _cmd_say(arg1=None, arg2=None):
if arg1 == "on":
prof.settings_string_set("lednotification", "enabled", "on")
prof.cons_show("LED notifications enabled")
@ -68,6 +69,10 @@ def _cmd_say(arg1=None, arg2=None, arg3=None):
prof.settings_string_set("lednotification", "enabled", "off")
prof.cons_show("LED notifications disabled")
elif arg1 == "command":
split = arg2.split()
mode = split[0]
arg3 = arg2.replace(mode, '', 1)[1:]
arg2 = mode
if arg2 == None or arg3 == None:
prof.cons_bad_cmd_usage("/lednotification")
elif arg2 == "on":
@ -104,8 +109,8 @@ def _cmd_say(arg1=None, arg2=None, arg3=None):
def prof_init(version, status, account_name, fulljid):
synopsis = [
"/lednotification on|off",
"/lednotification command on 'command'",
"/lednotification command off 'command'",
"/lednotification command on command",
"/lednotification command off command",
"/lednotification blink on|off|interval",
"/lednotification rooms on|off"]
description = "Show new notifications with LEDs"
@ -117,7 +122,7 @@ def prof_init(version, status, account_name, fulljid):
["rooms <args>", "Turn notifications for rooms on or off"]]
examples = [
"/lednotification on",
"/lednotification command on 'xset led 3'",
"/lednotification command on xset led 3",
"/lednotification rooms off",
"/lednotification blink on",
"/lednotification blink 0.5"]