sandboxnu / office-hours

Webapp to streamline office hours at Northeastern.
https://info.khouryofficehours.com
GNU General Public License v3.0
32 stars 13 forks source link

Feature Request: String templating in default Teams messages #928

Open rymaju opened 1 year ago

rymaju commented 1 year ago

I like to greet students by their name, something like:

"Hi {name}, how can I help you?"

If I could support that by default it would save me some time.

Seems simple enough, just save the string here (No change).

Then template here, filling in relevant variables to the user.

You could use pupa:

export function useTeams(
  queueId: number,
  users: string,
  message: string
): () => void {
  const isQueueOnline = useQueue(queueId).queue?.room.startsWith("Online");

  function openTeams(): void {

    const userData = getUserDataFromSomewhere(users); // TODO
    const filledInMessage = pupa(message, { name: userData.name }, { ignoreMissing: true})

    if (isQueueOnline) {
      window.open(
        `https://teams.microsoft.com/l/chat/0/0?users=${users}&message=${filledInMessage}`
      );
    }
  }

  return openTeams;
}
dfarooq610 commented 1 year ago

hi! this sounds really cool! I can take a stab at it, thanks for bringing it up :)

Mehulparekh144 commented 1 month ago

hi! this sounds really cool! I can take a stab at it, thanks for bringing it up :)

Hey are you working on it ? I would like to work on this issue too !