Coverage for mindsdb / interfaces / chatbot / types.py: 58%

19 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-21 00:36 +0000

1from enum import Enum 

2import datetime as dt 

3 

4 

5class BotException(Exception): 

6 pass 

7 

8 

9class ChatBotMessage: 

10 """ 

11 Represents a message sent and received by chatbots. 

12 

13 Attributes: 

14 type (ChatBotMessage.Type): Type of message 

15 text (str): Actual message content 

16 user (str): The user that sent the message 

17 destination (str): The user or channel that received the message 

18 

19 """ 

20 

21 class Type(Enum): 

22 DIRECT = 1 

23 CHANNEL = 2 

24 

25 def __init__(self, type: Type, text: str, user: str, destination: str = None, sent_at: dt.datetime = None): 

26 self.type = type 

27 self.text = text 

28 self.user = user 

29 self.destination = destination 

30 self.sent_at = sent_at or dt.datetime.now() 

31 

32 

33class Function: 

34 

35 def __init__(self, name, description, callback): 

36 self.name = name 

37 self.description = description 

38 self.callback = callback