def msg_all(bot, update, args): message = ' '.join(args).upper() user = update.message.from_user user_id = user.id msg_broadcast = ("%s %s: %s" % (user_id, user.first_name, message)) for chat in map(lambda x: x[0], persistence.get_admin_chat_ids(db_file)): if chat != 0: bot.send_message(chat, text=msg_broadcast)
def broadcast(update, context, message): user = update.message.from_user user_id = user.id msg_broadcast = ("%s %s: %s" % (user_id, user.first_name, message)) for each_chat in map(lambda x: x[0], persistence.get_admin_chat_ids(db_file)): if each_chat != 0: context.bot.send_message(each_chat, text=msg_broadcast)
def broadcast(): tokenparam = request.args.get('token') msg = request.args.get('msg') if tokenparam == token: for chat in map(lambda x: x[0], persistence.get_admin_chat_ids(db_file)): if chat != 0: bot.send_message(chat, text=msg) return "Sent {}".format(msg)
dispatcher.add_handler(CommandHandler('start', start)) dispatcher.add_handler(CommandHandler('cmds', commands)) dispatcher.add_handler(MessageHandler(Filters.text, on_text)) dispatcher.add_handler(MessageHandler(Filters.contact, on_contact)) dispatcher.add_handler(MessageHandler(Filters.document, on_document)) logging.info("Allowed ids: %s" % str(allowed_ids)) logging.info("Starting bot") updater.start_polling() bot = updater.bot for chat in map(lambda x: x[0], persistence.get_admin_chat_ids(db_file)): if chat != 0: bot.send_message(chat, text="Bot started") @app.route('/broadcast') def broadcast(): tokenparam = request.args.get('token') msg = request.args.get('msg') if tokenparam == token: for chat in map(lambda x: x[0], persistence.get_admin_chat_ids(db_file)): if chat != 0: bot.send_message(chat, text=msg) return "Sent {}".format(msg)