Files
OpenBB/bots/groupme/run_groupme.py
Colin Delahunty 56bc8417d1 This one WEIRD trick will reduce new bot code by 90% (#1480)
* Began menu abstraction

* refactor slack to new structure

* Refactored Groupme

* Slight refactor

* Added check for using bot

* Removed auto-lower

* Fixed black

* Fixing mypy

* Added fixes

* Improved input handling

* Removed image

Co-authored-by: jose-donato <zmcdonato@gmail.com>
Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com>
2022-03-15 21:29:14 -04:00

31 lines
723 B
Python

import json
from bots.groupme.groupme_helpers import send_message
from bots.helpers import ShowView
from bots.common.helpers import non_slash
def handle_groupme(request) -> bool:
"""Handles groupme bot inputs
Parameters
----------
request : Request
The request object provided by FASTAPI
Returns
----------
success : bool
Whether the response was sent successfully
"""
req = json.loads(request.decode("utf-8"))
text = req.get("text").strip()
group_id = req.get("group_id").strip()
response = non_slash(
text,
lambda x: send_message(x, group_id),
lambda x, y, z: ShowView().groupme(x, group_id, y, **z),
)
return response