Esempio n. 1
0
		def sending_org():
			
			usersList = get_users_list()

			for i in range(len(usersList)):
				if usersList[i] != '' and usersList[i] != None:
					send_now(usersList[i])
Esempio n. 2
0
def construct_message(message_chat_id):
	usersList = get_users_list()
	if str(message_chat_id) in usersList:
		message = Message_Template(
				chat_id = message_chat_id,
				text = COMMAND_TEXT, 

				disable_web_page_preview=DISABLE_WEB_PAGE_PREVIEW,
				reply_to_message_id=REPLY_TO_MESSAGE_ID, 
				reply_markup=REPLY_MARKUP_FOLLOWED,
				parse_mode=PARSE_MODE, 
				disable_notification=DISABLE_NOTIFICATION, 
				timeout=None
			)
		return message
	else:
		message = Message_Template(
				chat_id = message_chat_id,
				text = COMMAND_TEXT, 

				disable_web_page_preview=DISABLE_WEB_PAGE_PREVIEW,
				reply_to_message_id=REPLY_TO_MESSAGE_ID, 
				reply_markup=REPLY_MARKUP_UNFOLLOWED,
				parse_mode=PARSE_MODE, 
				disable_notification=DISABLE_NOTIFICATION, 
				timeout=None
			)
		return message
Esempio n. 3
0
		def send_now(user):
			params = info.construct_message(user)
			try:
				bot.send_message(chat_id=params.chat_id,
					text=params.text + '\nСпасибо, что подписались на ежедневную рассылку❤️',
					reply_markup=params.reply_markup)
			except:
				bot.send_message(config.ADMIN_ID, f'user {user} blocked the bot, i\'ll unfollow him automatically')
				del_user_from_users_list(user)
				usersList = get_users_list()
				bot.send_message(config.ADMIN_ID, f'new users list is {usersList}')
Esempio n. 4
0
	def send_unfollow_message(message):
		try:
			params = unfollow.construct_message(message.chat.id)
			bot.send_message(chat_id=params.chat_id,
				text=params.text,
				parse_mode=params.parse_mode,
				reply_markup=params.reply_markup)

			bot.send_message(config.ADMIN_ID, ' '.join(get_users_list()))

		except AttributeError as e:
			print(repr(e))
			bot.send_message(chat_id=message.chat.id, text='Эта команда в данный момент недоступна.')
Esempio n. 5
0
def construct_message(message_chat_id):
    if str(message_chat_id) not in get_users_list():
        add_user_to_users_list(message_chat_id)
        message = Message_Template(
            chat_id=message_chat_id,
            text=COMMAND_TEXT_POS,
            disable_web_page_preview=DISABLE_WEB_PAGE_PREVIEW,
            reply_to_message_id=REPLY_TO_MESSAGE_ID,
            reply_markup=REPLY_MARKUP_POS,
            parse_mode=PARSE_MODE,
            disable_notification=DISABLE_NOTIFICATION,
            timeout=None)
        return message
    else:
        message = Message_Template(
            chat_id=message_chat_id,
            text=COMMAND_TEXT_NEG,
            disable_web_page_preview=DISABLE_WEB_PAGE_PREVIEW,
            reply_to_message_id=REPLY_TO_MESSAGE_ID,
            reply_markup=REPLY_MARKUP_NEG,
            parse_mode=PARSE_MODE,
            disable_notification=DISABLE_NOTIFICATION,
            timeout=None)
        return message
Esempio n. 6
0
	def send_inline_callback(call):
		try:
			if call.message:
				if call.data == 'help':
					try:
						params = help.construct_message(call.message.chat.id)
						bot.edit_message_text(chat_id=call.message.chat.id, 
							message_id=call.message.message_id,
							text=params.text, 
							reply_markup=params.reply_markup)
					except Exception:
						bot.delete_message(chat_id=call.message.chat.id,
							message_id=call.message.message_id)
						send_help_message(call.message)

				elif call.data == 'info':
					try:
						params = info.construct_message(call.message.chat.id)
						bot.edit_message_text(chat_id=call.message.chat.id,
							message_id=call.message.message_id,
							text=params.text,
							reply_markup=params.reply_markup)
					except Exception:
						bot.delete_message(chat_id=call.message.chat.id,
							message_id=call.message.message_id)
						send_info_message(call.message)

				elif call.data == 'sub':
					try:
						params = sub.construct_message(call.message.chat.id)
						bot.edit_message_text(chat_id=call.message.chat.id,
							message_id=call.message.message_id,
							text=params.text,
							reply_markup=params.reply_markup)

						bot.send_message(config.ADMIN_ID, 'Кто-то подписался/отписался\n\n' +' '.join(get_users_list()))
					
					except Exception:
						bot.delete_message(chat_id=call.message.chat.id,
							message_id=call.message.message_id)

						bot.send_message(chat_id=params.chat_id,
							text=params.text,
							parse_mode=params.parse_mode,
							reply_markup=params.reply_markup)

				elif call.data == 'unfollow':
					try:
						params = unfollow.construct_message(call.message.chat.id)
						bot.edit_message_text(chat_id=call.message.chat.id,
							message_id=call.message.message_id,
							text=params.text,
							reply_markup=params.reply_markup)

						bot.send_message(config.ADMIN_ID, 'Кто-то подписался/отписался\n\n' +' '.join(get_users_list()))

					except Exception:
						bot.delete_message(chat_id=call.message.chat.id,
							message_id=call.message.message_id)
						
						bot.send_message(chat_id=params.chat_id,
							text=params.text,
							parse_mode=params.parse_mode,
							reply_markup=params.reply_markup)

				elif call.data == 'report':
					try:
						params = report.construct_message(call.message.chat.id)
						bot.edit_message_text(chat_id=call.message.chat.id,
							message_id=call.message.message_id,
							text=params.text + f'\n\nmessage.chat.id - {call.message.chat.id}\nmessage.from_user.id - {call.message.from_user.id}\nmessage.chat.type - {call.message.chat.type}',
							reply_markup=params.reply_markup)

					except Exception:
						params = report.construct_message(call.message.chat.id)
						bot.delete_message(chat_id=call.message.chat.id,
							message_id=call.message.message_id)
						send_report_message(call.message)

				elif call.data == 'author':
					try:
						params = author.construct_message(call.message.chat.id)
						bot.edit_message_text(chat_id=call.message.chat.id,
							message_id=call.message.message_id,
							text=params.text,
							reply_markup=params.reply_markup)

					except Exception:
						params = author.construct_message(call.message.chat.id)
						bot.delete_message(chat_id=call.message.chat.id,
							message_id=call.message.message_id)
						send_report_message(call.message)

				elif call.data == 'donate':
					try:
						bot.delete_message(chat_id=call.message.chat.id,
							message_id=call.message.message_id)
						send_report_message(call.message)

					except Exception:
						bot.edit_message_text(chat_id=call.message.chat.id, 
							message_id=call.message.message_id,
							text='Кажется, произошла какая=то ошибка. Используйте команду /report, чтобы сообщить',
							reply_markup=report.construct_message(call.message.chat.id).reply_markup)

				elif call.data == 'picture':
					try:
						params = info.construct_message(call.message.chat.id)
						bot.delete_message(chat_id=call.message.chat.id,
							message_id=call.message.message_id)
						CALLBACK_MARKUP = info.construct_markup(call.message.chat.id)
						bot.send_photo(chat_id=call.message.chat.id, 
							caption=params.text,
							photo=open('out.jpeg', 'rb'),
							reply_markup=CALLBACK_MARKUP)
					except Exception:
						bot.send_message(config.ADMIN_ID, 'Какая-то ошибка с callback методом picture')

		except Exception as e:
			print(repr(e))
Esempio n. 7
0
		def mail_org():
			usersList = get_users_list()
			for i in range(len(usersList)):
				if usersList[i] != '' and usersList[i] != None:
					send_mail_now(int(usersList[i]))
Esempio n. 8
0
def construct_markup(message_chat_id):
	usersList = get_users_list()
	if str(message_chat_id) in usersList:
		return CALLBACK_MARKUP_FOLLOWED
	else:
		return CALLBACK_MARKUP_UNFOLLOWED