質問編集履歴
1
現段階のコードを載せました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,9 +34,59 @@
|
|
34
34
|
|
35
35
|
```Python
|
36
36
|
|
37
|
+
#入退室ログBOT
|
38
|
+
|
39
|
+
import discord
|
40
|
+
|
41
|
+
from time import sleep
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
client = discord.Client()
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
#vclog.txtのファイルパス
|
50
|
+
|
51
|
+
vclogpath = "/mnt/share/vclog.txt"
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
#入退室ログの表示を行うチャンネルのID
|
56
|
+
|
57
|
+
logch = 878058288883834951
|
58
|
+
|
59
|
+
#testVC_870078948246171708
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
#監視するVCのチャンネルID
|
64
|
+
|
65
|
+
acvc01 = 872387756381319178
|
66
|
+
|
67
|
+
#testVC_VC_847993185254113314
|
68
|
+
|
69
|
+
acvc02 = 856780992958431232
|
70
|
+
|
71
|
+
#testVC_test_878057066286153788
|
72
|
+
|
73
|
+
acvc03 = 849616978021056532
|
74
|
+
|
75
|
+
acvc04 = 853495690026418206
|
76
|
+
|
77
|
+
acvc05 = 870151770159054849
|
78
|
+
|
79
|
+
acvc06 = 876407340528697375
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
# 起動時処理
|
84
|
+
|
37
85
|
@client.event
|
38
86
|
|
39
87
|
async def on_ready():
|
88
|
+
|
89
|
+
#コンソールへの起動通知と追記処理
|
40
90
|
|
41
91
|
for channel in client.get_all_channels():
|
42
92
|
|
@@ -47,6 +97,72 @@
|
|
47
97
|
print("チャンネルID:" + str(channel.id))
|
48
98
|
|
49
99
|
print("----------")
|
100
|
+
|
101
|
+
#チャンネル名とIDの追記
|
102
|
+
|
103
|
+
with open(vclogpath, mode="a", encoding="utf-8") as fout:
|
104
|
+
|
105
|
+
fout.write("Name:" + str(channel.name) + "___")
|
106
|
+
|
107
|
+
fout.write("ID:" + str(channel.id) + "\n")
|
108
|
+
|
109
|
+
fout.write("----------\n")
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
##########入退室ログの表示
|
114
|
+
|
115
|
+
@client.event
|
116
|
+
|
117
|
+
async def on_voice_state_update(member, before, after):
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
#チャンネルへの入室ステータスが変更されたとき(ミュートON、OFFに反応しないように分岐)
|
122
|
+
|
123
|
+
if before.channel != after.channel:
|
124
|
+
|
125
|
+
#logを書き込むテキストチャンネル(チャンネルID)
|
126
|
+
|
127
|
+
botRoom = client.get_channel(logch)
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
#監視するボイスチャンネル(チャンネルID)
|
132
|
+
|
133
|
+
announceChannelIds = [acvc01, acvc02, acvc03, acvc04, acvc05, acvc06]
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
#退室log
|
138
|
+
|
139
|
+
if before.channel is not None and before.channel.id in announceChannelIds:
|
140
|
+
|
141
|
+
await botRoom.send("**" + before.channel.name + "** を__" + member.name + "__ が抜けました!" + " ID_" + str(member.id))
|
142
|
+
|
143
|
+
print(member.name + "_が_" + before.channel.name + "_をLeft" + "___ID_" + str(member.id))
|
144
|
+
|
145
|
+
with open(vclogpath, mode="a", encoding="utf-8") as fout:
|
146
|
+
|
147
|
+
fout.write(member.name + "_が_" + before.channel.name + "_をLeft" + "___ID_" + str(member.id) + "\n")
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
#入室log
|
152
|
+
|
153
|
+
if after.channel is not None and after.channel.id in announceChannelIds:
|
154
|
+
|
155
|
+
await botRoom.send("**" + after.channel.name + "** へ__" + member.name + "__ が参加しました!" + " ID_" + str(member.id))
|
156
|
+
|
157
|
+
print(member.name + "_が_" + after.channel.name + "_にJoin" + "___ID_" + str(member.id))
|
158
|
+
|
159
|
+
with open(vclogpath, mode="a", encoding="utf-8") as fout:
|
160
|
+
|
161
|
+
fout.write(member.name + "_が_" + after.channel.name + "_Join" + "___ID_" + str(member.id) + "\n")
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
client.run()#←BOT-token
|
50
166
|
|
51
167
|
```
|
52
168
|
|