Skip to content

Commit

Permalink
SpyAgent 2.8.1
Browse files Browse the repository at this point in the history
Improvements in audio management:
***vcconnect - connect to any voice channel
***vcdisconnect - disconnect from voice channel
***vcstop - turns off the music
***vcplay - turns on music
  • Loading branch information
progame1201 committed Jan 16, 2024
1 parent 69bbfde commit a37af37
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ __All commands work with the prefix ***<br>__
+ set - set the channel (by ID)
+ ***setuser - It works as a SpyAgentPM setting the user as a channel<br>
+ ***reply - reply to a message<br>
+ ***vcplay - turns on music in any voice channel<br>
+ ***vcstop - turns off the music where it is on (you can enable it in the config)
+ ***vcplay - turns on music<br>
+ ***vcstop - turns off the music<br>
+ ***vcconnect - connect to any voice channel<br>
+ ***vcdisconnect - disconnect from voice channel

### **commands in private messages:** work in SpyAgentPM<br>

Expand Down
50 changes: 35 additions & 15 deletions SpyBot20/Commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, client=None, guild=None, channel=None):
self.client:Client = client
self.channel:TextChannel = channel
self.guild = guild
self.vcchlients:list[VoiceClient] = []
init(autoreset=True)
def getmutes(self):
if os.path.exists("channelmutes"):
Expand Down Expand Up @@ -319,6 +320,23 @@ async def reply(self):
return
await replymessages[id].reply(await self.async_input("message:"))
async def vcpaly(self):
for i, client in enumerate(self.vcchlients):
print(f"{i}:{client.channel.name}")
id = await self.async_input("channel index:")
vcch = self.vcchlients[int(id)]
path = filedialog.askopenfilename()
if path == "" or path == None or path == " ":
return
source = FFmpegPCMAudio(path)
vcch.play(source, after=self.VC_after_playing)
logger.success("Audio playback has started")

def VC_after_playing(self, error):
if error:
pass
else:
logger.info("Audio has finished playing")
async def vcconnect(self):
print("Choose a channel:")
channels: dict[int, dict[str:int]] = {}
for i, channel in enumerate(self.guild.voice_channels):
Expand All @@ -328,28 +346,30 @@ async def vcpaly(self):
if data == "" or data == None:
return
try:
vcchannel:VoiceChannel = self.client.get_channel(list(channels.get(int(data)).values())[0])
for client in self.client.voice_clients:
if client.guild.id == vcchannel.guild.id:
await client.disconnect()
logger.success(f"channel assigned! channel name {channel.name}, channel id: {channel.id}")
vcch:VoiceClient = await vcchannel.connect(timeout=5)
vcchannel:VoiceChannel = self.client.get_channel(list(channels.get(int(data)).values())[0])
for client in self.client.voice_clients:
if client.channel.guild.id == vcchannel.guild.id:
await client.disconnect()
self.vcchlients.append(await vcchannel.connect(timeout=5))
logger.success(f"connected! channel name {vcchannel.name}, channel id: {vcchannel.id}")
return
except Forbidden:
logger.error(f"{Fore.RED}It's impossible to connect: Forbidden.")
return
path = filedialog.askopenfilename()
if path == "" or path == None or path == " ":
return
source = FFmpegPCMAudio(path)
vcch.play(source)
logger.success("Audio playback has started")
async def VC_play(self, source, vcch):
vcch.play(source)
async def vcstop(self):
async def vcdisconnect(self):
for i, client in enumerate(self.client.voice_clients):
print(f"{i}:{client.channel.name}")
id = await self.async_input("channel index:")
await self.client.voice_clients[int(id)].disconnect()
logger.success("Disconnected")
async def vcstop(self):
for i, client in enumerate(self.vcchlients):
print(f"{i}:{client.channel.name}")
id = await self.async_input("channel index:")
try:
self.vcchlients[int(id)].source.cleanup()
except:
pass
logger.success("Stoped playing.")


6 changes: 4 additions & 2 deletions SpyBot20/SpyAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from colorama import Fore, init
import Commands
import LocalCommandManager
logger.info("Spy Agent 2.8.0, 2024, progame1201")
logger.info("Spy Agent 2.8.1, 2024, progame1201")
logger.info("Running...")
client:Client = Client(intents=Intents.all())
init(autoreset=True)
Expand Down Expand Up @@ -200,7 +200,9 @@ async def chatting():
cm.new(command_name="***setuser", func=cmnds.setuser)
cm.new(command_name="***reply", func=cmnds.reply)
cm.new(command_name="***vcplay", func=cmnds.vcpaly)
cm.new(command_name="***vcconnect", func=cmnds.vcconnect)
cm.new(command_name="***vcstop", func=cmnds.vcstop)
cm.new(command_name="***vcdisconnect", func=cmnds.vcdisconnect)
print(f"\n{Fore.YELLOW}List of loaded commands:\n{cm.get_keys()}\n{Fore.CYAN}type ***help to get more info!")
logger.success("Command manager started!")
await sleep(2)
Expand All @@ -209,7 +211,7 @@ async def chatting():
await sleep(1)
senddata = await async_input(f"{Fore.LIGHTBLACK_EX}Message to {channel.name}:\n{Fore.RESET}")
if senddata.lower() == "***help":
print("#####HELP#####\n***Mute - mute any channel\n***Unmute - unmute any channel\n***Delete - delete any message you have selected\n***Reset - Re-select the guild and channel for communication\n***Resetchannel - Re-select a channel for communication\n***File - send a file\n***Muteguild - mute any guild\n***Unmuteguild - unmute any guild\n***Reaction - react any message\n***Privatemsg - Send a private message to the user\n***Gethistory - Get the history of the channel you are on\ninto - send a message to any channel (by ID)\nset - set the channel (by ID)\n***setuser - It works as a Spy Agent PM setting the user as a channel\n#####INFO#####\nall messages are written in the format: guild: channel: author: message\n##############")
print("#####HELP#####\n***Mute - mute any channel\n***Unmute - unmute any channel\n***Delete - delete any message you have selected\n***Reset - Re-select the guild and channel for communication\n***Resetchannel - Re-select a channel for communication\n***File - send a file\n***Muteguild - mute any guild\n***Unmuteguild - unmute any guild\n***Reaction - react any message\n***Privatemsg - Send a private message to the user\n***Gethistory - Get the history of the channel you are on\n***into - send a message to any channel (by ID)\n***set - set the channel (by ID)\n***setuser - It works as a Spy Agent PM setting the user as a channel\n***reply - reply to a message\n***vcplay - turns on music\n***vcstop - turns off the music\n***edit - edit any message\n***vcconnect - connect to any voice channel\n***vcdisconnect - disconnect from voice channel\n#####INFO#####\nall messages are written in the format: guild: channel: author: message\n##############")
continue

cmresult = cm.execute(senddata)
Expand Down

0 comments on commit a37af37

Please sign in to comment.