<s> from django . http import JsonResponse <EOL> from django . utils . decorators import method_decorator <EOL> from django . views . decorators . csrf import csrf_exempt <EOL> from django . views . generic import View <EOL> from orchestra . bots . errors import SlackCommandInvalidRequest <EOL> from orchestra . bots . basebot import BaseBot <EOL> from orchestra . bots . staffbot import StaffBot <EOL> @ method_decorator ( csrf_exempt , name = '<STR_LIT>' ) <EOL> class BotMixin ( View ) : <EOL> """<STR_LIT>""" <EOL> BotClass = BaseBot <EOL> bot_config = { } <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( ) . __init__ ( * args , ** kwargs ) <EOL> self . bot = self . BotClass ( ** self . bot_config ) <EOL> def post ( self , request , * args , ** kwargs ) : <EOL> data = request . POST <EOL> try : <EOL> response_data = self . bot . dispatch ( data ) <EOL> except SlackCommandInvalidRequest as e : <EOL> response_data = { '<STR_LIT:error>' : str ( e ) } <EOL> return JsonResponse ( response_data ) <EOL> class StaffBotView ( BotMixin ) : <EOL> BotClass = StaffBot </s>
