Skip to content

Commit ac1320a

Browse files
authored
Merge pull request #41 from Lacentix/master
dumpyara: properly store initial message ID
2 parents 3c44fb6 + 36e3426 commit ac1320a

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

dumpyarabot/handlers.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,26 @@ async def dump(
111111
message_id=initial_message.message_id,
112112
)
113113

114+
initial_msg = await context.bot.send_message(
115+
chat_id=chat.id,
116+
reply_to_message_id=None if use_privdump else message.message_id,
117+
text=f"{dump_args.url.unicode_string()} dump started",
118+
)
119+
120+
dump_args.initial_message_id = initial_msg.message_id
121+
114122
console.print("[blue]Calling Jenkins to start build...[/blue]")
115123
response_text = await utils.call_jenkins(dump_args)
116124
console.print(f"[green]Jenkins response: {response_text}[/green]")
117125

118126
except ValidationError:
119127
console.print(f"[red]Invalid URL provided: {url}[/red]")
120128
response_text = "Invalid URL"
129+
await context.bot.send_message(
130+
chat_id=chat.id,
131+
reply_to_message_id=None if use_privdump else message.message_id,
132+
text=response_text,
133+
)
121134
except Exception:
122135
console.print("[red]Unexpected error occurred:[/red]")
123136
console.print_exception()

dumpyarabot/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ class DumpArguments(BaseModel):
1414
use_alt_dumper: bool
1515
add_blacklist: bool
1616
use_privdump: bool
17+
initial_message_id: Optional[int] = None

dumpyarabot/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async def call_jenkins(args: schemas.DumpArguments) -> str:
110110
"URL": args.url.unicode_string(),
111111
"USE_ALT_DUMPER": args.use_alt_dumper,
112112
"ADD_BLACKLIST": args.add_blacklist,
113+
"INITIAL_MESSAGE_ID": args.initial_message_id,
113114
},
114115
auth=(settings.JENKINS_USER_NAME, settings.JENKINS_USER_TOKEN),
115116
)

extract_and_push.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
CHAT_ID="-1001412293127"
99

10+
[[ -z ${INITIAL_MESSAGE_ID} ]] && START_MESSAGE_ID="" || START_MESSAGE_ID="${INITIAL_MESSAGE_ID}"
11+
1012
# usage: normal - sendTg normal "message to send"
1113
# reply - sendTg reply message_id "reply to send"
1214
# edit - sendTg edit message_id "new message" ( new message must be different )

0 commit comments

Comments
 (0)