Skip to content

Commit

Permalink
version 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkoz committed Oct 27, 2021
1 parent 84a445c commit f59dfb2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -39,6 +39,8 @@ Open Keypirinha and select the `Calendar` entry.
View your upcoming events, and if they have a linked teams meeting, join the meeting
by highlighting the event with the up/down arrows and pressing `Enter`

If you enable the "always_suggest" option, you can even just open Keypirinha and
press space to display your events.

## Configuration

Expand All @@ -47,12 +49,18 @@ You can configure these settings :
* label : The catalog entry name (if you want to type `ocal` instead of `Calendar` to invoke the plugin for example)
* max_results : To limit the number of events returned
* max_days : To limit the number of days in the future scanned for events
* always_suggest : Set to 'yes' to add your events to the default results of Keypirinha without havint to first enter the 'label' keyword
* date_format : To change the date format for outlook's filter only, according to your locale. If you experience strange
behaviour on the dates you can try to change this


## Change Log

### v1.3
* Option to add meetings to default suggestions
* Support ms teams links protected by outlook safelinks protection
* Updated icons

### v1.2
* Make date_format configurable to allow to adapt to the user's locale

Expand Down
Binary file modified src/maybe.ico
Binary file not shown.
Binary file added src/organizer.ico
Binary file not shown.
5 changes: 5 additions & 0 deletions src/outlook_calendar.ini
Expand Up @@ -16,6 +16,11 @@
# Defaults to 5
#max_days = 5

# Whether to display your events in the default suggestions of Keypirinha
# If enabled, you won't need to type the 'Label' keyword to view your events
# Defaults to 'no'
#always_suggest = no

# Date format for filtering outlook events
# If the events returned are not what you expect, and it looks like months and
# days are inverted, try changing this, for example to '%m-%d-%Y'
Expand Down
14 changes: 10 additions & 4 deletions src/outlook_calendar.py
Expand Up @@ -39,7 +39,7 @@ def on_catalog(self):
])

def on_suggest(self, user_input, items_chain):
if not items_chain or items_chain[0].category() != kp.ItemCategory.KEYWORD:
if not self.settings.get_bool("always_suggest", "main", False) and (not items_chain or items_chain[0].category() != kp.ItemCategory.KEYWORD):
return
date = datetime.now()
cal = self.__get_calendar(date,date+dt.timedelta(days=int(self.settings.get("max_days", "main", 5, True))))
Expand All @@ -63,21 +63,27 @@ def _read_config(self):
self.kpsettings = kp.settings()

def __compose_suggestions(self, cal, user_input) -> []:
# Label of outlook response status
status = {1:"Organizer", 2: "Tentative", 3: "Accepted", 4:"Declined", 5: "Pending"}
icons={1:"ok", 2:"maybe", 3:"ok", 4:"ko", 5:"maybe"}
# Icon of outlook response status
icons={1:"organizer", 2:"maybe", 3:"ok", 4:"ko", 5:"maybe"}
suggestions = []
nb=0
for app in cal:
if len(user_input) < 1 or app.subject.lower().find(user_input.lower())>=0:
# If no user input, display everything. Otherwise, lookup in the subject field
# Added the "space" condition to allow for quick display when always_suggest is true :
# In that last case, opening the window and only pressing "space" will display your next appointments
if len(user_input) < 1 or app.subject.lower().find(user_input.lower())>=0 or user_input==" ":
nb = nb+1
link="None"
desc= app.location
body = str(app.body)
# Check for MS teams link
srch = re.search(r":\/\/teams.[\w\d:#@%\/;$()~_?\+-=\\\.&]*",body)
# If not found, check a outlook safelink protected link
if not srch:
for link in re.findall(r"safelinks\.protection\.outlook\.com[\S]*\?url=([^&]*)",body):
srch = re.search(r":\/\/teams.[\w\d:#@%\/;$()~_?\+-=\\\.&]*",unquote(link))
self.dbg('Safe link found: '+unquote(link))
if srch:
break
if srch:
Expand Down

0 comments on commit f59dfb2

Please sign in to comment.