Comments (7)
Thank you for checking the function get_ok_in_response()
, @ky4k0b . I have tested it on my end and it seems working well.
Here is my test result:
$ get_ok_in_response '{"ok":true,"text":"a b c"}'
true
$ get_ok_in_response '{"text":"a b c","ok":true}'
true
# Testing the cases with awk used in the function
$ echo '{"text":"a b c","ok":true}' | awk 'match($0, /"ok":([^,}]+)/) {print substr($0, RSTART+5, RLENGTH-5)}'
true
$ echo '{"ok":true,"text":"a b c"}' | awk 'match($0, /"ok":([^,}]+)/) {print substr($0, RSTART+5, RLENGTH-5)}'
true
Seems like your test data doesn't have the opening "
for text
. Could you check if that is actually missing in the response of Slack API?
from slacktee.
@Chikashi-Kato
check how you pass variables into this function
if [[ $(get_ok_in_response $post_result) != "true" ]]; then
now consider this example:
manage:~# function get_ok_in_response() {
> local response=$1
> echo "$(echo "$response" | awk 'match($0, /"ok":([^,}]+)/) {print substr($0, RSTART+5, RLENGTH-5)}')"
> }
manage:~# ok='{"ok":true,"text":"a b c"}'
manage:~# not_ok='{"text":"a b c","ok":true}'
manage:~# get_ok_in_response $ok
true
manage:~# get_ok_in_response $not_ok
manage:~# get_ok_in_response "$not_ok"
true
manage:~#
from slacktee.
Ohhh, I see. Now I could reproduce the issue.
Sorry I didn't fully understand your explanation and also, I was using zsh
instead of bash
.
I agree with you. We should wrap $post_result
with "
for avoiding the unexpected issue caused by the change of the Slack API in future!
from slacktee.
@ky4k0b While I'm fixing the bug, could you explain why the function call doesn't work with $not_ok
without wrapping of "
? I tried to figure it out by myself but couldn't find the root cause of the behavior. 🤔
from slacktee.
it's all about empty strings, strings with spaces and strings with special symbols like *
without wrapping with " it runs like this:
get_ok_in_response $not_ok
vvv
get_ok_in_response {"text":"a b c","ok":true}
vvv
it takes {"text":"a as a first argument cause of space delimiter
more explanations and cool examples here: https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable
from slacktee.
Ah! Space delimiter!!! That makes a lot of sense! Thank you so much for your explanation and the link to the stack overflow page!!!
from slacktee.
Merged the fix into master. Thanks again for your report, @ky4k0b !
from slacktee.
Related Issues (20)
- Add negative color/prefix pattern condition HOT 5
- color doesn't stay HOT 3
- Unable to close with CTRL+C, when running directly HOT 4
- Interactive copies won't work for unattended installs HOT 2
- Using Webhook to run slacktee HOT 2
- Unable to create slacktee as a service HOT 4
- Add ability to skip interactive setup upon installation HOT 2
- "not in channel" error HOT 10
- Different output by same bot? HOT 3
- invalid json when sending non-json text HOT 14
- Post to thread HOT 1
- Color in ouput gives json error HOT 4
- Breaking rich format when sending +4000 characters HOT 2
- Add version flag HOT 1
- Send without message
- `parseMode` causes invalid json error
- streaming but without editing
- any kind of logs?
- Slack files.upload deprecated HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slacktee.