Skip to content

Commit

Permalink
SpyAgent 2.9.0
Browse files Browse the repository at this point in the history
2 commands have been added:
***vctts - plays tts message to the voice channel
***activity - to put an activity on the bot, for example: playing a game
  • Loading branch information
progame1201 committed Jan 18, 2024
1 parent a37af37 commit cb13b95
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 16 deletions.
52 changes: 47 additions & 5 deletions SpyBot20/Commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import config
from tkinter import filedialog
from colorama import Fore, init
import pyttsx3

class Commands:
'''All commands of SpyAgent 2.8.0+
'''All commands of SpyAgent 2.9.0+
most of the commands were taken from version 1.0.0-2.0.0, which is why their code maybe bad.
'''
def __init__(self, client=None, guild=None, channel=None):
Expand Down Expand Up @@ -185,9 +186,22 @@ async def status(self):
for key in statuses.keys():
print(key)
status = input("status:")
if status in statuses.keys():
if status.lower() in statuses.keys():
await self.client.change_presence(status=statuses[status])
logger.success(f"status changed to {status}")
async def activity(self):
print("activities list: game\nstreaming\nlistening\nwatching")
activity = await self.async_input("activity:")
name = await self.async_input("activity name:")
await self.client.change_presence(activity=None)
if activity.lower() == "game":
await self.client.change_presence(activity=Game(name=name))
if activity.lower() == "streaming":
await self.client.change_presence(activity=Streaming(name=name, url=await self.async_input("url:")))
if activity.lower() == "listening":
await self.client.change_presence(activity=Activity(type=ActivityType.listening, name=name))
if activity.lower() == "watching":
await self.client.change_presence(activity=Activity(type=ActivityType.watching, name=name))
async def guildmute(self):
guildlistformute = []
guild_mute_list = self.getmutes()[1]
Expand Down Expand Up @@ -323,8 +337,15 @@ async def vcpaly(self):
for i, client in enumerate(self.vcchlients):
print(f"{i}:{client.channel.name}")
id = await self.async_input("channel index:")
if int(id) < 0:
return
vcch = self.vcchlients[int(id)]
path = filedialog.askopenfilename()
print("opend methods:\n1: by path\n2: by filedialog")
method = await self.async_input("open method:")
if method == "1":
path = await self.async_input("path:")
elif method == "2":
path = filedialog.askopenfilename()
if path == "" or path == None or path == " ":
return
source = FFmpegPCMAudio(path)
Expand All @@ -350,17 +371,38 @@ async def vcconnect(self):
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))
self.vcchlients.append(await vcchannel.connect())
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
async def vctts(self):
for i, client in enumerate(self.vcchlients):
print(f"{i}:{client.channel.name}")
id = await self.async_input("channel index:")
if int(id) < 0:
return
vcch = self.vcchlients[int(id)]
message = await self.async_input("tts message:")
engine = pyttsx3.init()
engine.save_to_file(text=message, filename="VC_TEMP_TTS.wav")
engine.runAndWait()
source = FFmpegPCMAudio("VC_TEMP_TTS.wav")
vcch.play(source, after=self.VC_after_playing)
logger.success("Audio playback has started")
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()
if int(id) < 0:
return
for client in self.vcchlients:
if self.client.voice_clients[int(id)].channel.id == client.channel.id:
self.vcchlients.remove(client)
break
await self.client.voice_clients[int(id)].disconnect(force=True)

logger.success("Disconnected")
async def vcstop(self):
for i, client in enumerate(self.vcchlients):
Expand Down
37 changes: 28 additions & 9 deletions SpyBot20/SpyAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
from colorama import Fore, init
import Commands
import LocalCommandManager
logger.info("Spy Agent 2.8.1, 2024, progame1201")
logger.info("Spy Agent 2.9.0, 2024, progame1201")
logger.info("Running...")
client:Client = Client(intents=Intents.all())
init(autoreset=True)

async def getmutes():
channels_mute_list = []
guild_mute_list = []
if os.path.exists("channelmutes"):
if os.path.getsize("channelmutes") > 0:
data = open("channelmutes", 'rb').read()
channels_mute_list = pickle.loads(data)
else:
channels_mute_list = []
else:
open("channelmutes", 'wb').close()
channels_mute_list = []
Expand All @@ -32,8 +32,6 @@ async def getmutes():
if os.path.getsize("guildmutes") > 0:
data = open("guildmutes", 'rb').read()
guild_mute_list = pickle.loads(data)
else:
guild_mute_list = []
else:
open("guildmutes", 'wb').close()
guild_mute_list = []
Expand Down Expand Up @@ -110,11 +108,24 @@ async def message_edit():
before, after = await client.wait_for("message_edit")
if channel.id == after.channel.id:
print(f"Message: {before.content} | has been changed to: {after.content} | in: {after.guild}: {after.channel}: {after.author}\n")

async def guild_channel_delete():
while True:
rchannel:channel = await client.wait_for("guild_channel_delete")
if rchannel.guild.id == guild.id:
print(f"channel {rchannel.name} has been deleted\n")
async def guild_channel_create():
while True:
cchannel:channel = await client.wait_for("guild_channel_create")
if cchannel.guild.id == guild.id:
print(f"channel {cchannel.name} has been created\n")
async def guild_join():
while True:
jguild = await client.wait_for("guild_join")
print(f"Client was joined to the {jguild.name} guild")
async def guild_remove():
while True:
guild = await client.wait_for("guild_remove")
print(f"The guild: {guild.name} | has been removed from the guild list (this could be due to: The client has been banned. The client was kicked out. The guild owner deleted the guild.")
rguild = await client.wait_for("guild_remove")
print(f"The guild: {rguild.name} | has been removed from the guild list (this could be due to: The client has been banned. The client was kicked out. The guild owner deleted the guild.\n")

if config.detector:
if config.on_reaction_add:
Expand All @@ -127,6 +138,12 @@ async def guild_remove():
asyncio.run_coroutine_threadsafe(message_edit(), client.loop)
if config.on_guild_remove:
asyncio.run_coroutine_threadsafe(guild_remove(), client.loop)
if config.on_guild_join:
asyncio.run_coroutine_threadsafe(guild_join(), client.loop)
if config.on_guild_channel_create:
asyncio.run_coroutine_threadsafe(guild_channel_create(), client.loop)
if config.on_guild_channel_delete:
asyncio.run_coroutine_threadsafe(guild_channel_delete(), client.loop)
async def receive_messages():
global channel
global guild
Expand Down Expand Up @@ -203,6 +220,8 @@ async def chatting():
cm.new(command_name="***vcconnect", func=cmnds.vcconnect)
cm.new(command_name="***vcstop", func=cmnds.vcstop)
cm.new(command_name="***vcdisconnect", func=cmnds.vcdisconnect)
cm.new(command_name="***activity", func=cmnds.activity)
cm.new(command_name="***vctts", func=cmnds.vctts)
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 @@ -211,7 +230,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\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##############")
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***vctts - plays tts message to the voice channel\n***activity - to put an activity on the bot, for example: playing a game\n#####INFO#####\nall messages are written in the format: guild: channel: author: message\n##############")
continue

cmresult = cm.execute(senddata)
Expand Down
5 changes: 4 additions & 1 deletion SpyBot20/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
on_reaction_remove = True # default == True it only works if it happened in the channel you selected
on_message_delete = True # default == True it only works if it happened in the channel you selected
on_message_edit = True # default == True it only works if it happened in the channel you selected
on_guild_remove = True # default == True
on_guild_remove = True # default == True
on_guild_join = True # default == True
on_guild_channel_create = True # default == True it only works if it happened in the guild you selected
on_guild_channel_delete = True # default == True it only works if it happened in the guild you selected
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
disnake
loguru
pytz
asyncio
asyncio
pyttsx3

0 comments on commit cb13b95

Please sign in to comment.