Example #1
0
def delete(update, context):
	"""Show new choice of buttons"""
	query = update.callback_query
	query.answer()

	data = query.data.split('_')
	id = int(data[1])
	user = UsersClass(query.from_user.id)
	notes = NotesClass(user.client, None)
	notes.delete(id)
	notes.get({'page': 1, 'count': settings.COUNT_PAGE})

	if(notes.state):
		context.bot.edit_message_media(chat_id=query.message.chat_id, message_id=query.message.message_id, reply_markup=notes.reply_markup, media=InputMediaPhoto(media=notes.scheduler.file_patch, caption=notes.scheduler.body, parse_mode='Markdown'))
		return 'TIMING'
	else:
		buttons = [
			InlineKeyboardButton("πŸ“ ΠŸΠ»Π°Π½ΠΈΡ€ΠΎΠ²Ρ‰ΠΈΠΊ", callback_data='100'),
			InlineKeyboardButton("⚠️ Π’Π°ΠΆΠ½Ρ‹Π΅ Π΄Π°Ρ‚Ρ‹", callback_data='200'),
		]
		keyboard = settings.constructor(buttons, settings.COUNT_ROW)
		reply_markup = InlineKeyboardMarkup(keyboard)
		
		context.bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id)
		context.bot.send_message(chat_id=query.message.chat.id, text="Π­Ρ‚ΠΎ ваш ΠΏΠ΅Ρ€ΡΠΎΠ½Π°Π»ΡŒΠ½Ρ‹ΠΉ ΠΏΠ»Π°Π½ΠΈΡ€ΠΎΠ²Ρ‰ΠΈΠΊ Π΄Π΅Π» Π½Π° дСнь, нСдСлю, мСсяц ΠΈ ΠΊΠ²Π°Ρ€Ρ‚Π°Π»", reply_markup=reply_markup, parse_mode='Markdown')
	return 'TIMING'
Example #2
0
def pagin(update, context):
	"""Show new choice of buttons"""
	query = update.callback_query
	query.answer()

	data = query.data.split('_')
	print(data)
	page = int(data[1])

	user = UsersClass(query.from_user.id)
	notes = NotesClass(user.client, None)
	notes.get({'page': page, 'count': settings.COUNT_PAGE})
	if(notes.state):
		context.bot.edit_message_media(chat_id=query.message.chat_id, message_id=query.message.message_id, reply_markup=notes.reply_markup, media=InputMediaPhoto(media=notes.scheduler.file_patch, caption=notes.scheduler.body, parse_mode='Markdown'))
		return 'TIMING'
	else:
		user.create_dialog('TIMING|104')
		context.bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id)
		context.bot.send_message(chat_id=query.message.chat.id, text='Π’Π²Π΅Π΄ΠΈΡ‚Π΅ тСкст напоминания ΠΈΠ»ΠΈ ΠΎΡ‚ΠΏΡ€Π°Π²ΡŒΡ‚Π΅ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ', parse_mode='Markdown')
		return 'DIALOG'
Example #3
0
def one(update, context):
	"""Show new choice of buttons"""
	query = update.callback_query
	query.answer()

	user = UsersClass(query.from_user.id)
	notes = NotesClass(user.client, None)
	if('_' in query.data):
		notes.get({'page': 1, 'count': settings.COUNT_PAGE, 'note_id': query.data.split('_')[1]})
	else:
		notes.get({'page': 1, 'count': settings.COUNT_PAGE})

	if(notes.state):
		if(notes.scheduler.file_patch):
			# context.bot.deleteMessage(chat_id=query.message.chat.id, message_id=update.message.message_id)
			context.bot.sendPhoto(chat_id=query.message.chat.id, photo=notes.scheduler.file_patch, caption=notes.scheduler.body, reply_markup=notes.reply_markup, parse_mode='Markdown')
		else:
			query.edit_message_text(
				text=notes.scheduler.body,
				reply_markup=notes.reply_markup,
				parse_mode='Markdown'
			)
		return 'TIMING'
	else:
		user.create_dialog('TIMING|104')

		buttons = [
				InlineKeyboardButton("ΠžΡ‚ΠΌΠ΅Π½ΠΈΡ‚ΡŒ ❌", callback_data='777'),
		]
		keyboard = settings.constructor(buttons, settings.COUNT_ROW)
		reply_markup = InlineKeyboardMarkup(keyboard)
		query.edit_message_text(
			'Π’Π²Π΅Π΄ΠΈΡ‚Π΅ тСкст напоминания ΠΈΠ»ΠΈ ΠΎΡ‚ΠΏΡ€Π°Π²ΡŒΡ‚Π΅ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ',
			reply_markup=reply_markup,
			parse_mode='Markdown'
		)
		return 'DIALOG'
Example #4
0
def text(update, context):
	query = update.message
	print(query)
	user = UsersClass(query.from_user.id)
	if(user.dialog):
		data = user.dialog.data.split('|')
		print(data)

		step = data[0]
		action = data[1]

		if(step == 'TIMING'):
			if(action == '104'):
				notes = NotesClass(user.client, None)
				notes.create(update.message.text)
				notes.get({'page': 1, 'count': settings.COUNT_PAGE})
				if(notes.state):
					context.bot.sendPhoto(chat_id=query.chat.id, photo=notes.scheduler.file_patch, caption=notes.scheduler.body, reply_markup=notes.reply_markup)
					user.delete_dialog()
				else:
					user.create_dialog('TIMING|104')
					update.message.reply_text('Π’Π²Π΅Π΄ΠΈΡ‚Π΅ тСкст напоминания')
					return 'DIALOG'

			elif(action == '108'):
				id = data[2]
				notes = NotesClass(user.client, None)
				notes.update(type_up='body', id=id, data=update.message.text)
				notes.detail(id)
				
				context.bot.sendPhoto(chat_id=query.chat.id, photo=notes.scheduler.file_patch, caption=notes.scheduler.body, reply_markup=notes.reply_markup)
				user.delete_dialog()

			elif(action == '200'):
				notes = ImportantClass(user.client, None)
				notes.create(update.message.text)
				notes.get({'page': 1, 'count': settings.COUNT_PAGE})
				if(notes.state):
					# context.bot.sendPhoto(chat_id=query.chat.id, photo=notes.important.file_patch, caption=notes.important.body, reply_markup=notes.reply_markup)
					user = UsersClass(query.from_user.id)
					notes = ImportantClass(user.client, notes.important.id)
					user.delete_dialog()
					user.create_dialog('TIMING|209|{}'.format(notes.important.id))

					# context.bot.deleteMessage(chat_id=query.message.chat_id, message_id=query.message.message_id)
					context.bot.send_message(chat_id=query.chat.id, text='Π’Π²Π΅Π΄ΠΈΡ‚Π΅ Π΄Π°Ρ‚Ρƒ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ Π΄Π΄.ΠΌΠΌ', parse_mode='Markdown')
					return 'DIALOG'
				else:
					user.create_dialog('TIMING|200')
					update.message.reply_text('Π’Π²Π΅Π΄ΠΈΡ‚Π΅ тСкст напоминания')
					return 'DIALOG'
				
				# context.bot.sendPhoto(chat_id=query.chat.id, photo=settings.MEDIA_TECH, caption=notes.important.body, reply_markup=notes.reply_markup)
				# user.delete_dialog()

			elif(action == '208'):
				id = data[2]
				notes = ImportantClass(user.client, None)
				notes.update(type_up='body', id=id, data=update.message.text)
				notes.detail(id)
				
				context.bot.sendPhoto(chat_id=query.chat.id, photo=notes.important.file_patch, caption=notes.important.body, reply_markup=notes.reply_markup)
				user.delete_dialog()

			elif(action == '209'):
				date = update.message.text.split('.')
				if(len(date) != 2):
					context.bot.send_message(chat_id=query.chat.id, text='Π’Π²Π΅Π΄ΠΈΡ‚Π΅ Π΄Π°Ρ‚Ρƒ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ Π΄Π΄.ΠΌΠΌ', parse_mode='Markdown')
					return '{}'.format(step)

				if(date[0][0] == '0'):
					day = date[0][1]
				else:
					day = date[0]

				if(date[1][0] == '0'):
					month = date[1][1]
				else:
					month = date[1]

				if not (1 <= int(day) <= 31):
					context.bot.send_message(chat_id=query.chat.id, text='Π’Π²Π΅Π΄ΠΈΡ‚Π΅ Π΄Π°Ρ‚Ρƒ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ Π΄Π΄.ΠΌΠΌ', parse_mode='Markdown')
					return '{}'.format(step)

				if not (1 <= int(month) <= 12):
					context.bot.send_message(chat_id=query.chat.id, text='Π’Π²Π΅Π΄ΠΈΡ‚Π΅ Π΄Π°Ρ‚Ρƒ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ Π΄Π΄.ΠΌΠΌ', parse_mode='Markdown')
					return '{}'.format(step)

				now = datetime.datetime.now()
				month_day = calendar.monthrange(now.year, 1)[1]

				if (int(day) > month_day):
					context.bot.send_message(chat_id=query.chat.id, text='Π’ Π΄Π°Π½Π½ΠΎΠΌ мСсяцС количСство Π΄Π½Π΅ΠΉ = {}'.format(month_day), parse_mode='Markdown')
					return '{}'.format(step)

				id = data[2]
				notes = ImportantClass(user.client, None)
				notes.update(type_up='date', id=id, data=[day, month])
				notes.detail(id)
				
				if(notes.important.hour == None or notes.important.minute == None):
					buttons = []
					for x in range(1, 24):
						prefix = ''
						if(notes.important.hour == x):
							prefix = 'βœ…'

						buttons.append(InlineKeyboardButton('{}{}'.format(prefix, x), callback_data='211_{}_{}'.format(notes.important.id, x)))

					keyboard = settings.constructor(buttons, 4)
					reply_markup = InlineKeyboardMarkup(keyboard)

					context.bot.sendPhoto(chat_id=query.chat.id, photo=notes.important.file_patch, caption='Π’Ρ‹Π±Π΅Ρ€ΠΈΡ‚Π΅ час', reply_markup=reply_markup)
					user.delete_dialog()
					return 'DIALOG'

				context.bot.sendPhoto(chat_id=query.chat.id, photo=notes.important.file_patch, caption=notes.important.body, reply_markup=notes.reply_markup)
				user.delete_dialog()

		return '{}'.format(step)