smart-bot-factory 0.3.6__py3-none-any.whl → 0.3.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of smart-bot-factory might be problematic. Click here for more details.

Files changed (45) hide show
  1. smart_bot_factory/admin/__init__.py +7 -7
  2. smart_bot_factory/admin/admin_events.py +483 -383
  3. smart_bot_factory/admin/admin_logic.py +234 -158
  4. smart_bot_factory/admin/admin_manager.py +68 -53
  5. smart_bot_factory/admin/admin_tester.py +46 -40
  6. smart_bot_factory/admin/timeout_checker.py +201 -153
  7. smart_bot_factory/aiogram_calendar/__init__.py +11 -3
  8. smart_bot_factory/aiogram_calendar/common.py +12 -18
  9. smart_bot_factory/aiogram_calendar/dialog_calendar.py +126 -64
  10. smart_bot_factory/aiogram_calendar/schemas.py +49 -28
  11. smart_bot_factory/aiogram_calendar/simple_calendar.py +94 -50
  12. smart_bot_factory/analytics/analytics_manager.py +414 -392
  13. smart_bot_factory/cli.py +204 -148
  14. smart_bot_factory/config.py +123 -102
  15. smart_bot_factory/core/bot_utils.py +480 -324
  16. smart_bot_factory/core/conversation_manager.py +287 -200
  17. smart_bot_factory/core/decorators.py +1145 -739
  18. smart_bot_factory/core/message_sender.py +287 -266
  19. smart_bot_factory/core/router.py +170 -100
  20. smart_bot_factory/core/router_manager.py +121 -83
  21. smart_bot_factory/core/states.py +4 -3
  22. smart_bot_factory/creation/__init__.py +1 -1
  23. smart_bot_factory/creation/bot_builder.py +320 -242
  24. smart_bot_factory/creation/bot_testing.py +440 -365
  25. smart_bot_factory/dashboard/__init__.py +1 -3
  26. smart_bot_factory/event/__init__.py +2 -7
  27. smart_bot_factory/handlers/handlers.py +682 -466
  28. smart_bot_factory/integrations/openai_client.py +218 -168
  29. smart_bot_factory/integrations/supabase_client.py +928 -637
  30. smart_bot_factory/message/__init__.py +18 -22
  31. smart_bot_factory/router/__init__.py +2 -2
  32. smart_bot_factory/setup_checker.py +162 -126
  33. smart_bot_factory/supabase/__init__.py +1 -1
  34. smart_bot_factory/supabase/client.py +631 -515
  35. smart_bot_factory/utils/__init__.py +2 -3
  36. smart_bot_factory/utils/debug_routing.py +38 -27
  37. smart_bot_factory/utils/prompt_loader.py +153 -120
  38. smart_bot_factory/utils/user_prompt_loader.py +55 -56
  39. smart_bot_factory/utm_link_generator.py +123 -116
  40. {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.8.dist-info}/METADATA +3 -1
  41. smart_bot_factory-0.3.8.dist-info/RECORD +59 -0
  42. smart_bot_factory-0.3.6.dist-info/RECORD +0 -59
  43. {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.8.dist-info}/WHEEL +0 -0
  44. {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.8.dist-info}/entry_points.txt +0 -0
  45. {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.8.dist-info}/licenses/LICENSE +0 -0
@@ -1,21 +1,22 @@
1
1
  import calendar
2
2
  from datetime import datetime, timedelta
3
3
 
4
- from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
5
- from aiogram.types import CallbackQuery
4
+ from aiogram.types import (CallbackQuery, InlineKeyboardButton,
5
+ InlineKeyboardMarkup)
6
6
 
7
- from .schemas import SimpleCalendarCallback, SimpleCalAct, highlight, superscript
8
7
  from .common import GenericCalendar
8
+ from .schemas import (SimpleCalAct, SimpleCalendarCallback, highlight,
9
+ superscript)
9
10
 
10
11
 
11
12
  class SimpleCalendar(GenericCalendar):
12
13
 
13
- ignore_callback = SimpleCalendarCallback(act=SimpleCalAct.ignore).pack() # placeholder for no answer buttons
14
+ ignore_callback = SimpleCalendarCallback(
15
+ act=SimpleCalAct.ignore
16
+ ).pack() # placeholder for no answer buttons
14
17
 
15
18
  async def start_calendar(
16
- self,
17
- year: int = datetime.now().year,
18
- month: int = datetime.now().month
19
+ self, year: int = datetime.now().year, month: int = datetime.now().month
19
20
  ) -> InlineKeyboardMarkup:
20
21
  """
21
22
  Creates an inline keyboard with the provided year and month
@@ -59,41 +60,62 @@ class SimpleCalendar(GenericCalendar):
59
60
  # inline_kb = InlineKeyboardMarkup(row_width=7)
60
61
  # First row - Year
61
62
  years_row = []
62
- years_row.append(InlineKeyboardButton(
63
- text="<<",
64
- callback_data=SimpleCalendarCallback(act=SimpleCalAct.prev_y, year=year, month=month, day=1).pack()
65
- ))
66
- years_row.append(InlineKeyboardButton(
67
- text=str(year) if year != now_year else highlight(year),
68
- callback_data=self.ignore_callback
69
- ))
70
- years_row.append(InlineKeyboardButton(
71
- text=">>",
72
- callback_data=SimpleCalendarCallback(act=SimpleCalAct.next_y, year=year, month=month, day=1).pack()
73
- ))
63
+ years_row.append(
64
+ InlineKeyboardButton(
65
+ text="<<",
66
+ callback_data=SimpleCalendarCallback(
67
+ act=SimpleCalAct.prev_y, year=year, month=month, day=1
68
+ ).pack(),
69
+ )
70
+ )
71
+ years_row.append(
72
+ InlineKeyboardButton(
73
+ text=str(year) if year != now_year else highlight(year),
74
+ callback_data=self.ignore_callback,
75
+ )
76
+ )
77
+ years_row.append(
78
+ InlineKeyboardButton(
79
+ text=">>",
80
+ callback_data=SimpleCalendarCallback(
81
+ act=SimpleCalAct.next_y, year=year, month=month, day=1
82
+ ).pack(),
83
+ )
84
+ )
74
85
  kb.append(years_row)
75
86
 
76
87
  # Month nav Buttons
77
88
  month_row = []
78
- month_row.append(InlineKeyboardButton(
79
- text="<",
80
- callback_data=SimpleCalendarCallback(act=SimpleCalAct.prev_m, year=year, month=month, day=1).pack()
81
- ))
82
- month_row.append(InlineKeyboardButton(
83
- text=highlight_month(),
84
- callback_data=self.ignore_callback
85
- ))
86
- month_row.append(InlineKeyboardButton(
87
- text=">",
88
- callback_data=SimpleCalendarCallback(act=SimpleCalAct.next_m, year=year, month=month, day=1).pack()
89
- ))
89
+ month_row.append(
90
+ InlineKeyboardButton(
91
+ text="<",
92
+ callback_data=SimpleCalendarCallback(
93
+ act=SimpleCalAct.prev_m, year=year, month=month, day=1
94
+ ).pack(),
95
+ )
96
+ )
97
+ month_row.append(
98
+ InlineKeyboardButton(
99
+ text=highlight_month(), callback_data=self.ignore_callback
100
+ )
101
+ )
102
+ month_row.append(
103
+ InlineKeyboardButton(
104
+ text=">",
105
+ callback_data=SimpleCalendarCallback(
106
+ act=SimpleCalAct.next_m, year=year, month=month, day=1
107
+ ).pack(),
108
+ )
109
+ )
90
110
  kb.append(month_row)
91
111
 
92
112
  # Week Days
93
113
  week_days_labels_row = []
94
114
  for weekday in self._labels.days_of_week:
95
115
  week_days_labels_row.append(
96
- InlineKeyboardButton(text=highlight_weekday(), callback_data=self.ignore_callback)
116
+ InlineKeyboardButton(
117
+ text=highlight_weekday(), callback_data=self.ignore_callback
118
+ )
97
119
  )
98
120
  kb.append(week_days_labels_row)
99
121
 
@@ -104,34 +126,56 @@ class SimpleCalendar(GenericCalendar):
104
126
  days_row = []
105
127
  for day in week:
106
128
  if day == 0:
107
- days_row.append(InlineKeyboardButton(text=" ", callback_data=self.ignore_callback))
129
+ days_row.append(
130
+ InlineKeyboardButton(
131
+ text=" ", callback_data=self.ignore_callback
132
+ )
133
+ )
108
134
  continue
109
- days_row.append(InlineKeyboardButton(
110
- text=highlight_day(),
111
- callback_data=SimpleCalendarCallback(act=SimpleCalAct.day, year=year, month=month, day=day).pack()
112
- ))
135
+ days_row.append(
136
+ InlineKeyboardButton(
137
+ text=highlight_day(),
138
+ callback_data=SimpleCalendarCallback(
139
+ act=SimpleCalAct.day, year=year, month=month, day=day
140
+ ).pack(),
141
+ )
142
+ )
113
143
  kb.append(days_row)
114
144
 
115
145
  # nav today & cancel button
116
146
  cancel_row = []
117
- cancel_row.append(InlineKeyboardButton(
118
- text=self._labels.cancel_caption,
119
- callback_data=SimpleCalendarCallback(act=SimpleCalAct.cancel, year=year, month=month, day=day).pack()
120
- ))
121
- cancel_row.append(InlineKeyboardButton(text=" ", callback_data=self.ignore_callback))
122
- cancel_row.append(InlineKeyboardButton(
123
- text=self._labels.today_caption,
124
- callback_data=SimpleCalendarCallback(act=SimpleCalAct.today, year=year, month=month, day=day).pack()
125
- ))
147
+ cancel_row.append(
148
+ InlineKeyboardButton(
149
+ text=self._labels.cancel_caption,
150
+ callback_data=SimpleCalendarCallback(
151
+ act=SimpleCalAct.cancel, year=year, month=month, day=day
152
+ ).pack(),
153
+ )
154
+ )
155
+ cancel_row.append(
156
+ InlineKeyboardButton(text=" ", callback_data=self.ignore_callback)
157
+ )
158
+ cancel_row.append(
159
+ InlineKeyboardButton(
160
+ text=self._labels.today_caption,
161
+ callback_data=SimpleCalendarCallback(
162
+ act=SimpleCalAct.today, year=year, month=month, day=day
163
+ ).pack(),
164
+ )
165
+ )
126
166
  kb.append(cancel_row)
127
167
  return InlineKeyboardMarkup(row_width=7, inline_keyboard=kb)
128
168
 
129
169
  async def _update_calendar(self, query: CallbackQuery, with_date: datetime):
130
170
  await query.message.edit_reply_markup(
131
- reply_markup=await self.start_calendar(int(with_date.year), int(with_date.month))
171
+ reply_markup=await self.start_calendar(
172
+ int(with_date.year), int(with_date.month)
173
+ )
132
174
  )
133
175
 
134
- async def process_selection(self, query: CallbackQuery, data: SimpleCalendarCallback) -> tuple:
176
+ async def process_selection(
177
+ self, query: CallbackQuery, data: SimpleCalendarCallback
178
+ ) -> tuple:
135
179
  """
136
180
  Process the callback_query. This method generates a new calendar if forward or
137
181
  backward is pressed. This method should be called inside a CallbackQueryHandler.
@@ -175,6 +219,6 @@ class SimpleCalendar(GenericCalendar):
175
219
  return (True, datetime.now())
176
220
  if data.act == SimpleCalAct.cancel:
177
221
  await query.message.delete_reply_markup()
178
- return ('cancel', None)
222
+ return ("cancel", None)
179
223
  # at some point user clicks DAY button, returning date
180
- return return_data
224
+ return return_data