#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Hello, World!

In this example we create a shell with one simple command: hello

To run this script you have to provide a custom configuration, or set
environment variables instead::

- ``CHAT_ROOM_MODERATORS`` - Mention at least your e-mail address
- ``CISCO_SPARK_BOT_TOKEN`` - Received from Cisco Spark on bot registration
- ``SERVER_URL`` - Public link used by Cisco Spark to reach your server

The token is specific to your run-time, please visit Cisco Spark for
Developers to get more details:

    https://developer.ciscospark.com/

For example, if you run this script under Linux or macOs with support from
ngrok for exposing services to the Internet::

    export CHAT_ROOM_MODERATORS="alice@acme.com"
    export CISCO_SPARK_BOT_TOKEN="<token id from Cisco Spark for Developers>"
    export SERVER_URL="http://1a107f21.ngrok.io"
    python hello.py


"""

import os

from shellbot import Engine, ShellBot, Context, Command
Context.set_logger()

# create a bot and load command
#
class Hello(Command):
    keyword = 'hello'
    information_message = u"Hello, World!"

engine = Engine(type='spark', command=Hello())

# load configuration
#
os.environ['CHAT_ROOM_TITLE'] = 'Hello tutorial'
engine.configure()

# create a chat room
#
bot = engine.bond(reset=True)

# run the bot
#
engine.run()

# delete the chat room when the bot is stopped
#
bot.dispose()

@@ -907,16 +907,678 @@
  hello%0A%0A
+Multiple questions are adressed in this example:%0A%0A- How to build a basic command that displays a static message? Look at the%0A command %60%60hello%60%60 below, this is really done in 3 lines of code.%0A%0A- How to use Cisco Spark? As shown below, the platform is selected during%0A  the initialisation of the engine. Here we put %60%60type='spark'%60%60 and that's it.%0A  Ok, in addition to this code you also have to set some variables to make it%0A  work, but this is configuration done outside the code itself.%0A%0A- How to change the banner? Shellbot support bare text, rich content, and even%0A  some upload, all together. This is done with some environment variables, as%0A  shown below.%0A%0A
 To run t
@@ -2684,16 +2684,330 @@
 torial'%0A
+os.environ%5B'BOT_BANNER_TEXT'%5D = u%22Type '@%7B%7D help' for more information%22%0Aos.environ%5B'BOT_BANNER_CONTENT'%5D = u%22Hello there! Type %60%60@%7B%7D help%60%60 at any time to get more information on available commands.%22%0Aos.environ%5B'BOT_BANNER_FILE'%5D = %22https://upload.wikimedia.org/wikipedia/commons/5/5e/Sunrise_Matobo_Zimbabwe.jpg%22%0A
 engine.c

use banner in examples/hello