Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
software-project-WS25
Telegram Team
Commits
486ccca4
Commit
486ccca4
authored
Dec 16, 2025
by
Pranav
Browse files
Make the number of historical messages to fetch a value set from external .env file
parent
edc84e44
Pipeline
#12305
passed with stages
in 42 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Desktop/Telegram_Bot/services/telegram_listener.py
View file @
486ccca4
...
...
@@ -23,7 +23,7 @@ API_ID = int(os.getenv("API_ID"))
API_HASH
=
os
.
getenv
(
"API_HASH"
)
SESSION
=
os
.
getenv
(
"SESSION"
)
INVITE_LINK
=
os
.
getenv
(
"INVITE_LINK"
)
LIMIT
=
os
.
getenv
(
"
LIMIT"
);
MESSAGE_
LIMIT
=
int
(
os
.
getenv
(
"
MESSAGE_LIMIT"
,
"50"
))
DATA_DIR
=
Path
(
os
.
getenv
(
"DATA_DIR"
,
"/app/data"
))
OUTPUT_DIR
=
DATA_DIR
/
"output/telegram"
...
...
@@ -222,7 +222,7 @@ async def process_all_channels(client, limit):
for
ch
in
channels
:
try
:
print
(
"Processing Historical Messages"
)
print
(
f
"Processing Historical Messages
for channel
{
ch
.
title
}
"
)
history
=
[
m
async
for
m
in
client
.
iter_messages
(
ch
,
limit
=
limit
)]
for
m
in
reversed
(
history
):
await
process_message_for_storage
(
m
)
...
...
@@ -257,10 +257,10 @@ async def main():
if
target
:
print
(
f
"Listening to channel:
{
target
.
title
}
"
)
await
process_single_channel
(
client
,
target
,
LIMIT
)
await
process_single_channel
(
client
,
target
,
MESSAGE_
LIMIT
)
else
:
print
(
"Listening to all joined channels"
)
await
process_all_channels
(
client
,
LIMIT
)
await
process_all_channels
(
client
,
MESSAGE_
LIMIT
)
print
(
"Listening for messages..."
)
await
client
.
run_until_disconnected
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment