Compare commits
34 Commits
Author | SHA1 | Date |
---|---|---|
Profitroll | fa0cd2e30f | |
Renovate | 73d6b01ede | |
Profitroll | 5c5a620d65 | |
Renovate | 1c05efa0f4 | |
Profitroll | f5de2457ba | |
Renovate | 8cec182435 | |
Profitroll | ad0ab65c5d | |
Profitroll | 0029cdaa30 | |
Profitroll | e94883f6ad | |
Renovate | 465838a196 | |
Profitroll | a059fb0518 | |
Renovate | c4ee74753b | |
Profitroll | 492edc242f | |
Renovate | 66c0ad7ee8 | |
Profitroll | c1ee1b50ab | |
Profitroll | 7a379cf97e | |
Profitroll | 388e27fdff | |
Profitroll | 65a0e1097e | |
Profitroll | 3fe67e18b0 | |
Profitroll | 91eecb4b0b | |
Profitroll | 740c6a1464 | |
Profitroll | 3ca44dcd2d | |
Profitroll | 301439f144 | |
Profitroll | 3435d59d96 | |
Renovate | d560bce8c6 | |
Profitroll | 528604b6b4 | |
Profitroll | 76c7812284 | |
Profitroll | 8e48334cea | |
Renovate | bc9cebbec6 | |
Profitroll | a178aa2af9 | |
Profitroll | fb3e291d77 | |
Profitroll | 75c1889477 | |
Profitroll | 5329b4c727 | |
Profitroll | 0f3a6121d6 |
|
@ -163,4 +163,11 @@ cython_debug/
|
||||||
.history/
|
.history/
|
||||||
|
|
||||||
# Built Visual Studio Code Extensions
|
# Built Visual Studio Code Extensions
|
||||||
*.vsix
|
*.vsix
|
||||||
|
|
||||||
|
# Project
|
||||||
|
venv
|
||||||
|
venv_linux
|
||||||
|
venv_windows
|
||||||
|
|
||||||
|
config.json
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:base"
|
||||||
|
]
|
||||||
|
}
|
18
README.md
18
README.md
|
@ -4,10 +4,10 @@
|
||||||
<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">
|
<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">
|
<img alt="License: GPL v2" src="https://img.shields.io/badge/License-GPL_v2-blue.svg">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://crowdin.com/project/yusarinbot">
|
<a href="https://weblate.end-play.xyz/engage/yusarinbot/">
|
||||||
<img alt="Crowdin" src="https://badges.crowdin.net/yusarinbot/localized.svg">
|
<img src="https://weblate.end-play.xyz/widget/yusarinbot/svg-badge.svg" alt="Translation status" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://git.end-play.xyz/profitroll/TelegramPoster">
|
<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">
|
<img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://discord.com/invite/2zpzErtnNT">
|
<a href="https://discord.com/invite/2zpzErtnNT">
|
||||||
|
@ -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`
|
1. `git clone https://git.end-play.xyz/profitroll/YusarinBot`
|
||||||
2. `cd YusarinBot`
|
2. `cd YusarinBot`
|
||||||
3. `pip install -r requirements.txt`
|
3. `pip install -r requirements.txt`
|
||||||
4. `nano config.json`
|
4. `cp config_example.json config.json`
|
||||||
5. `python yusarin.py`
|
5. `nano config.json`
|
||||||
|
6. `python yusarin.py`
|
||||||
|
|
||||||
## Installation (Detailed)
|
## 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
|
9. You can rename it however you want, set needed descriptions etc
|
||||||
10. Go to "Bot" tab and enable application as bot
|
10. Go to "Bot" tab and enable application as bot
|
||||||
11. Copy token of your 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
|
12. Copy `config_example.json` to `config.json`
|
||||||
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/>)
|
13. Open file `config.json` with your favorite text editor and paste your token as value of "bot_token" key
|
||||||
14. Bot is ready! Run it using `python yusarin.py`
|
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
|
## Config explanation
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ from discord import (
|
||||||
utils,
|
utils,
|
||||||
)
|
)
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
from discord.abc import GuildChannel
|
||||||
|
|
||||||
from functions import (
|
from functions import (
|
||||||
appendLog,
|
appendLog,
|
||||||
|
@ -32,6 +33,11 @@ class CogChannel(commands.Cog):
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_guild_channel_delete(self, channel: GuildChannel):
|
||||||
|
if isUserVoice(channel):
|
||||||
|
await removeUserVoice(channel)
|
||||||
|
|
||||||
@Cog.listener()
|
@Cog.listener()
|
||||||
async def on_voice_state_update(
|
async def on_voice_state_update(
|
||||||
self, member: Member, before: VoiceState, after: VoiceState
|
self, member: Member, before: VoiceState, after: VoiceState
|
||||||
|
@ -42,23 +48,17 @@ class CogChannel(commands.Cog):
|
||||||
vc_to = after.channel
|
vc_to = after.channel
|
||||||
|
|
||||||
# If user left vc
|
# If user left vc
|
||||||
if vc_to is None:
|
if before.channel is not None and len(before.channel.members) == 0:
|
||||||
if isUserVoice(vc_from):
|
if isUserVoice(vc_from):
|
||||||
if isVoiceOfUser(vc_from, member):
|
if not isVoiceOfUser(vc_from, member):
|
||||||
await removeUserVoice(vc_from)
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
if loadJson("config.json")["enable_nomic"]:
|
if loadJson("config.json")["enable_nomic"]:
|
||||||
await changeNomicPerms("deny", vc_from, member)
|
await changeNomicPerms("deny", vc_from, member)
|
||||||
|
await removeUserVoice(vc_from)
|
||||||
|
|
||||||
# If user joined vc
|
# If user joined vc
|
||||||
else:
|
if after.channel is not None and after.channel.id == guildConfGet(
|
||||||
if isUserVoice(vc_from):
|
member.guild, "channel"
|
||||||
if isVoiceOfUser(vc_from, member):
|
):
|
||||||
await removeUserVoice(vc_from)
|
|
||||||
else:
|
|
||||||
if loadJson("config.json")["enable_nomic"]:
|
|
||||||
await changeNomicPerms("deny", vc_from, member)
|
|
||||||
if isUserVoice(vc_to):
|
if isUserVoice(vc_to):
|
||||||
if loadJson("config.json")["enable_nomic"]:
|
if loadJson("config.json")["enable_nomic"]:
|
||||||
await changeNomicPerms("allow", vc_to, member)
|
await changeNomicPerms("allow", vc_to, member)
|
||||||
|
|
36
functions.py
36
functions.py
|
@ -253,31 +253,45 @@ async def removeUserVoice(vc: VoiceChannel) -> None:
|
||||||
nomic_channel = utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
nomic_channel = utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||||
|
|
||||||
remove(vc_file)
|
remove(vc_file)
|
||||||
|
|
||||||
await needed_channel.delete()
|
if needed_channel is None:
|
||||||
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:
|
|
||||||
appendLog(
|
appendLog(
|
||||||
f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}",
|
f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}",
|
||||||
guild=vc.guild,
|
guild=vc.guild,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
await needed_channel.delete()
|
||||||
|
|
||||||
if loadJson("config.json")["enable_nomic"]:
|
|
||||||
await nomic_channel.delete()
|
|
||||||
if debug:
|
if debug:
|
||||||
appendLog(
|
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,
|
guild=vc.guild,
|
||||||
)
|
)
|
||||||
else:
|
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(
|
appendLog(
|
||||||
f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}",
|
f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}",
|
||||||
guild=vc.guild,
|
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:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
ujson~=5.7.0
|
ujson==5.10.0
|
||||||
py-cord[speed]~=2.4.1
|
py-cord[speed]==2.5.0
|
|
@ -1,2 +1,2 @@
|
||||||
py-cord~=2.4.1
|
py-cord==2.5.0
|
||||||
requests~=2.28.2
|
requests==2.31.0
|
|
@ -7,15 +7,16 @@ except Exception as exp:
|
||||||
)
|
)
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
from os import getpid
|
from os import getpid, path
|
||||||
|
|
||||||
from functions import *
|
from functions import *
|
||||||
|
|
||||||
pid = getpid()
|
pid = getpid()
|
||||||
version = 1.9
|
version = 2.3
|
||||||
|
|
||||||
if (
|
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"
|
or loadJson("config.json")["bot_token"] == "SET-BOT-TOKEN"
|
||||||
):
|
):
|
||||||
print(
|
print(
|
||||||
|
|
Loading…
Reference in New Issue