Skip to content

Commit

Permalink
SpyAgent 4.7.0
Browse files Browse the repository at this point in the history
added a special version running on UNIX-like systems
improved the code of some commands
  • Loading branch information
progame1201 committed Jan 15, 2024
1 parent 523a88f commit 5b9a833
Show file tree
Hide file tree
Showing 4 changed files with 293 additions and 69 deletions.
99 changes: 35 additions & 64 deletions SpyBot20/Commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ async def get_history(self):
print("Channel history:\n#####################")
messages.reverse()
for message in messages:
date = message.created_at
rounded_date = date.replace(second=0, microsecond=0)
rounded_date_string = rounded_date.astimezone(pytz.timezone('Europe/Moscow')).strftime('%Y-%m-%d %H:%M')
rounded_date_string = message.created_at.astimezone(pytz.timezone('Europe/Moscow')).strftime('%Y-%m-%d %H:%M')
attachment_list = []
reactions_list = []
msg = f"{message.channel}: {rounded_date_string} {message.author}: {message.content}"
Expand Down Expand Up @@ -84,10 +82,9 @@ async def mutechannel(self):
mutechanelname = await self.async_input("type chanel index: ")
try:
mchannel = self.client.get_channel(channellistformute[int(mutechanelname)])
channels_mute_list.append(channellistformute[int(mutechanelname)])
channels_mute_list.append(mchannel.id)
with open('channelmutes', 'wb') as f:
towrite = pickle.dumps(channels_mute_list)
f.write(towrite)
f.write(pickle.dumps(channels_mute_list))
logger.success(f"Channel '{mchannel.name}' muted")
except Exception as e:
print(f"index not found\n{e}")
Expand All @@ -96,15 +93,14 @@ async def unmutechannel(self):
channels_mute_list = self.getmutes()[0]
for i in range(len(channels_mute_list)):
unmutech = self.client.get_channel(channels_mute_list[i])
channellistforunmute.append(channels_mute_list[i])
print(f"{i}: {unmutech}")
channellistforunmute.append(unmutech.id)
print(f"{i}: {unmutech.name}")
unmutechanelname = await self.async_input("type chanel index: ")
try:
mchannel = self.client.get_channel(channellistforunmute[int(unmutechanelname)])
channels_mute_list.remove(channellistforunmute[int(unmutechanelname)])
channels_mute_list.remove(mchannel.id)
with open('channelmutes', 'wb') as f:
towrite = pickle.dumps(channels_mute_list)
f.write(towrite)
f.write(pickle.dumps(channels_mute_list))
logger.success(f"Channel '{mchannel.name}' unmuted")
except Exception as e:
print(f"index not found\n{e}")
Expand All @@ -118,9 +114,7 @@ async def delete(self):
for i, message in enumerate(messages):
if message.author.id == self.client.user.id:
yourmessages[i] = message
date = message.created_at
rounded_date = date.replace(second=0, microsecond=0)
rounded_date_string = rounded_date.astimezone(pytz.timezone('Europe/Moscow')).strftime('%Y-%m-%d %H:%M')
rounded_date_string = message.created_at.astimezone(pytz.timezone('Europe/Moscow')).strftime('%Y-%m-%d %H:%M')
print(f"{i}: {message.channel}: {rounded_date_string} {message.author}: {message.content}")
data = await self.async_input("message index:")
if data == "" or data == None:
Expand Down Expand Up @@ -178,15 +172,13 @@ async def file(self):
except Exception as e:
print(f"error sending file\n{e}")
async def status(self):
print("status list:\nonline\noffline\nidle")
statuses:dict = {"online":Status.online,"offline":Status.offline, "idle":Status.idle}
print("statuses:")
for key in statuses.keys():
print(key)
status = input("status:")
if status == "online":
await self.client.change_presence(status=Status.online)
if status == "offline":
await self.client.change_presence(status=Status.offline)
if status == "idle":
await self.client.change_presence(status=Status.idle)
if status == "online" or status == "offline" or status == "idle":
if status in statuses.keys():
await self.client.change_presence(status=statuses[status])
logger.success(f"status changed to {status}")
async def guildmute(self):
guildlistformute = []
Expand All @@ -202,8 +194,7 @@ async def guildmute(self):
mguild = self.client.get_guild(guildlistformute[int(muteguildname)])
guild_mute_list.append(mguild.id)
with open('guildmutes', 'wb') as f:
towrite = pickle.dumps(guild_mute_list)
f.write(towrite)
f.write(pickle.dumps(guild_mute_list))
logger.success(f"Guild '{mguild.name}' muted")
except Exception as e:
print(f"index not found\n{e}")
Expand All @@ -212,15 +203,14 @@ async def unmuteguild(self):
guild_mute_list = self.getmutes()[1]
for i in range(len(guild_mute_list)):
unmuteg = self.client.get_guild(guild_mute_list[i])
guildlistforunmute.append(guild_mute_list[i])
guildlistforunmute.append(unmuteg.id)
print(f"{i}: {unmuteg}")
unmutechanelname = await self.async_input("type guild index: ")
try:
mguild = self.client.get_guild(guildlistforunmute[int(unmutechanelname)])
guild_mute_list.remove(mguild.id)
with open('guildmutes', 'wb') as f:
towrite = pickle.dumps(guild_mute_list)
f.write(towrite)
f.write(pickle.dumps(guild_mute_list))
logger.success(f"Guild '{mguild.name}' unmuted")
except Exception as e:
print(f"index not found\n{e}")
Expand All @@ -238,41 +228,22 @@ async def reaction(self):
emoji = emojilist[int(reactemoji)]
except:
return
print("1 - message id")
print("2 - message list")
messageinput = await self.async_input("type number:")
if messageinput == "2":
messages = []
async for message in self.channel.history(limit=50, oldest_first=False):
messages.append(message)
messages.reverse()
for i, message in enumerate(messages):
print(f"{i}: {message.author}: {message.content}")
messageindex = await self.async_input("message index:")
message = messages[int(messageindex)]
await message.add_reaction(emoji)
logger.success(f"message reacted. Emoji: {emoji}")
if messageinput == "1":
messageid = int(await self.async_input("message id: "))
message = await self.channel.fetch_message(int(messageid))
await message.add_reaction(emoji)
logger.success(f"message reacted. Emoji: {emoji}")
if emojiinput == "2":
emoji = await self.async_input("emoji: ")
print("1 - message id")
print("2 - message list")
messageinput = await self.async_input("type number:")
if messageinput == "2":
messages = []
async for message in self.channel.history(limit=50, oldest_first=False):
messages.append(message)
messages.reverse()
for i, message in enumerate(messages):
print(f"{i}: {message.author}: {message.content}")
messageindex = await self.async_input("message index:")
message = messages[int(messageindex)]
await message.add_reaction(emoji)
logger.success(f"message reacted. Emoji: {emoji}")
print("1 - message id")
print("2 - message list")
messageinput = await self.async_input("type number:")
if messageinput == "2":
messages = []
async for message in self.channel.history(limit=50, oldest_first=False):
messages.append(message)
messages.reverse()
for i, message in enumerate(messages):
print(f"{i}: {message.author}: {message.content}")
messageindex = await self.async_input("message index:")
message = messages[int(messageindex)]
await message.add_reaction(emoji)
logger.success(f"message reacted. Emoji: {emoji}")
if messageinput == "1":
messageid = int(await self.async_input("message id: ") )
message = await self.channel.fetch_message(int(messageid))
Expand All @@ -285,11 +256,12 @@ async def privatemsg(self):
user:User = self.client.get_user(usrid)
msg = await self.async_input(f"{Fore.LIGHTBLACK_EX}Message to {user.name}:")
await user.send(msg)
async def pmreset(self):

async def setuser(self):
usrid = int(await self.async_input("user id:"))
user: User = self.client.get_user(usrid)
self.channel = user
return {"channel":user}
return {"channel":user, "guild":None}
async def edit(self):
messages = []
yourmessages: dict[int:Message] = {}
Expand All @@ -299,8 +271,7 @@ async def edit(self):
for i, message in enumerate(messages):
if message.author.id == self.client.user.id:
yourmessages[i] = message
date = message.created_at
rounded_date_string = date.astimezone(pytz.timezone('Europe/Moscow')).strftime('%Y-%m-%d %H:%M')
rounded_date_string = message.created_at.astimezone(pytz.timezone('Europe/Moscow')).strftime('%Y-%m-%d %H:%M')
print(f"{i}: {message.channel}: {rounded_date_string} {message.author}: {message.content}")

data = await self.async_input("message index:")
Expand Down
12 changes: 7 additions & 5 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.6.0, 2024, progame1201")
logger.info("Spy Agent 2.7.0, 2024, progame1201")
logger.info("Running...")
client:Client = Client(intents=Intents.all())
init(autoreset=True)
Expand Down Expand Up @@ -41,7 +41,7 @@ async def getmutes():
def calculate_file_hash(file_path):
sha256_hash = hashlib.sha256()
with open(file_path, "rb") as file:
for byte_block in iter(lambda: file.read(4096), b""):
for byte_block in iter(lambda: file.read(), b""):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest()
def check_file_integrity(file_path):
Expand Down Expand Up @@ -194,15 +194,16 @@ async def chatting():
cm.new(command_name="***edit", func=cmnds.edit)
cm.new(command_name="***into", func=cmnds.into)
cm.new(command_name="***set", func=cmnds.set)
cm.new(command_name="***setuser", func=cmnds.setuser)
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)
await get_history(channel)
while True:
await sleep(1)
senddata = await async_input(f"{Fore.LIGHTBLACK_EX}Message to {guild.name}: {channel.name}:\n{Fore.RESET}")
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#####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\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##############")
continue

cmresult = cm.execute(senddata)
Expand All @@ -212,7 +213,8 @@ async def chatting():
if "channel" in list(cmresult.keys()):
channel = cmresult["channel"]
if "guild" in list(cmresult.keys()):
guild = cmresult["guild"]
if cmresult["guild"] != None:
guild = cmresult["guild"]
continue

try:
Expand Down
Loading

0 comments on commit 5b9a833

Please sign in to comment.