Skip to content

Commit

Permalink
git: add verbose as config option
Browse files Browse the repository at this point in the history
  • Loading branch information
leofah committed Jan 11, 2023
1 parent 4c7e8ee commit 2d97fcf
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions plugins_examples/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from matrixroom import MatrixRoom

DEFAULTCONFIG = {
"verbose": False,
"emoji": True,
"notification": True,
}
Expand Down Expand Up @@ -80,14 +81,12 @@ async def handle(self, token, event, content):
called by GitManager when a hook event occurs
"""
self.plugin.log.info(f"Token event received: {event}")
if "config" in await self.plugin.kvstore_get_local_keys():
config = json.loads(await self.plugin.kvstore_get_local_value("config"))
else:
config = DEFAULTCONFIG
s_config = await self.plugin.kvstore_get_local_value("config")
config = DEFAULTCONFIG | (json.loads(s_config or "{}"))
text = self.format_event(
event,
content,
verbose=False,
verbose=config["verbose"],
emojis=config["emoji"],
asnotice=config["notification"],
)
Expand Down Expand Up @@ -157,12 +156,8 @@ async def handle_listhooks(args):

async def handle_config(args):
# setup default config
if "config" not in await self.plugin.kvstore_get_local_keys():
await self.plugin.kvstore_set_local_value(
"config", json.dumps(DEFAULTCONFIG)
)

config = json.loads(await self.plugin.kvstore_get_local_value("config"))
s_config = await self.plugin.kvstore_get_local_value("config")
config = DEFAULTCONFIG | (json.loads(s_config or "{}"))
if len(args) == 0:
await self.plugin.send_html(
format_code(
Expand Down

0 comments on commit 2d97fcf

Please sign in to comment.