up db test
This commit is contained in:
2
.idea/discord-bot.iml
generated
2
.idea/discord-bot.iml
generated
@@ -4,7 +4,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="jdk" jdkName="Python 3.9 (discord-bot)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
1
.idea/encodings.xml
generated
1
.idea/encodings.xml
generated
@@ -2,5 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
<file url="file://$PROJECT_DIR$/sqlite_python.db" charset="windows-1251" />
|
<file url="file://$PROJECT_DIR$/sqlite_python.db" charset="windows-1251" />
|
||||||
|
<file url="file://$PROJECT_DIR$/test_database.sql" charset="windows-1251" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (discord-bot)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (discord-bot)" project-jdk-type="Python SDK" />
|
||||||
|
<component name="PyPackaging">
|
||||||
|
<option name="earlyReleasesAsUpgrades" value="true" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
||||||
BIN
audio/1.mp3
BIN
audio/1.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
72
main.py
72
main.py
@@ -1,32 +1,74 @@
|
|||||||
|
import random
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
import discord
|
import discord
|
||||||
import ffmpeg
|
from asyncio import sleep
|
||||||
from discord import guild, FFmpegPCMAudio
|
from os import walk
|
||||||
|
|
||||||
|
from discord import user, member
|
||||||
|
from discord import FFmpegPCMAudio
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
threading.current_thread().name = "main"
|
threading.current_thread().name = "main"
|
||||||
logging.basicConfig(stream=sys.stdout, filemode='w', level='INFO',
|
logging.basicConfig(stream=sys.stdout, filemode='w', level='INFO',
|
||||||
format='%(asctime)s - %(levelname)s - %(threadName)s - %(message)s')
|
format='%(asctime)s - %(levelname)s - %(threadName)s - %(message)s')
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix='$')
|
|
||||||
|
intents = discord.Intents.all()
|
||||||
|
intents.typing = True
|
||||||
|
intents.presences = True
|
||||||
|
|
||||||
|
bot = commands.Bot(command_prefix='$', guild_subscriptions=True, intents=intents)
|
||||||
|
f = []
|
||||||
|
for filenames in walk('audio'):
|
||||||
|
f.extend(filenames)
|
||||||
|
break
|
||||||
|
f = f[2]
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_voice_state_update(member, before, after):
|
async def on_voice_state_update(member, before, after):
|
||||||
channel = bot.get_channel(947075464256712724)
|
channel = bot.get_channel(783729824896122930)
|
||||||
print(member)
|
_role = 929729495370461205
|
||||||
_memb = 260050236813082624
|
_memb = 375664768087752714
|
||||||
if before.channel == None:
|
_bot_id = 946819004314570852
|
||||||
await channel.send(f'{member.mention} ах ты ебаглаз')
|
role = discord.utils.find(lambda r: r.name == 'тарковчане', member.roles)
|
||||||
voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=guild)
|
if before.channel is None and role in member.roles:
|
||||||
audio_source = FFmpegPCMAudio('audio/1.mp3')
|
track = random.randint(0, len(f) - 1)
|
||||||
if not voice_client.is_playing():
|
audio_source = FFmpegPCMAudio(f'audio/{f[track]}')
|
||||||
voice_client.play(audio_source, after=None)
|
logging.error(f'{track}\t\t\t{f[track]}')
|
||||||
if after.channel == None:
|
if not bot.voice_clients:
|
||||||
await channel.send(f'{member.mention} ты куда пошел?')
|
await sleep(1)
|
||||||
|
_channel = after.channel
|
||||||
|
vc = await after.channel.connect()
|
||||||
|
if not vc.is_playing():
|
||||||
|
vc.play(audio_source, after=None)
|
||||||
|
while vc.is_playing():
|
||||||
|
await sleep(0.5)
|
||||||
|
await sleep(1)
|
||||||
|
await vc.disconnect()
|
||||||
|
if before.channel is None and member.id == _memb:
|
||||||
|
track = random.randint(0, len(f) - 1)
|
||||||
|
audio_source = FFmpegPCMAudio(f'audio/{_memb}/bear2_enemy_scav3.wav')
|
||||||
|
logging.error(f'{track}\t\t\t{f[track]}')
|
||||||
|
if not bot.voice_clients:
|
||||||
|
await sleep(1)
|
||||||
|
_channel = after.channel
|
||||||
|
vc = await after.channel.connect()
|
||||||
|
if not vc.is_playing():
|
||||||
|
vc.play(audio_source, after=None)
|
||||||
|
while vc.is_playing():
|
||||||
|
await sleep(0.5)
|
||||||
|
await sleep(1)
|
||||||
|
await vc.disconnect()
|
||||||
|
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_member_join(member):
|
||||||
|
role = discord.utils.get(member.guild.roles, id=734358428939452486)
|
||||||
|
print(role)
|
||||||
|
await member.add_roles(role)
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
@@ -35,5 +77,3 @@ async def on_ready():
|
|||||||
|
|
||||||
|
|
||||||
bot.run('OTQ2ODE5MDA0MzE0NTcwODUy.YhkP6Q.dhFqi2MJMrxzHt5FtjK5Cl-5BI8')
|
bot.run('OTQ2ODE5MDA0MzE0NTcwODUy.YhkP6Q.dhFqi2MJMrxzHt5FtjK5Cl-5BI8')
|
||||||
|
|
||||||
# if __name__ == '__main__':
|
|
||||||
|
|||||||
BIN
sqlite_python.db
BIN
sqlite_python.db
Binary file not shown.
Reference in New Issue
Block a user