Example #1
0
 def process_ajax(sub, req):
     try:
         if sub == 'telegram_test':
             ret = ToolBaseNotify.send_telegram_message(
                 req.form['text'],
                 bot_token=req.form['bot_token'],
                 chat_id=req.form['chat_id'])
             return jsonify(ret)
         elif sub == 'discord_test':
             ret = ToolBaseNotify.send_discord_message(
                 req.form['text'], webhook_url=req.form['url'])
             return jsonify(ret)
         elif sub == 'advanced_test':
             ret = ToolBaseNotify.send_advanced_message(
                 req.form['text'],
                 policy=req.form['policy'],
                 message_id=req.form['message_id'])
             return jsonify(ret)
         elif sub == 'scheduler':
             go = request.form['scheduler']
             logger.debug('scheduler :%s', go)
             if go == 'true':
                 SystemLogicTelegramBot.scheduler_start()
             else:
                 SystemLogicTelegramBot.scheduler_stop()
             return jsonify(go)
     except Exception as exception:
         logger.error('Exception:%s', exception)
         logger.error(traceback.format_exc())
         return jsonify('exception')
Example #2
0
 def process_ajax(sub, req):
     try:
         if sub == 'telegram_test':
             ret = ToolBaseNotify.send_telegram_message(
                 req.form['text'],
                 bot_token=req.form['bot_token'],
                 chat_id=req.form['chat_id'])
             return jsonify(ret)
         elif sub == 'discord_test':
             ret = ToolBaseNotify.send_discord_message(
                 req.form['text'], webhook_url=req.form['url'])
             return jsonify(ret)
         elif sub == 'advanced_test':
             ret = ToolBaseNotify.send_advanced_message(
                 req.form['text'],
                 policy=req.form['policy'],
                 message_id=req.form['message_id'])
             return jsonify(ret)
     except Exception as exception:
         logger.error('Exception:%s', exception)
         logger.error(traceback.format_exc())
         return jsonify('exception')