-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscordbot.py
More file actions
187 lines (152 loc) · 5.09 KB
/
discordbot.py
File metadata and controls
187 lines (152 loc) · 5.09 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# インストールした discord.py を読み込む
import discord
import cv2
import random
# 自分のBotのアクセストークンに置き換えてください
TOKEN = 'ODE4MTM3NTM2MTI2OTEwNTc0.YETr9A.7WhBZWXEx-HdfHu6tyVfe-jwwxs'
# 接続に必要なオブジェクトを生成
client = discord.Client()
# おみくじ内容リスト
random_omikuji =[
'大吉',
'中吉',
'小吉',
'末吉',
'凶',
]
#おみくじ詳細内容
detail_1=[
'★★★★★',
'★★★★★',
'★★★★☆',
'★★★★☆',
'★★★☆☆',
]
detail_2=[
'★★★★★',
'★★★★☆',
'★★★★☆',
'★★★☆☆',
'★★★☆☆',
]
detail_3=[
'★★★★☆',
'★★★★☆',
'★★★☆☆',
'★★★☆☆',
'★★☆☆☆',
]
detail_4=[
'★★★★☆',
'★★★☆☆',
'★★★☆☆',
'★★☆☆☆',
'★★☆☆☆',
]
detail_5=[
'★★★☆☆',
'★★☆☆☆',
'★★☆☆☆',
'★★☆☆☆',
'★☆☆☆☆',
]
hokan_1=[]
hokan_2=[]
hokan_3=[]
hokan_4=[]
hokan_5=[]
dai=0
tyu=0
syou=0
sue=0
kyou=0
while dai <5:
D1=random.choice(detail_1)
hokan_1.append(D1)
dai+=1
while tyu<5:
D2=random.choice(detail_2)
hokan_2.append(D2)
tyu+=1
while syou<5 :
D3=random.choice(detail_3)
hokan_3.append(D3)
syou+=1
while sue<5:
D4=random.choice(detail_4)
hokan_4.append(D4)
sue+=1
while kyou<5:
D5=random.choice(detail_5)
hokan_5.append(D5)
kyou+=1
#content 判定
def judgeman(n):
return n
# 今日のおみくじ精度用
cnt=0
random_entry =[]
while cnt<100:
cnt+=1
random_entry.append(str(cnt))
setumei='現在利用可能機能\nおみくじ 『omibomk1』の発言で実行'
# 起動時に動作する処理
@client.event
async def on_ready():
# 起動したらターミナルにログイン通知が表示される
print('ログインしました')
ch_id = 818143415958634548 #266523840320897024
#818143415958634548 試験場ch id
#266523840320897024 いつのもch id
#入力されたチャンネルIDからチャンネル情報を取得してchannelに格納する。
channel = client.get_channel(ch_id)
await channel.send(setumei)
# メッセージ受信時に動作する処理S
@client.event
async def on_message(message):
# m=input()
# await message.channel.send(m)
# メッセージ送信者がBotだった場合は無視する
if message.author.bot:
return
# 「おみくじ_omibo」と発言したら「今回の~」が返る処理
if message.content.startswith('omibomk1'):
oha=random.choice(random_entry)
await message.channel.send('今日の満足度は'+oha+'%です!')
await message.channel.send( message.author.name +'さんのためにおみくじを引いてきます!')
#random_omikujiからランダムで1つ要素を返す
content =random.choice(random_omikuji)
await message.channel.send(content)
if content=='大吉':
await message.channel.send('総合運 '+hokan_1[0] +'\n'+ '勝負運 '+hokan_1[1] +'\n'+ '金運 '+hokan_1[2] +'\n'+ '恋愛運 '+hokan_1[3]+ '\n'+ '仕事運 '+hokan_1[4] +'\n')
return
elif content=='中吉':
await message.channel.send('総合運 '+hokan_2[0] +'\n'+ '勝負運 '+hokan_2[1] +'\n'+ '金運 '+hokan_2[2] +'\n'+ '恋愛運 '+hokan_2[3] + '\n'+ '仕事運 '+hokan_2[4] +'\n')
return
elif content=='小吉':
await message.channel.send('総合運 '+hokan_3[0] + '\n'+ '勝負運 '+hokan_3[1] + '\n'+ '金運 '+hokan_3[2] + '\n'+ '恋愛運 '+hokan_3[3] + '\n'+ '仕事運 '+hokan_3[4] +'\n')
return
elif content=='末吉':
await message.channel.send('総合運 '+hokan_4[0] +'\n'+ '勝負運 '+hokan_4[1] + '\n'+ '金運 '+hokan_4[2] + '\n'+ '恋愛運 '+hokan_4[3] + '\n'+ '仕事運 '+hokan_4[4] + '\n')
return
elif content=='凶':
await message.channel.send('総合運 '+hokan_5[0] +'\n'+ '勝負運 '+hokan_5[1] +'\n'+ '金運 '+hokan_5[2] +'\n'+ '恋愛運 '+hokan_5[3] +'\n'+ '仕事運 '+hokan_5[4] +'\n')
return
if message.content.startswith('$ルーレット'):
await message.channel.send('内容を1つずついれてね!\nすべていれたら $抽選 と入力してね!')
return
hako=[]
mon=0
#while True :
#hako.append(message.content)
#print(hako)
# if hako[mon]=='$抽選':
# hako.pop()
# message.channel.send('結果を表示します')
# break
#mon+=1
if message.content.startswith('$抽選'):
ore=random.choice(hako)
await message.channel.send(ore)
# Botの起動とDiscordサーバーへの接続
client.run(TOKEN)