-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoin.py
125 lines (117 loc) · 4.97 KB
/
coin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import time
import discord
from discord.ext import commands
import os.path
import os
from time import gmtime, strftime
import random
from chatGPT import responses
config = responses.get_config()
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
bot = commands.Bot(command_prefix='!', help_command = None, intents=intents)
@bot.event
async def on_ready():
print(f'Logged COIN as {bot.user} (ID: {bot.user.id})')
print('------')
@bot.command()
async def coin(ctx):
if ctx.guild != None:
f = open("var.txt", "w")
f.write(str(ctx.author))
f.close()
run = 1
begintime = int(strftime("%S"))
print(begintime)
randomint = random.randint(3, 8)
await ctx.send(f'{str(ctx.author)[:-5]}, готов?', delete_after=randomint)
endtime = begintime+randomint
if endtime > 59:
endtime = endtime - 60
print(endtime)
while run == 1:
f = open("var.txt", "r")
if f.read() == "shoot":
f.close()
await ctx.send(":bruh:")
f = open("var.txt", "w")
f.write(" ")
f.close()
run = 0
if run == 1 and int(strftime("%S")) == endtime:
f.close()
begintime = int(strftime("%S"))
endtime = begintime+2
if endtime > 59:
endtime = endtime - 60
print(begintime)
print(endtime)
print("SHOOT!")
begintime_ns = time.time_ns()
await ctx.send('https://cdn.discordapp.com/attachments/832604996720918574/1041934924560732190/Coin_Throw.gif', delete_after=1)
while run == 1:
f = open("var.txt", "r")
if f.read() == "shoot":
endtime_ns = time.time_ns()
f.close()
await ctx.send("https://cdn.discordapp.com/attachments/832604996720918574/1041939967758319686/Coin_Shoot.gif", delete_after=2)
realtime_ns = endtime_ns - begintime_ns
realtime = round(realtime_ns / 1000000)
print(f"Time = {realtime}")
if realtime > 799:
realtime = realtime - 800
elif realtime < 800 and realtime > 399:
realtime = 0
elif realtime < 400:
realtime = realtime - 400
await ctx.send(f'Твой счёт: {realtime} мс.')
f = open("var.txt", "w")
f.write(" ")
f.close()
if os.path.isfile(f'./scores/{str(ctx.author)}') == False:
f = open(f'./scores/{str(ctx.author)}', "w")
f.write("2000")
f.close()
f = open(f'./scores/{str(ctx.author)}', "r");
a = f.read()
if int(a) > realtime:
f.close()
f = open(f'./scores/{str(ctx.author)}', "w");
f.write(str(realtime))
f.close()
f.close()
if os.path.isfile(f'./coins/{str(ctx.author)}') == False:
f = open(f'./coins/{str(ctx.author)}', "w")
f.write("0")
f.close()
f = open(f'./coins/{str(ctx.author)}', "r");
a = f.read()
f.close()
if realtime > 299:
a = int(a) + 1
await ctx.send("+1 монета")
elif realtime < 300 and realtime > -1:
a = int(a) + 2
await ctx.send("+2 монеты")
elif realtime < 0:
a = int(a) + 3
await ctx.send("+3 монеты")
f = open(f'./coins/{str(ctx.author)}', "w");
f.write(str(a))
f.close()
run = 0
if int(strftime("%S")) == endtime:
f.close()
f = open("var.txt", "w")
f.write(" ")
f.close()
run = 0
else:
await ctx.send("Эта команда отключена в личных сообщениях.")
@bot.command(name='bot')
async def _bot(ctx):
time.sleep(4)
await ctx.send('[Console] Coin Initialized')
token = config['V1_token']
bot.run(token)