Skip to content
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

🤖 Commands #1453

Merged
merged 26 commits into from
Feb 20, 2019
Merged

🤖 Commands #1453

merged 26 commits into from
Feb 20, 2019

Conversation

nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Jan 21, 2019

This is a first step towards the option to allow writing bots.

  1. Example input: /calculate 42+23
  2. User input + some meta data is passed on to a script called via shell_exec/exec and the output is posted as a comment to the user/all

Fix #1179


Tasks

  • Allow/block guests
  • Allow management of commands via CLI
  • Allow messages to be only visible to some users
  • Invoke the scripts
  • Hardcode help/list commands
  • Allow apps to define commands
  • Write calculator as example command
  • Respect enabled flag
  • Allow aliases
  • Write docs about the parameters
  • Add an admin section which lists the commands
  • Adjust tests
  • Make the admin list beautiful ( @skjnldsv )
  • UI hint about commands/mentions
  • UI option to start using a command (automatically adding /help into the input)

Calc example

./occ talk:command:add calc calculator "/path/to/calc.sh \"{ARGUMENTS_DOUBLEQUOTE_ESCAPED}\"" 1 3

calc.sh:

while test $# -gt 0; do
  case "$1" in
    --help)
      echo "/calc - A Nextcloud Talk chat wrapper for gnome-calculator"
      echo " "
      echo "Simple equations: /calc 3 + 4 * 5"
      echo "Complex equations: /calc sin(3) + 3^3 * sqrt(5)"
      exit 0
      ;;
    *)
      break
      ;;
 esac
done

set -f
echo "$@ ="
echo $(gnome-calculator --solve="$@")

Echo example

./occ talk:command:add echo reflection "/path/to/echo.sh \"{ARGUMENTS_DOUBLEQUOTE_ESCAPED}\"" 1 3

echo.sh:

while test $# -gt 0; do
  case "$1" in
    --help)
      echo "/echo - A test command which returns what you typed"
      echo " "
      echo "Example: /echo hello there"
      echo "Result: \"hello there\""
      exit 0
      ;;
    *)
      break
      ;;
 esac
done

set -f
echo "You typed: $@"

@nickvergessen nickvergessen added this to the 💚 Next Major milestone Jan 21, 2019
@nickvergessen nickvergessen self-assigned this Jan 21, 2019
@nickvergessen nickvergessen force-pushed the feature/noid/commands branch 2 times, most recently from 94c3f41 to afb387c Compare January 23, 2019 15:23
@nickvergessen
Copy link
Member Author

@nickvergessen
Copy link
Member Author

Ref https://developers.google.com/hangouts/chat/reference/message-formats/cards

@danxuliu I had a look at this. The biggest problem is, that it would require all clients to understand HTML or any other markup we add/support there. So for version 1 I would go with plaintext only (also note that we have a 1k char limit atm). We can still go for a output-markup later on.

@nickvergessen
Copy link
Member Author

@skjnldsv when you are back again, can you help turning the admin overview of commands into a nice grid layout similar to the user management. That would be very cool 😎

@nickvergessen
Copy link
Member Author

Ready for review, UI hint and finishing will go in a new PR

@skjnldsv
Copy link
Member

@skjnldsv when you are back again, can you help turning the admin overview of commands into a nice grid layout similar to the user management. That would be very cool

of course! Follow-up pr ?

@nickvergessen
Copy link
Member Author

of course! Follow-up pr ?

yes, much appriciated

@nickvergessen nickvergessen force-pushed the feature/noid/commands branch 2 times, most recently from 87507c3 to 58aacf2 Compare February 14, 2019 11:14
Copy link
Member

@Ivansss Ivansss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing: Rendering correctly bot messages that are not for the current user.

@skjnldsv
Copy link
Member

of course! Follow-up pr ?

yes, much appriciated

please ping me once merged, I'll address this :)

nickvergessen and others added 5 commits February 20, 2019 12:17
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
It's just too dangerous for now.

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member Author

Missing: Rendering correctly bot messages that are not for the current user.

Now done, please re-review @Ivansss

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@Ivansss Ivansss merged commit ffb42eb into master Feb 20, 2019
@Ivansss Ivansss deleted the feature/noid/commands branch February 20, 2019 13:30
@nickvergessen
Copy link
Member Author

@skjnldsv it's in :)

nickvergessen added a commit that referenced this pull request Feb 21, 2019
Signed-off-by: Joas Schilling <coding@schilljs.com>
nickvergessen added a commit that referenced this pull request Feb 21, 2019
Signed-off-by: Joas Schilling <coding@schilljs.com>
nickvergessen added a commit that referenced this pull request Feb 25, 2019
@nickvergessen nickvergessen mentioned this pull request Apr 10, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants