from django.db import models


class User(models.Model):
	user_name = models.CharField('Логин', max_length = 30)
	user_firstname = models.TextField('Имя', max_length = 30)
	user_lastname = models.TextField('Фамилия', max_length = 30)
	tg_id = models.CharField('tg_id', max_length = 10)


	def __str__(self):
		return self.user_name

	class Meta:
		verbose_name = "Пользователь"
		verbose_name_plural = "Пользователи"

class Bot(models.Model):
	user = models.ForeignKey(User, on_delete = models.CASCADE)
	option = models.CharField('Option', max_length = 30)
	global_id = models.CharField('Global id', max_length = 30)
	bot_name = models.CharField('Bot Name', max_length = 30)
	bot_username = models.CharField('Bot Username', max_length = 30)
	token = models.CharField('Token', max_length = 100)
	status = models.IntegerField('Status', default=1)
	pID = models.IntegerField('pID', default=0)

	def __str__(self):
		return (str(self.id) + "_" + str(self.user))

	class Meta:
		verbose_name = "Бот"
		verbose_name_plural = "Боты"

class BotUser(models.Model):
	bot_name = models.ForeignKey(Bot, on_delete = models.CASCADE)
	username = models.CharField('Username', max_length = 30)
	first_name = models.TextField('Имя', max_length = 30)
	last_name = models.TextField('Фамилия', max_length = 30)
	tg_id = models.CharField('Id telegram', max_length = 10)
	pathAvatar = models.CharField('Avatar Path ', max_length = 200)
	dateReg = models.CharField('Дата регистрации', max_length = 200)

	def __str__(self):
		return (str(self.bot_name))

	class Meta:
		verbose_name = "Пользователь Бота"
		verbose_name_plural = "Пользователи Бота"

class Messages(models.Model):
	bot_name = models.ForeignKey(Bot, on_delete = models.CASCADE)
	count = models.IntegerField('Count', default=0)
	date = models.CharField('Date', max_length = 30)

	def __str__(self):
		return (str(self.bot_name))

	class Meta:
		verbose_name = "Сообщение"
		verbose_name_plural = "Сообщения"
#
class BotBranch(models.Model):
	bot_name = models.ForeignKey(Bot, on_delete = models.CASCADE)
	branch = models.CharField('Сценарий', max_length = 100, default=0)
	def __str__(self):
		return (str(self.branch))

	class Meta:
		verbose_name = "Сценарий бота"
		verbose_name_plural = "Сценарии бота"

class BranchButton(models.Model):
	button_color = models.CharField('Цвет кнопки', max_length = 100, default=0)
	button_name = models.CharField('Имя кнопки', max_length = 100, default=0)
	button_text = models.CharField('Текст кнопки', max_length = 100, default=0)
	def __str__(self):
		return (str(self.button_name))

	class Meta:
		verbose_name = "BranchButton"
		verbose_name_plural = "BranchButtons"



class BranchPic(models.Model):
	pic_path = models.CharField('Путь картинки', max_length = 100)
	def __str__(self):
		return (str(self.pic_path))

	class Meta:
		verbose_name = "BranchPic"
		verbose_name_plural = "BranchPics"



class CustomCommand(models.Model):
	bot_branch = models.ForeignKey(BotBranch, on_delete = models.CASCADE)
	branch_button_id = models.CharField('ID кнопки сценария', max_length = 1000)
	branch_pic_id =  models.CharField('ID картинки Сценария', max_length = 1000)
	branch_text_id =  models.CharField('ID текста Сценария', max_length = 1000)
	# bot_name = models.ForeignKey(Bot, on_delete = models.CASCADE)
	step = models.IntegerField('Шаг', default=0)
	action = models.CharField('Действие', max_length = 30, default=0)
	# doc_path = models.CharField('Путь документа', max_length = 100, default=0)
	# command = models.CharField('Ключевое слово', max_length = 100, default=0)
	# response = models.CharField('Ответ', max_length = 500, default=0)

	def __str__(self):
		return (str(self.bot_branch))

	class Meta:
		verbose_name = "Пользовательские команды"
		verbose_name_plural = "Пользовательская команда"
class BranchText(models.Model):
	# custom_command = models.ForeignKey(CustomCommand, on_delete = models.CASCADE)
	# custom_command_id =  models.CharField('ID Команды', max_length = 1000, default=0)
	text = models.CharField('Текст поля', max_length = 100, default=0)
	def __str__(self):
		return (str(self.text))

	class Meta:
		verbose_name = "BranchText"
		verbose_name_plural = "BranchTexts"
