Skip to content

Commit

Permalink
Merge branch 'Development' of https://github.com/JaWarrior12/New-Light
Browse files Browse the repository at this point in the history
…into Development
  • Loading branch information
JaWarrior12 committed Oct 20, 2024
2 parents 709deb8 + 3123c02 commit b26d3a7
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 268 deletions.
7 changes: 6 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ updates:
interval: "weekly"
timezone: "America/New_York"
day: "sunday"
labels:
- "branch: main/production"
- "PR type: dependencies"

- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
"target-branch": "Development"
Expand All @@ -19,4 +23,5 @@ updates:
timezone: "America/New_York"
day: "sunday"
labels:
- "development"
- "branch: development"
- "PR type: dependencies"
22 changes: 22 additions & 0 deletions .github/workflows/deploy_to_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Controls When Workflow Will Run
on:
# Triggers on push/pull, only for specified branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to manually run workflow from Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: self-hosted

# Steps represent a sequence of tasks that will be exectued as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
20 changes: 14 additions & 6 deletions cogs/adcmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ def cog_unload(self):
#@commands.has_role('Developer')
async def banuser(self,ctx,user,*,reason=None):
if ctx.message.author.id in developers:
global banned
try:
user=int(user)
except:
return "Not A Valid Integer"
keya = "all"
keyb = "ban"
gid=str(ctx.message.guild.id)
lists.bannedlist()
data = dumps(lists.readdataE())
print(type(user))
#print(type(user))
if type(user) is discord.Member:
baseUser=user
user=user.id
Expand Down Expand Up @@ -75,6 +77,7 @@ async def banuser(self,ctx,user,*,reason=None):
except:
#print("other")
other["banInfo"].update({str(user):{"reason":reason,"userName":None,"banDate":date}})
lists.setother(other)
lists.setdataE(banlt)
await ctx.send(f'The User With A User Id Of {user} has been BANNED from using New Light')
lists.bannedlist()
Expand All @@ -89,6 +92,7 @@ async def banuser(self,ctx,user,*,reason=None):
@commands.command(name="unban",hidden=False,help="Unbans A User From Using New Light")
async def unban(self,ctx,user_id):
if ctx.message.author.id in developers:
lists.bannedlist()
if str(user_id) not in banned:
await ctx.send(f'The User With An ID Of {user_id} Is Not In The Banned List.')
elif type(user_id)==int:
Expand All @@ -99,8 +103,8 @@ async def unban(self,ctx,user_id):
#await ctx.send(banlt)
banlt["ban"].remove(str(user_id))
other=lists.readother()
await ctx.send(f"User Ban Info: {other["banInfo"][str(user_id)]}")
other["banInfo"].pop(str(user_id))
#await ctx.send(f"User Ban Info: {other["banInfo"][str(user_id)]}")
#other["banInfo"].pop(str(user_id))
lists.setother(other)
#await ctx.send(banlt)
lists.setdataE(banlt)
Expand Down Expand Up @@ -143,6 +147,7 @@ async def unbanguild(self,ctx,gid,*,reason=None):
if ctx.message.author.id in developers:
try:
if type(gid)!=int:
lists.bannedguilds()
data=lists.readdataE()
data["banguilds"].remove(int(gid))
other=lists.readother()
Expand Down Expand Up @@ -173,10 +178,13 @@ async def banlist(self,ctx,opt):
for x in data["ban"]:
#print(x)
try:
ctnt=ctnt+"\n- "+str(x)+f" ; User Name: `{other[str(x)]['userName']}` ; Ban Reason: `{other[str(x)]['reason']}` ; Ban Date: {other[str(x)]['date']}"
if "userName" in list(other[str(x)].keys()):
ctnt=ctnt+"\n- "+str(x)+f" ; User Name: `{other[str(x)]['userName']}` ; Ban Reason: `{other[str(x)]['reason']}` ; Ban Date: {other[str(x)]['banDate']}"
else:
pass
except Exception as e:
await ctx.send(e)
#print(ctnt)
print(e)
#print(ctnt)
await ctx.send(f'Banned Users:\n{ctnt}')
elif opt=="guilds":
try:
Expand Down
4 changes: 2 additions & 2 deletions cogs/faketagcmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
class FakeTagCmds(commands.Cog, name="Fake Tag Database Commands",description="Access The Fake Tag Database, New Light's in-house fake tagged ship tracker."):
def __init__(self, bot: commands.Bot):
self.bot=bot
if bot.application_id != 975858537223847936:
if self.bot.user.id != 975858537223847936:
self.fakeTagDBScanner.start()
def cog_unload(self):
if self.bot.application_id != 975858537223847936:
if self.bot.user.id != 975858537223847936:
self.fakeTagDBScanner.cancel()
else:
pass
Expand Down
80 changes: 32 additions & 48 deletions cogs/plexusSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ class PlexusCmds(commands.Cog, name="Daily Transfer Logs",description="Commands
def __init__(self, bot: commands.Bot):
self.bot = bot
#self.runDailyTransferReport_TimerLoop.start
#print(self.bot.application_id)
if self.bot.application_id == 974045822167679087:
#print(self.bot.user.id)
if self.bot.user.id == 974045822167679087:
self.runDailyTransferReport_TimerLoop.start()
print("start trackLog loop")
#pass
def cog_unload(self):
if self.bot.application_id == 974045822167679087:
if self.bot.user.id == 974045822167679087:
#pass
self.runDailyTransferReport_TimerLoop.cancel()
#else:
Expand Down Expand Up @@ -115,9 +115,9 @@ async def runDailyTransferReport_TimerLoop(self):
print("Running Daily trackLog Loop!")
await self.runDailyTransferReport(self,None,None,None,None)

@runDailyTransferReport_TimerLoop.before_loop
async def before_task_starts(self):
await self.wait_until_ready()
#@runDailyTransferReport_TimerLoop.before_loop
#async def before_task_starts(self):
#await self.wait_until_ready()

@staticmethod
async def runDailyTransferReport(self,servers=None,year=None,month=None,day=None):
Expand All @@ -131,29 +131,29 @@ async def runDailyTransferReport(self,servers=None,year=None,month=None,day=None
elif servers=="all":
pass
elif servers==None:
pass
serversList=[guild.id for guild in self.bot.guilds]
else:
serversList=servers.split(",")
for key in serversList:
logChannel=configs[str(key)]["trackLogChannel"]
shipsToLoop=data[str(key)]["trackList"]
log_file_name=None
logFile=None
today=datetime.now(pytz.UTC)
#print(today)
if year is None:
year=today.year
month=today.month
day=today.day
PlexusServer = self.bot.get_guild(int(key))
print(PlexusServer)
PlexusReportChannel = await PlexusServer.fetch_channel(int(logChannel))
print(PlexusReportChannel)
try:
logChannel=configs[str(key)]["trackLogChannel"]
shipsToLoop=data[str(key)]["trackList"]
log_file_name=None
logFile=None
today=datetime.now(pytz.UTC)
#print(today)
if year is None:
year=today.year
month=today.month
day=today.day
PlexusServer = self.bot.get_guild(int(key))
print(PlexusServer)
PlexusReportChannel = await PlexusServer.fetch_channel(int(logChannel))
print(PlexusReportChannel)
jsondata = lists.get_gzipped_json(f'https://pub.drednot.io/prod/econ/{int(year)}_{int(month)}_{int(day)}/log.json.gz')
shipData = lists.get_gzipped_json(f'https://pub.drednot.io/prod/econ/{int(year)}_{int(month)}_{int(day)}/ships.json.gz')
altShipData = lists.get_gzipped_json(f'https://pub.drednot.io/prod/econ/{int(year)}_{int(month)}_{int(day)}/ships.json.gz')
log_file_name=f"Plexus_Daily_Transfers.txt"
log_file_name=f"{PlexusServer.name}_Daily_Transfers.txt"
shipTotals={}
receiveTotals={}
for ship in shipsToLoop:
Expand Down Expand Up @@ -316,34 +316,18 @@ def writeToFile(sourceDict,sectionTitle,stateVar):
logFile.write(f"{srcShipConversion["name"]} {srcShipConversion["hex_code"]} received {itemCount} {item} from {dstShipConversion["name"]} {dstShipConversion["hex_code"]} \n")
writeToFile(shipTotals,"Transfer Send Logs",0)
writeToFile(receiveTotals,"Transfer Receive Logs",1)
if log_file_name != None:
def yesterday(frmt='%Y-%m-%d', string=True):
return (datetime.now(pytz.UTC) - timedelta(days=1)).strftime('%Y-%m-%d')
if year == None:
message=f"{PlexusServer.name} Daily Transfer Report For {datetime.now(pytz.UTC)}"
else:
message=f"{PlexusServer.name} Daily Transfer Report For {int(year)}_{int(month)}_{int(day)}"
await PlexusReportChannel.send(message,file=discord.File(log_file_name))
os.remove(log_file_name)
except Exception as e:
print(e)
e_type, e_object, e_traceback = sys.exc_info()

e_filename = os.path.split(
e_traceback.tb_frame.f_code.co_filename
)[1]

e_message = str(e)

e_line_number = e_traceback.tb_lineno

print(f'exception type: {e_type}')

print(f'exception filename: {e_filename}')

print(f'exception line number: {e_line_number}')

print(f'exception message: {e_message}')
if log_file_name != None:
def yesterday(frmt='%Y-%m-%d', string=True):
return (datetime.now(pytz.UTC) - timedelta(days=1)).strftime('%Y-%m-%d')
if year == None:
message=f"{PlexusServer.name} Daily Transfer Report For {datetime.now(pytz.UTC)}"
else:
message=f"{PlexusServer.name} Daily Transfer Report For {int(year)}_{int(month)}_{int(day)}"
await PlexusReportChannel.send(message,file=discord.File(log_file_name))
os.remove(log_file_name)
continue
print("Plexus Daily Transfer Report Script Finished")

async def setup(bot: commands.Bot):
Expand Down
Loading

0 comments on commit b26d3a7

Please sign in to comment.