Advertisement
selfharm

aa

May 22nd, 2024
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.81 KB | None | 0 0
  1. from flask import Flask, render_template, request, jsonify
  2. import discum
  3. import time
  4. import random
  5. import threading
  6.  
  7. app = Flask(__name__)
  8.  
  9. try:
  10.     DT = open("token.txt", "r").read().strip()
  11. except FileNotFoundError:
  12.     print("token.txt not found")
  13.     exit()
  14.  
  15. raids = [
  16.     {"name": "Last Wish", "big": "489911398025920513", "small": "1080056128240631869"},
  17.     {"name": "Deep Stone Crypt", "big": "780123659183849492", "small": "1080056027912876062"},
  18.     {"name": "Vault Of Glass", "big": "894652222523203645", "small": "1080056025182392331"},
  19.     {"name": "Garden Of Salvation", "big": "628624111165374494", "small": "1080056183072751636"},
  20.     {"name": "Vow Of The Disciple", "big": "949726571973992508", "small": "1080055964897660959"},
  21.     {"name": "Kings Fall", "big": "1004189641966092430", "small": "1080055833850806312"},
  22.     {"name": "Crotas End", "big": "1134068958706815016", "small": "1140402589758927009"}
  23. ]
  24.  
  25. lfg_message = ""
  26. running = False
  27. message_ids = {"big": [], "small": []}
  28.  
  29. bot = discum.Client(token=DT)
  30.  
  31. def send_messages(big_channel_id, small_channel_id):
  32.     global running
  33.     while running:
  34.         time.sleep(random.uniform(1.3, 2.0))
  35.         res1 = bot.sendMessage(small_channel_id, lfg_message)
  36.         message_ids["small"].append(res1.json()['id'])
  37.         time.sleep(random.uniform(0.45, 0.70))
  38.         res2 = bot.sendMessage(big_channel_id, lfg_message)
  39.         message_ids["big"].append(res2.json()['id'])
  40.         time.sleep(random.randint(28, 30))
  41.         bot.deleteMessage(small_channel_id, res1.json()['id'])
  42.         message_ids["small"].remove(res1.json()['id'])
  43.         time.sleep(random.randint(1, 2))
  44.         bot.deleteMessage(big_channel_id, res2.json()['id'])
  45.         message_ids["big"].remove(res2.json()['id'])
  46.  
  47. @app.route('/')
  48. def index():
  49.     return render_template('index.html', raids=raids)
  50.  
  51.  
  52. @app.route('/start_lfg', methods=['POST'])
  53. def start_lfg():
  54.     global lfg_message, running
  55.     data = request.json
  56.     selected_raid = raids[int(data['selectedRaid'])]
  57.     lfg_amount = data['lfgAmount']
  58.     lfg_message = f"LF{lfg_amount}M fresh KWTD dm for invite :)"
  59.    
  60.     running = True
  61.     threading.Thread(target=send_messages, args=(selected_raid['big'], selected_raid['small'])).start()
  62.    
  63.     return jsonify({"status": "LFG started"})
  64.  
  65. @app.route('/stop_lfg', methods=['POST'])
  66. def stop_lfg():
  67.     global running
  68.     running = False
  69.     for msg_id in message_ids["small"]:
  70.         bot.deleteMessage(raids[int(request.json['selectedRaid'])]['small'], msg_id)
  71.     for msg_id in message_ids["big"]:
  72.         bot.deleteMessage(raids[int(request.json['selectedRaid'])]['big'], msg_id)
  73.     message_ids["small"].clear()
  74.     message_ids["big"].clear()
  75.     return jsonify({"status": "LFG stopped"})
  76.  
  77. if __name__ == '__main__':
  78.     app.run(debug=True)
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement