Skip to content

Commit 551eca3

Browse files
dj4zo6u_6dj4zo6u_6
dj4zo6u_6
authored and
dj4zo6u_6
committed
many updates
1 parent c0ccbee commit 551eca3

File tree

4 files changed

+141
-23
lines changed

4 files changed

+141
-23
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
!ohya_bot.py
33
!README.md
44
!bot_data
5-
!.gitignore
5+
!.gitignore
6+
!upd_handle.py

bot_data/distr.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{603199977874915345: 69.37457547783218, 850304005531500575: 22.694414639094145, 608188006871859231: 8.380731606611135, 764866433120206848: 311.95443265729784, 833718482011947018: 2.4950706891163486, 1162683658390487060: 1.541011346777017, 303139670508830730: 4.469086253084322, 859408731530723340: 1.541011346777017, 463749943694327818: 4.2156277438144185, 853258456664768552: 2.573319182318213, 811569133350813697: 1.541011346777017, 888783917866434591: 41.980103529377466, 599152664328142858: 1.8328398158088297, 843821667302113281: 4.80596110408413, 569549687745675265: 1.8168005998036132, 802096562616008714: 1.541011346777017, 235148962103951360: 1.541011346777017, 643069955603955724: 4.591931921930092, 708679950613348484: 7.122594261460993, 412654898090475530: 24.503967429602046, 635372429564313617: 1.541011346777017, 364761561866174465: 2.9194310493846083, 331730758555402240: 22.05479909860041, 628209104413917185: 1.841011346777017, 582151572646133770: 41.17807707742818, 477502315683774474: 1.7672107458443735, 305364865172635650: 1.541011346777017, 688028496789766219: 4.045940055532189, 734974910887362600: 1.541011346777017, 585432135855374336: 11.063875185611918, 197175057846501377: 4.601414616195158, 822426133059338261: 1.541011346777017, 1156412821953843240: 1.9830158316083188, 616263807810928642: 1.541011346777017, 407409320003633153: 1.541011346777017, 592044925428957204: 1.541011346777017, 553961833040707616: 11.964815263257083, 513165597610344458: 11.994423223947912, 531136458317365258: 36.98177259747319, 806176233434906634: 1.541011346777017, 676343695649538048: 1.541011346777017, 517691155136380929: 10.443807856205218, 589767352128897024: 1.541011346777017, 633655910551519252: 1.541011346777017, 1009666912684343358: 1.541011346777017, 478261455972728862: 5.34180868677135, 615166433793540111: 1.541011346777017, 279182058205478923: 8.463022052666174, 846686867034341388: 1.541011346777017, 844093945616269323: 16.55882326590646, 574212455786348556: 4.809874261018841, 942965454119522314: 1.541011346777017, 617706608595566592: 3.0565746513965606, 634644700720267284: 1.541011346777017, 281431001346080768: 1.541011346777017, 899445664260448277: 3.3995087859737034, 733958721750827028: 2.05510490782302, 614327736583979013: 3.7030843288699073, 604854555691319297: 27.76204344198913, 843857253185880074: 4.241011346777016, 257491879749353482: 1.541011346777017, 239377050920681472: 1.541011346777017, 806032348013133834: 3.730690463131835, 678212699175256067: 1.541011346777017, 757225258041475204: 14.275757318864102, 570492046067105827: 38.751634663623946, 603400864857718838: 14.890658494227166, 559426966151757824: 1.541011346777017, 272389275197112330: 1.8084689326486725, 363736072804368394: 22.855415331271963, 674955659711873035: 1.541011346777017, 680797161646325828: 3.1393643986466806, 758489197409206272: 1.841011346777017, 641267810605203456: 17.197193231758526, 88208179581698048: 1.541011346777017, 916686718596448267: 1.541011346777017, 695265543942307890: 1.541011346777017, 638314770159894529: 1.541011346777017, 708886890547511326: 1.541011346777017, 277445453904347136: 15.947424322712637, 944490130352246825: 1.541011346777017, 615036232598290432: 1.541011346777017, 528577926988300289: 1.541011346777017, 699967979919638588: 6.324202442406154, 330925329944281089: 22.482918436814955, 527891741055909910: 82.63694554485161, 968477545420955648: 1.541011346777017, 1160733130701951116: 1.8042828428369087, 1160733135617671249: 0.6439836030692476}
1+
{603199977874915345: 80.56023766441888, 850304005531500575: 25.58720372965826, 608188006871859231: 7.277969267348206, 764866433120206848: 332.30926465919634, 833718482011947018: 2.4589599494152794, 1162683658390487060: 1.3382403528625963, 303139670508830730: 3.881030192807754, 859408731530723340: 1.3382403528625963, 463749943694327818: 3.953120835910392, 853258456664768552: 2.234713960916679, 811569133350813697: 1.3382403528625963, 888783917866434591: 52.04843120571485, 599152664328142858: 2.4049176050625407, 843821667302113281: 5.32082302535489, 569549687745675265: 1.5777404110924913, 802096562616008714: 1.3382403528625963, 235148962103951360: 1.3382403528625963, 643069955603955724: 3.987711452207716, 708679950613348484: 10.369778098890414, 412654898090475530: 25.722119867867672, 635372429564313617: 1.3382403528625963, 364761561866174465: 2.5352833681969016, 331730758555402240: 27.37920679997082, 628209104413917185: 1.5987654338092403, 582151572646133770: 85.8363344618294, 477502315683774474: 1.5346757420362804, 305364865172635650: 1.3382403528625963, 688028496789766219: 4.1135628682426395, 734974910887362600: 1.3382403528625963, 585432135855374336: 10.508056594383696, 197175057846501377: 6.847690501165897, 822426133059338261: 1.3382403528625963, 1156412821953843240: 2.014282838743941, 616263807810928642: 1.3382403528625963, 407409320003633153: 1.3382403528625963, 592044925428957204: 1.3382403528625963, 553961833040707616: 11.834852260317877, 513165597610344458: 12.200556881590776, 531136458317365258: 42.775973596196415, 806176233434906634: 1.3382403528625963, 676343695649538048: 1.3382403528625963, 517691155136380929: 9.643245943595216, 589767352128897024: 1.3382403528625963, 633655910551519252: 1.3382403528625963, 1009666912684343358: 1.3382403528625963, 478261455972728862: 4.638917135075305, 615166433793540111: 2.214835268612085, 279182058205478923: 15.448822637564936, 846686867034341388: 1.3382403528625963, 844093945616269323: 17.948755793437492, 574212455786348556: 4.176976270650373, 942965454119522314: 1.3382403528625963, 617706608595566592: 4.15438119491516, 634644700720267284: 2.2382403528625963, 281431001346080768: 1.3382403528625963, 899445664260448277: 2.9521910054820864, 733958721750827028: 1.7846879082147904, 614327736583979013: 3.2158211484369357, 604854555691319297: 27.630545323757328, 843857253185880074: 3.68296608138239, 257491879749353482: 1.3382403528625963, 239377050920681472: 1.3382403528625963, 806032348013133834: 5.039794782980977, 678212699175256067: 1.3382403528625963, 757225258041475204: 12.69730943690571, 570492046067105827: 36.35257585851795, 603400864857718838: 22.45807477559766, 559426966151757824: 1.3382403528625963, 272389275197112330: 1.5705050502259528, 363736072804368394: 31.501219595661645, 674955659711873035: 1.3382403528625963, 680797161646325828: 3.5706812573403632, 758489197409206272: 1.8592905147558838, 641267810605203456: 14.934333862529881, 88208179581698048: 1.3382403528625963, 916686718596448267: 1.3382403528625963, 695265543942307890: 1.3382403528625963, 638314770159894529: 1.3382403528625963, 708886890547511326: 1.3382403528625963, 277445453904347136: 28.54901337521732, 944490130352246825: 1.3382403528625963, 615036232598290432: 1.3382403528625963, 528577926988300289: 1.3382403528625963, 699967979919638588: 5.492044510769419, 330925329944281089: 26.003142596750603, 527891741055909910: 93.5840236841981, 968477545420955648: 1.3382403528625963, 1160733130701951116: 1.5668697789357542, 1160733135617671249: 0.5592462677264236, 707937704519925770: 8.68416936488813}

ohya_bot.py

+80-21
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
import numpy
33
import os
44
import random
5+
import datetime
6+
7+
"================================================================================="
58

69
last_message={}
710
async def check_3_same_message(message):
811
global last_message
12+
if message.author==client.user:
13+
last_message[message.channel]=["",0]
914
if message.channel not in last_message:
1015
last_message[message.channel]=[message.content,1]
1116
elif message.content==last_message[message.channel][0]:
@@ -136,6 +141,10 @@ async def default_react(message):
136141
# if message.channel.id==1162707874464682115: #哦鴨測機
137142
# await message.channel.send("https://tenor.com/view/shake-head-anime-bocchi-the-rock-bocchi-the-rock-gif-bocchi-gif-27212768")
138143
# if message.author.id==764866433120206848: # 我
144+
# await message.add_reaction("8️⃣")
145+
# await message.add_reaction("🇼")
146+
# await message.add_reaction("🇨")
147+
# await message.add_reaction("🇵")
139148
if message.author.id==844093945616269323: #arctan
140149
await message.add_reaction("<:hao:1163133973795446935>")
141150
str=(message.content).lower()
@@ -145,42 +154,88 @@ async def default_react(message):
145154
str=str.replace(f"{emoji.id}","")
146155
# print(str)
147156
if message.author.id==527891741055909910: #cheissmart ,"妻","漆","欺","棲","戚","淒"
148-
P7=["7","7","七","seven","柒","闖關","⑦"]
149-
for p7 in P7:
150-
if p7 in str:
151-
await message.channel.send("https://tenor.com/view/shake-head-anime-bocchi-the-rock-bocchi-the-rock-gif-bocchi-gif-27212768")
152-
break
157+
P7=["p7","seven","闖關","cco"]
158+
if sum([1 if p7 in str else 0 for p7 in P7]) > 0:
159+
await message.channel.send("https://tenor.com/view/shake-head-anime-bocchi-the-rock-bocchi-the-rock-gif-bocchi-gif-27212768")
160+
161+
cp8w=["8w"]
162+
if (message.author.id==364761561866174465 and "wiwi" in str) or (message.author.id==331730758555402240 and "8e7" in str) or sum([1 if cp in str else 0 for cp in cp8w]) > 0:
163+
await message.add_reaction("8️⃣")
164+
await message.add_reaction("🇼")
165+
await message.add_reaction("🇨")
166+
await message.add_reaction("🇵")
167+
return
153168
eights=["8","eight","八","8️⃣","8","🎱"]
154-
for eight in eights:
155-
if eight in str:
156-
await message.add_reaction("8️⃣")
157-
break
169+
no_eights=["8w"]
170+
if sum([1 if eight in str else 0 for eight in eights]) > 0 and sum([1 if noteight in str else 0 for noteight in no_eights]) == 0:
171+
await message.add_reaction("8️⃣")
172+
158173
sadge=["封鎖"]
159-
for sad in sadge:
160-
if sad in str:
161-
await message.add_reaction("😢")
174+
if sum([1 if sad in str else 0 for sad in sadge]) > 0:
175+
await message.add_reaction("😢")
176+
162177

178+
async def upd_cf_roles(guild):
179+
from bot_data import cf
180+
import time
181+
with open("bot_data/handle/handle.txt","r") as f:
182+
handle_map=eval(f.read())
183+
role_ids=[1164186643129970789,1164186598338998342,1164186553606733824]
184+
roles=[guild.get_role(roid) for roid in role_ids]
185+
for member in guild.members:
186+
if member.id not in handle_map:
187+
continue
188+
rating=-1
189+
while rating<0:
190+
time.sleep(0.3)
191+
rating=cf.get_rating(handle_map[member.id]["handle"])
192+
# if handle_map[member.id]["rating"] == rating:
193+
# continue
194+
handle_map[member.id]["rating"]=rating
195+
lst=[False,False,False]
196+
if rating >= 2100:
197+
lst[2]=True
198+
elif rating >= 1900:
199+
lst[1]=True
200+
elif rating >= 1600:
201+
lst[0]=True
202+
for i in range(3):
203+
if lst[i]:
204+
await member.add_roles(roles[i])
205+
elif not lst[i]:
206+
await member.remove_roles(roles[i])
207+
print(member.name,lst,rating)
208+
with open("bot_data/handle/handle.txt","w") as f:
209+
f.write(str(handle_map))
210+
211+
"================================================================================="
212+
213+
last_upd_time=None
163214
async def check_ver(message):
164215
if(message.content=="check ver"):
165-
await message.channel.send("last upd: 23-10-18 14:27")
216+
await message.channel.send(f"last upd: {last_upd_time}")
166217

167218
intents = discord.Intents.default()
168219
intents.message_content = True
169220
intents.members = True
221+
intents.guilds = True
170222
client = discord.Client(intents = intents)
171223

172224
@client.event
173225
async def on_ready():
226+
global last_upd_time
227+
last_upd_time=datetime.datetime.now().replace(microsecond=0)
174228
print("on ready")
175229

176230
@client.event
177231
async def on_message(message):
178-
179232
# print(f"{message.author.display_name}, {message.author.global_name}, {message.author.name}")
180-
# if message.channel.id != 1162707874464682115: #哦鴨測機
181-
# return
182-
# print("測機")
233+
if message.channel.id == 1162707874464682115: #哦鴨測機
234+
print("測機")
235+
# return
183236
if message.author==client.user:
237+
global last_message
238+
last_message[message.channel]=["",0]
184239
return
185240
if message.channel.id==1162757642045903009: # CF手把
186241
await CFhandle(message)
@@ -201,9 +256,13 @@ async def on_message(message):
201256
await XXlee(message)
202257
await zhong(message)
203258
await default_react(message)
259+
204260

205261

206-
TOKEN=""
207-
with open("../data.txt","r") as data:
208-
TOKEN=eval(data.read())["TOKEN"]
209-
client.run(TOKEN)
262+
if __name__ == "__main__":
263+
TOKEN=""
264+
with open("../data.txt","r") as data:
265+
TOKEN=eval(data.read())["TOKEN"]
266+
client.run(TOKEN)
267+
print("owo??")
268+

upd_handle.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import discord
2+
import time
3+
4+
5+
intents = discord.Intents.default()
6+
intents.message_content = True
7+
intents.members = True
8+
intents.guilds = True
9+
client = discord.Client(intents = intents)
10+
11+
# ============================================================================ #
12+
13+
async def upd_cf_roles(guild):
14+
from bot_data import cf
15+
import time
16+
with open("bot_data/handle/handle.txt","r") as f:
17+
handle_map=eval(f.read())
18+
role_ids=[1164186643129970789,1164186598338998342,1164186553606733824]
19+
roles=[guild.get_role(roid) for roid in role_ids]
20+
for member in guild.members:
21+
if member.id not in handle_map:
22+
continue
23+
rating=-1
24+
while rating<0:
25+
time.sleep(0.3)
26+
rating=cf.get_rating(handle_map[member.id]["handle"])
27+
if handle_map[member.id]["rating"] == rating:
28+
continue
29+
handle_map[member.id]["rating"]=rating
30+
lst=[False,False,False]
31+
if rating >= 2100:
32+
lst[2]=True
33+
elif rating >= 1900:
34+
lst[1]=True
35+
elif rating >= 1600:
36+
lst[0]=True
37+
for i in range(3):
38+
if lst[i]:
39+
await member.add_roles(roles[i])
40+
elif not lst[i]:
41+
await member.remove_roles(roles[i])
42+
print(member.name,lst,rating)
43+
with open("bot_data/handle/handle.txt","w") as f:
44+
f.write(str(handle_map))
45+
46+
# ============================================================================ #
47+
48+
@client.event
49+
async def on_ready():
50+
time.sleep(86400)
51+
await upd_cf_roles(client.guilds[0])
52+
print("done")
53+
54+
if __name__ == "__main__":
55+
TOKEN=""
56+
with open("../data.txt","r") as data:
57+
TOKEN=eval(data.read())["TOKEN"]
58+
client.run(TOKEN)

0 commit comments

Comments
 (0)