Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ready(message, content_type, mestext, caption, file_id, btns):
- uid = message.from_user.id
- text = message.text
- if text == "Добавить кнопку":
- msg = bot.send_message(uid, "Отправьте название кнопки", reply_markup=types.ReplyKeyboardRemove())
- bot.register_next_step_handler(msg, add_name, content_type, mestext, caption, file_id, btns)
- if text == "Отправить рассылку":
- bot.send_message(uid, "Началась рассылка", reply_markup=types.ReplyKeyboardRemove())
- users_file = open('users', 'r')
- users = users_file.read().split('.')
- users_file.close()
- if btns:
- markup = types.InlineKeyboardMarkup()
- for name, link in btns.items():
- btn = types.InlineKeyboardButton(text=name, url=link)
- markup.add(btn)
- for user in users:
- try:
- if content_type == "text":
- bot.send_message(user, mestext, reply_markup=markup, parse_mode="HTML")
- time.sleep(0.06)
- elif content_type == "photo":
- if caption:
- bot.send_photo(user, file_id, caption=caption, reply_markup=markup, parse_mode="HTML")
- time.sleep(0.06)
- else:
- bot.send_photo(user, file_id, reply_markup=markup)
- time.sleep(0.06)
- elif content_type == "video":
- if caption:
- bot.send_video(user, file_id, caption=caption, reply_markup=markup, parse_mode="HTML")
- time.sleep(0.06)
- else:
- bot.send_video(user, file_id, reply_markup=markup)
- time.sleep(0.06)
- elif content_type == "document":
- if caption:
- bot.send_document(user, file_id, caption=caption, reply_markup=markup, parse_mode="HTML")
- time.sleep(0.06)
- else:
- bot.send_document(user, file_id, reply_markup=markup)
- time.sleep(0.06)
- elif content_type == "animation":
- if caption:
- bot.send_animation(user, file_id, caption=caption, reply_markup=markup, parse_mode="HTML")
- time.sleep(0.06)
- else:
- bot.send_animation(user, file_id, reply_markup=markup)
- time.sleep(0.06)
- except:
- pass
- else:
- for user in users:
- try:
- if content_type == "text":
- bot.send_message(user, mestext, parse_mode="HTML")
- time.sleep(0.06)
- elif content_type == "photo":
- if caption:
- bot.send_photo(user, file_id, caption=caption, parse_mode="HTML")
- time.sleep(0.06)
- else:
- bot.send_photo(user, file_id)
- time.sleep(0.06)
- elif content_type == "video":
- if caption:
- bot.send_video(user, file_id, caption=caption, parse_mode="HTML")
- time.sleep(0.06)
- else:
- bot.send_video(user, file_id)
- time.sleep(0.06)
- elif content_type == "document":
- if caption:
- bot.send_document(user, file_id, caption=caption, parse_mode="HTML")
- time.sleep(0.06)
- else:
- bot.send_document(user, file_id)
- time.sleep(0.06)
- elif content_type == "animation":
- if caption:
- bot.send_animation(user, file_id, caption=caption, parse_mode="HTML")
- time.sleep(0.06)
- else:
- bot.send_animation(user, file_id)
- time.sleep(0.06)
- except:
- pass
- bot.send_message(uid, "Рассылка прошла успешно.")
Advertisement
Add Comment
Please, Sign In to add comment