Compare commits

...

19 Commits
v2.0 ... main

Author SHA1 Message Date
Profitroll 5c5a620d65 Merge pull request 'Update dependency py-cord to v2.5.0' (#8) from renovate/py-cord-2.x into main
Reviewed-on: #8
2024-03-02 17:44:44 +02:00
Renovate 1c05efa0f4 Update dependency py-cord to v2.5.0 2024-03-02 11:01:22 +02:00
Profitroll f5de2457ba Merge pull request 'Update dependency ujson to v5.9.0' (#7) from renovate/ujson-5.x into main
Reviewed-on: #7
2023-12-12 01:28:19 +02:00
Renovate 8cec182435 Update dependency ujson to v5.9.0 2023-12-11 01:34:57 +02:00
Profitroll ad0ab65c5d Fixed http 2023-08-26 00:00:44 +03:00
Profitroll 0029cdaa30 Replaced Crowdin with Weblate 2023-08-25 23:59:50 +03:00
Profitroll e94883f6ad Merge pull request 'Update dependency ujson to v5.8.0' (#6) from renovate/ujson-5.x into main
Reviewed-on: #6
2023-08-07 14:13:08 +03:00
Renovate 465838a196 Update dependency ujson to v5.8.0 2023-08-07 14:10:43 +03:00
Profitroll a059fb0518 Merge pull request 'Update dependency requests to v2.31.0' (#5) from renovate/requests-2.x into main
Reviewed-on: #5
2023-05-22 19:39:04 +03:00
Renovate c4ee74753b Update dependency requests to v2.31.0 2023-05-22 18:40:49 +03:00
Profitroll 492edc242f Merge pull request 'Update dependency requests to v2.30.0' (#4) from renovate/requests-2.x into main
Reviewed-on: #4
2023-05-08 11:50:52 +03:00
Renovate 66c0ad7ee8 Update dependency requests to v2.30.0 2023-05-08 11:46:39 +03:00
Profitroll c1ee1b50ab Added config check and updated version to 2.3 2023-05-07 16:39:48 +02:00
Profitroll 7a379cf97e Updated ignore 2023-05-07 16:38:46 +02:00
Profitroll 388e27fdff config.json is now config_example.json 2023-05-07 16:38:17 +02:00
Profitroll 65a0e1097e Updated version to 2.2 2023-05-07 16:24:09 +02:00
Profitroll 3fe67e18b0 Channel will terminate when the last user quit 2023-05-07 16:23:16 +02:00
Profitroll 91eecb4b0b Fixed channels logic 2023-05-02 16:13:11 +02:00
Profitroll 740c6a1464 Updated version to 2.1 2023-05-02 16:10:32 +02:00
8 changed files with 62 additions and 39 deletions

9
.gitignore vendored
View File

@ -163,4 +163,11 @@ cython_debug/
.history/
# Built Visual Studio Code Extensions
*.vsix
*.vsix
# Project
venv
venv_linux
venv_windows
config.json

View File

@ -4,8 +4,8 @@
<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">
<img alt="License: GPL v2" src="https://img.shields.io/badge/License-GPL_v2-blue.svg">
</a>
<a href="https://crowdin.com/project/yusarinbot">
<img alt="Crowdin" src="https://badges.crowdin.net/yusarinbot/localized.svg">
<a href="https://weblate.end-play.xyz/engage/yusarinbot/">
<img src="https://weblate.end-play.xyz/widget/yusarinbot/svg-badge.svg" alt="Translation status" />
</a>
<a href="https://git.end-play.xyz/profitroll/YusarinBot">
<img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg">
@ -26,8 +26,9 @@ Installation instructions are listed below. Please, make sure you have installed
1. `git clone https://git.end-play.xyz/profitroll/YusarinBot`
2. `cd YusarinBot`
3. `pip install -r requirements.txt`
4. `nano config.json`
5. `python yusarin.py`
4. `cp config_example.json config.json`
5. `nano config.json`
6. `python yusarin.py`
## Installation (Detailed)
@ -42,9 +43,10 @@ Installation instructions are listed below. Please, make sure you have installed
9. You can rename it however you want, set needed descriptions etc
10. Go to "Bot" tab and enable application as bot
11. Copy token of your bot
12. Open file `config.json` with your favorite text editor and paste your token as value of "bot_token" key
13. Copy your own Discord ID and paste it as value of "owner" key (How to get ID: <https://support.playhive.com/discord-user-id/>)
14. Bot is ready! Run it using `python yusarin.py`
12. Copy `config_example.json` to `config.json`
13. Open file `config.json` with your favorite text editor and paste your token as value of "bot_token" key
14. Copy your own Discord ID and paste it as value of "owner" key (How to get ID: <https://support.playhive.com/discord-user-id/>)
15. Bot is ready! Run it using `python yusarin.py`
## Config explanation

View File

@ -9,6 +9,7 @@ from discord import (
utils,
)
from discord.ext import commands
from discord.abc import GuildChannel
from functions import (
appendLog,
@ -32,6 +33,11 @@ class CogChannel(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_guild_channel_delete(self, channel: GuildChannel):
if isUserVoice(channel):
await removeUserVoice(channel)
@Cog.listener()
async def on_voice_state_update(
self, member: Member, before: VoiceState, after: VoiceState
@ -40,26 +46,19 @@ class CogChannel(commands.Cog):
vc_from = before.channel
vc_to = after.channel
category = member.guild.get_channel(guildConfGet(member.guild, "category"))
# If user left vc
if after.channel is None and before.channel.category == category and len(before.channel.members) == 0:
if before.channel is not None and len(before.channel.members) == 0:
if isUserVoice(vc_from):
if isVoiceOfUser(vc_from, member):
await removeUserVoice(vc_from)
return
else:
if not isVoiceOfUser(vc_from, member):
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member)
await removeUserVoice(vc_from)
# If user joined vc
if after.channel is not None and after.channel.id == guildConfGet(member.guild, "channel"):
if isUserVoice(vc_from):
if isVoiceOfUser(vc_from, member):
await removeUserVoice(vc_from)
else:
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member)
if after.channel is not None and after.channel.id == guildConfGet(
member.guild, "channel"
):
if isUserVoice(vc_to):
if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("allow", vc_to, member)

View File

@ -253,31 +253,45 @@ async def removeUserVoice(vc: VoiceChannel) -> None:
nomic_channel = utils.get(vc.guild.channels, id=vc_conf["nomic"])
remove(vc_file)
await needed_channel.delete()
if debug:
appendLog(
f"Removed voice channel '{needed_channel}' ({str(needed_channel.id)}) of user with id {str(vc_conf['ownerid'])}",
guild=vc.guild,
)
else:
if needed_channel is None:
appendLog(
f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}",
guild=vc.guild,
)
else:
await needed_channel.delete()
if loadJson("config.json")["enable_nomic"]:
await nomic_channel.delete()
if debug:
appendLog(
f"Removed nomic channel {nomic_channel} ({str(nomic_channel.id)}) of channel with id {str(needed_channel.id)}",
f"Removed voice channel '{needed_channel}' ({str(needed_channel.id)}) of user with id {str(vc_conf['ownerid'])}",
guild=vc.guild,
)
else:
appendLog(
f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}",
guild=vc.guild,
)
if loadJson("config.json")["enable_nomic"]:
if nomic_channel is None:
appendLog(
f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}",
guild=vc.guild,
)
else:
await nomic_channel.delete()
if debug:
appendLog(
f"Removed nomic channel '{nomic_channel}' ({str(nomic_channel.id)}) of channel with id {str(needed_channel.id)}",
guild=vc.guild,
)
else:
appendLog(
f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}",
guild=vc.guild,
)
else:
return

View File

@ -1,2 +1,2 @@
ujson==5.7.0
py-cord[speed]==2.4.1
ujson==5.9.0
py-cord[speed]==2.5.0

View File

@ -1,2 +1,2 @@
py-cord==2.4.1
requests==2.29.0
py-cord==2.5.0
requests==2.31.0

View File

@ -7,15 +7,16 @@ except Exception as exp:
)
exit()
from os import getpid
from os import getpid, path
from functions import *
pid = getpid()
version = 2.0
version = 2.3
if (
loadJson("config.json")["owner"] == "SET-OWNER-ID"
not path.exists("config.json")
or loadJson("config.json")["owner"] == "SET-OWNER-ID"
or loadJson("config.json")["bot_token"] == "SET-BOT-TOKEN"
):
print(