Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, render_template, request, jsonify
- import discum
- import time
- import random
- import threading
- app = Flask(__name__)
- try:
- DT = open("token.txt", "r").read().strip()
- except FileNotFoundError:
- print("token.txt not found")
- exit()
- raids = [
- {"name": "Last Wish", "big": "489911398025920513", "small": "1080056128240631869"},
- {"name": "Deep Stone Crypt", "big": "780123659183849492", "small": "1080056027912876062"},
- {"name": "Vault Of Glass", "big": "894652222523203645", "small": "1080056025182392331"},
- {"name": "Garden Of Salvation", "big": "628624111165374494", "small": "1080056183072751636"},
- {"name": "Vow Of The Disciple", "big": "949726571973992508", "small": "1080055964897660959"},
- {"name": "Kings Fall", "big": "1004189641966092430", "small": "1080055833850806312"},
- {"name": "Crotas End", "big": "1134068958706815016", "small": "1140402589758927009"}
- ]
- lfg_message = ""
- running = False
- message_ids = {"big": [], "small": []}
- bot = discum.Client(token=DT)
- def send_messages(big_channel_id, small_channel_id):
- global running
- while running:
- time.sleep(random.uniform(1.3, 2.0))
- res1 = bot.sendMessage(small_channel_id, lfg_message)
- message_ids["small"].append(res1.json()['id'])
- time.sleep(random.uniform(0.45, 0.70))
- res2 = bot.sendMessage(big_channel_id, lfg_message)
- message_ids["big"].append(res2.json()['id'])
- time.sleep(random.randint(28, 30))
- bot.deleteMessage(small_channel_id, res1.json()['id'])
- message_ids["small"].remove(res1.json()['id'])
- time.sleep(random.randint(1, 2))
- bot.deleteMessage(big_channel_id, res2.json()['id'])
- message_ids["big"].remove(res2.json()['id'])
- @app.route('/')
- def index():
- return render_template('index.html', raids=raids)
- @app.route('/start_lfg', methods=['POST'])
- def start_lfg():
- global lfg_message, running
- data = request.json
- selected_raid = raids[int(data['selectedRaid'])]
- lfg_amount = data['lfgAmount']
- lfg_message = f"LF{lfg_amount}M fresh KWTD dm for invite :)"
- running = True
- threading.Thread(target=send_messages, args=(selected_raid['big'], selected_raid['small'])).start()
- return jsonify({"status": "LFG started"})
- @app.route('/stop_lfg', methods=['POST'])
- def stop_lfg():
- global running
- running = False
- for msg_id in message_ids["small"]:
- bot.deleteMessage(raids[int(request.json['selectedRaid'])]['small'], msg_id)
- for msg_id in message_ids["big"]:
- bot.deleteMessage(raids[int(request.json['selectedRaid'])]['big'], msg_id)
- message_ids["small"].clear()
- message_ids["big"].clear()
- return jsonify({"status": "LFG stopped"})
- if __name__ == '__main__':
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement