Package: google-hangouts-chat-bot
A framework for Google Hangouts Chat BotThis is a framework you can use to build bots for Google Hangouts Chat. (You can read more about Google Hangouts Chat below.)It was made to be simple and extensible.What it does?There are many ways to create a bot for Google Hangouts Chat and one of them is using HTTP endpoints.
In a nutshell, the bot receives a JSON payload via an HTTP POST request and should respond it with another JSON, following a defined message format.This framework was built to facilitate the creation ofcli-like bots. It parses the payload and verifies if there is some command associated with the message. If there is one, this command is called and the result is returned.The main pieces are:Command: our base command classCommands: a collection of commandsEventHandler: the core, responsible to parse the message and call the associated command.In addition to that, we have:response helpers: to create the responses with the right format.create_text_response()create_cards_response()create_card_header()create_card_paragraph()create_card_key_value()create_card_image()create_card_buttons()create_card_text_buttoncreate_card()security helpers:check_allowed_domain- to verify if user can use the botcheck_bot_authenticity-  to verify if the request was made by a real botbuilt-inHelpcommand:When invoked, it will return a message with available commands (example):Commands available:

hello <name>
Say hello

sum <n>...
Sum informed values

# Repeat for every non-hidden command
# [command] [arguments]
# [description]

help
List commands available

HINT: If you need to specify multiple words for a parameter, use quotes (").AtentionThis framework is not a web framework. You need to use it with one solution.Example usingFlask:@app.route("/",methods=["POST"])defmain():payload=request.get_json()response=EventHandler(payload,commands).process()returnjson.jsonify(response)How it works?1 -Command(our base class):classCommand:# the keyword that will trigger itcommand=None# some aliases, if neededcommand_aliases=[]# description of expected argumentsarguments=None# description of commanddescription=None# if hidden, this command will not appear when listing commandshidden=False# main methoddefhandle(self,arguments,**kwargs):raiseNotImplementedError1.1 - Let's create aHellocommand:classHello(Command):command="hello"command_aliases=["hi","hey"]arguments="<name>"description="Say hello"defhandle(self,arguments,**kwargs):returncreate_text_response(f"Hello,{arguments[0]}!")2 -Commands:# Creating a list of available commandscommands=Commands()commands.add_command(Hello)# if needed, you can add commands by modulecommands.add_commands_from_module(some.module)3 -EventHandler:payload={...}# it receives the payload, commands list and more kwargs if needed# then it processes the payload, returning a responseresponse=EventHandler(payload,commands).process()4 - Sending a "hello" message:commands=Commands()commands.add_command(Hello)payload={"type":"MESSAGE","message":{"text":"hello Jane"},# what the user has typed"space":"...","user":"...",}# message will be parsed, identifying:#   command = "hello"#   arguments = ["Jane"]## since we have a command triggered by "hello"## class Hello(Command):#   command = "hello"#   ...## an instance will be created and called:#   return Hello().handle(arguments)response=EventHandler(payload,commands).process()print(response){"text":"Hello, Jane!"}Google Hangouts ChatThe following diagram describes a typical interaction with a bot in a chat room:Design guidelinesCreating new botsPublishing botsHangouts Chat message formatsInstallingYou can install usingpip:$ python -m pip install google_hangouts_chat_botAuthors@jeanpimentel(Jean Pimentel)ContributingContributions are always welcome and highly encouraged.
SeeCONTRIBUTINGfor more information on how to get started.LicenseMIT - Seethe LICENSEfor more information.