Skip to content

Commit

Permalink
feat: mock fly
Browse files Browse the repository at this point in the history
  • Loading branch information
horw committed Jan 9, 2024
1 parent 630f5d2 commit 396260d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion configure/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class Config(BaseModel):
sheet_url: Optional[str] = ''
channels_id: List[int] = []

@validator("interval", "checkpoint_timer", "interval", pre=True, always=True)
@validator("timer", "interval", "checkpoint_timer", pre=True, always=True)
def _min_to_sec(cls, value: int):
return value * 60
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def connect_window_error(error_str):
try:
bot.DATA = open(bot.tasks_path.replace('tasks.csv', 'taskscopy.csv'), 'rb').read()
# DATA_CA = open(TASKS_PATH.replace('tasks.csv', 'taskscopyCA.csv'), 'rb').read()
except:
except Exception as e:
print(e)
input('Tasks error')
sys.exit(0)

Expand All @@ -107,7 +108,6 @@ def restart_func():
bot.restart()



def open_link(link, site_link, sizes, sku, msg):
global TIME, TIME_CHECKPOINT, RESTART_PROCESS, NETWORK_USAGE, current_tasks_sites, window
print('Open Function...')
Expand All @@ -134,7 +134,7 @@ def open_link(link, site_link, sizes, sku, msg):
embed['color'] = 8190976
embed['fields'] = []
embed['fields'].append({'name': 'Time', 'value': f'{t}'})
embed['fields'].append({'name': 'Bot Name', 'value': f"{bot['name']}"})
embed['fields'].append({'name': 'Bot Name', 'value': f"{bot.name}"})
embed['fields'].append({'name': 'MONITOR', 'value': msg.channel.name})
embed['footer'] = {
'icon_url': 'https://cdn.discordapp.com/attachments/696345463099621478/752526723806920744/106481578_2024239424376214_1105798686871767184_o.png',
Expand Down Expand Up @@ -261,8 +261,8 @@ def discord_bot():
intents = discord.Intents.default()
intents.message_content = True

client = discord.Client(intents=intents)
# client = discord.Client(intents=intents, proxy="http://localhost:1080")
# client = discord.Client(intents=intents)
client = discord.Client(intents=intents, proxy="http://localhost:1080")

##START ROUTINE
@client.event
Expand Down
8 changes: 8 additions & 0 deletions mock/fly-mock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

print("fly fly fly")
while True:
try:
i = input("Wait for input")
print(i)
except Exception as e:
print(e)
7 changes: 7 additions & 0 deletions mock/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import subprocess

prpr = subprocess.Popen(r"D:\Projects\Python\discord-driven-action\mock\dist\fly-mock.exe",
creationflags=subprocess.CREATE_NEW_CONSOLE,
stdin=subprocess.PIPE)

input()
5 changes: 3 additions & 2 deletions programs/fly.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ def start(self, link, sku, sizes=None):
'SIZEBQT', sizes).replace('SKUBQT', sku).encode('utf-8'))

os.chdir(self.path.replace('fly-cli.exe', ''))

print("Start program on path: ", self.path)
prpr = subprocess.Popen(f"{self.path}",
creationflags=subprocess.CREATE_NEW_CONSOLE,
stdin=subprocess.PIPE)
self.fly_windows.append(prpr)
try:
prpr.communicate(b'\n', timeout=0.1)
prpr.stdin.write(b'\n')
prpr.stdin.flush()
except:
print("Command send to fly")

Expand Down

0 comments on commit 396260d

Please sign in to comment.