-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
- Loading branch information
1 parent
a7d5b0f
commit 3c41f14
Showing
10 changed files
with
215 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"path" | ||
"strings" | ||
|
||
slackapi "github.com/slack-go/slack" | ||
|
||
"github.com/graphaelli/zat/cmd" | ||
"github.com/graphaelli/zat/slack" | ||
) | ||
|
||
func main() { | ||
cfgDir := cmd.FlagConfigDir() | ||
noEscape := flag.Bool("n", false, "don't escape message text") | ||
flag.Parse() | ||
|
||
if flag.NArg() < 1 { | ||
fmt.Fprintf(os.Stderr, "usage: %s channel [text ...]\n", os.Args[0]) | ||
os.Exit(1) | ||
} | ||
channel := flag.Arg(0) | ||
text := "Hello, zat" | ||
if flag.NArg() > 1 { | ||
text = strings.Join(flag.Args()[1:], " ") | ||
} | ||
|
||
logger := log.New(os.Stderr, "", cmd.LogFmt) | ||
api, _ := slack.NewClientFromEnvOrFile(logger, path.Join(*cfgDir, cmd.SlackConfigPath), slackapi.OptionDebug(true)) | ||
if api == nil { | ||
logger.Fatal("failed to create slack api client") | ||
} | ||
|
||
channel, ts, text, err := api.SendMessage(channel, slackapi.MsgOptionText(text, !*noEscape)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(channel, ts, text) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"path" | ||
|
||
slackapi "github.com/slack-go/slack" | ||
|
||
"github.com/graphaelli/zat/cmd" | ||
"github.com/graphaelli/zat/slack" | ||
) | ||
|
||
func main() { | ||
cfgDir := cmd.FlagConfigDir() | ||
flag.Parse() | ||
|
||
logger := log.New(os.Stderr, "", cmd.LogFmt) | ||
api, _ := slack.NewClientFromEnvOrFile(logger, path.Join(*cfgDir, cmd.SlackConfigPath), slackapi.OptionDebug(true)) | ||
if api == nil { | ||
logger.Fatal("failed to create slack api client") | ||
} | ||
|
||
channels, _, err := api.GetConversations(&slackapi.GetConversationsParameters{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
for i, channel := range channels { | ||
fmt.Printf("%d: %+v\n", i, channel) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.