Skip to content

Commit

Permalink
Address Pylint warnings and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mhoran committed Mar 22, 2024
1 parent 771eeef commit 7ac3718
Showing 1 changed file with 38 additions and 31 deletions.
69 changes: 38 additions & 31 deletions scripts/weechatrn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import weechat
import json
from collections import UserDict
import weechat # pylint: disable=import-error


class Options(UserDict[str, str]):
Expand Down Expand Up @@ -78,15 +78,15 @@ def priv_msg_cb(
):
return weechat.WEECHAT_RC_OK

body = "<%s> %s" % (prefix, message)
body = f"<{prefix}> {message}"
is_pm = weechat.buffer_get_string(buffer, "localvar_type") == "private"
if is_pm:
send_push(title="Private message from %s" % prefix, body=body)
send_push(title=f"Private message from {prefix}", body=body)
elif int(highlight):
buffer_name = weechat.buffer_get_string(
buffer, "short_name"
) or weechat.buffer_get_string(buffer, "name")
send_push(title="Highlight in %s" % buffer_name, body=body)
send_push(title=f"Highlight in {buffer_name}", body=body)

return weechat.WEECHAT_RC_OK

Expand Down Expand Up @@ -123,8 +123,9 @@ def send_push(title: str, body: str) -> None:
def process_expo_cb(
data: str, command: str, return_code: int, out: str, err: str
) -> int:
"""Callback for Expi API request."""
if out:
weechat.prnt("", "return_code: %s, stdout: %s" % (return_code, out))
weechat.prnt("", f"return_code: {return_code}, stdout: {out}")
remove_unregistered_devices(out)
return weechat.WEECHAT_RC_OK

Expand Down Expand Up @@ -152,32 +153,38 @@ def remove_unregistered_devices(response: str) -> None:
weechat.config_set_plugin("push_tokens", ",".join(tokens))


if weechat.register(
"WeechatRN",
"mhoran",
"1.1.0",
"MIT",
"WeechatRN push notification plugin",
"",
"",
):
weechat.hook_command(
"weechatrn",
"Manage Expo push tokens for WeechatRN",
"<token>",
"token: Append the given push token to the list of push tokens",
def main():
"""Main entrypoint for plugin."""
if weechat.register(
"WeechatRN",
"mhoran",
"1.1.0",
"MIT",
"WeechatRN push notification plugin",
"",
"weechatrn_cb",
"",
)
weechat.hook_config("plugins.var.python.WeechatRN.*", "config_cb", "")
weechat.hook_print("", "irc_privmsg", "", 1, "priv_msg_cb", "")

for option, value in script_options_default.items():
if weechat.config_is_set_plugin(option):
script_options[option] = weechat.config_get_plugin(option)
else:
weechat.config_set_plugin(option, value[0])
weechat.config_set_desc_plugin(
option, '%s (default: "%s")' % (value[1], value[0])
):
weechat.hook_command(
"weechatrn",
"Manage Expo push tokens for WeechatRN",
"<token>",
"token: Append the given push token to the list of push tokens",
"",
"weechatrn_cb",
"",
)
weechat.hook_config("plugins.var.python.WeechatRN.*", "config_cb", "")
weechat.hook_print("", "irc_privmsg", "", 1, "priv_msg_cb", "")

for option, value in script_options_default.items():
if weechat.config_is_set_plugin(option):
script_options[option] = weechat.config_get_plugin(option)
else:
weechat.config_set_plugin(option, value[0])
weechat.config_set_desc_plugin(
option, f'{value[1]} (default: "{value[0]}")'
)


if __name__ == "__main__":
main()

0 comments on commit 7ac3718

Please sign in to comment.