async def process_activity(self, logic: Callable): """ Begins listening to console input. :param logic: :return: """ while True: msg = input() if msg is None: pass else: self._next_id += 1 activity = Activity( text=msg, channel_id="console", from_property=ChannelAccount(id="user", name="User1"), recipient=ChannelAccount(id="bot", name="Bot"), conversation=ConversationAccount(id="Convo1"), type=ActivityTypes.message, timestamp=datetime.datetime.now(), id=str(self._next_id), ) activity = TurnContext.apply_conversation_reference( activity, self.reference, True) context = TurnContext(self, activity) await self.run_pipeline(context, logic)
async def process_activity(self, logic: Callable): """ Begins listening to console input. :param logic: :return: """ while True: #user's input is set as variable msg msg = input() #Nothing happens if the user inputs a blank input if msg is None: pass else: #increases _next_id value by one self._next_id += 1 # creating an object for communication with the Bot. Used as an initial message for a new conversation activity = Activity( text=msg, channel_id='console', #Uniquely identifies ID of user and their name from_property=ChannelAccount(id='user', name='User1'), #identifies the bot as recipient and their name as Bot recipient=ChannelAccount(id='bot', name='Bot'), #identification of the conversation conversation=ConversationAccount(id='Convo1'), type=ActivityTypes.message, timestamp=datetime.datetime.now(), id=str(self._next_id)) #send to the bot activity = TurnContext.apply_conversation_reference( activity, self.reference, True) context = TurnContext(self, activity) # output of the function #logs message from user await self.run_middleware(context, logic)
async def process_activities(self, msgs, logic: Callable): """ Loops through array of strings to bot :param msgs: :param logic: :return: """ for msg in msgs: if msg is None: pass else: self._next_id += 1 activity = Activity(text=msg, channel_id='console', from_property=ChannelAccount(id='user', name='User1'), recipient=ChannelAccount(id='bot', name='Bot'), conversation=ConversationAccount(id='Convo1'), type=ActivityTypes.message, timestamp=datetime.datetime.now(), id=str(self._next_id)) activity = TurnContext.apply_conversation_reference(activity, self.reference, True) context = TurnContext(self, activity) print(context.get_conversation_reference(activity)) await self.run_middleware(context, logic)