-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_telegram_bot_api.py
39 lines (32 loc) · 990 Bytes
/
run_telegram_bot_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: ArianOmrani - https://github.com/arian24b/
# Git repository: https://github.com/arian24b/telegrambotapi
from subprocess import run, CalledProcessError
from tempfile import mkdtemp
from os import rmdir
# Configuration
API_ID = "123456"
API_HASH = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
HTTP_PORT = "5687"
telegram_bot_api_binary = "/path/to/telegram-bot-api"
# Create a temporary directory
temp_dir = mkdtemp(prefix="telegram-bot-api-")
# Arguments to pass to the telegram-bot-api binary
args = [
telegram_bot_api_binary,
f"--api-id={API_ID}",
f"--api-hash={API_HASH}",
f"--http-port={HTTP_PORT}",
f"--dir={temp_dir}",
f"--temp-dir={temp_dir}",
"--local",
]
# Execute the telegram-bot-api binary with the specified arguments
try:
run(args, check=True)
except CalledProcessError as e:
print(f"An error occurred: {e}")
finally:
# Clean up the temporary directory if needed
rmdir(temp_dir)