Skip to content

added hook command line arg #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/textsecure/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"net/url"
"os"
"os/exec"
"strings"
"time"

Expand All @@ -35,6 +36,7 @@ var (
unlinkdevice int
configDir string
stress int
hook string
)

func init() {
Expand All @@ -51,6 +53,7 @@ func init() {
flag.IntVar(&unlinkdevice, "unlinkdevice", 0, "Unlink a device, the argument is the id of the device to delete")
flag.IntVar(&stress, "stress", 0, "Automatically send many messages to the peer")
flag.StringVar(&configDir, "config", ".config", "Location of config dir")
flag.StringVar(&hook, "hook", "", "Program/Script to call when message is received (e.g. for bot usage)")
}

var (
Expand Down Expand Up @@ -150,6 +153,9 @@ func messageHandler(msg *textsecure.Message) {

if msg.Message() != "" {
fmt.Printf("\r %s%s\n>", pretty(msg), blue)
if hook != "" {
exec.Command(hook,pretty(msg)).Start()
}
}

for _, a := range msg.Attachments() {
Expand Down