forked from svtcore/telegram-referral-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
45 lines (42 loc) · 1.8 KB
/
bot.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
40
41
42
43
44
45
from classes.main import Main
from classes.auth import Auth
from dotenv import load_dotenv
import os
import argparse
import sys
load_dotenv()
BOT_NAME = os.getenv('BOT_NAME')
COUNT = os.getenv('COUNT')
REFER_ID = os.getenv('REFER_ID')
DELAY_MIN = os.getenv('DELAY_MIN')
DELAY_MAX = os.getenv('DELAY_MAX')
CHANNEL_NAME = os.getenv('CHANNEL_NAME')
JOIN_CHANNEL = None
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Process command line arguments")
parser.add_argument("-a", "--auth", action="store_true", help="Flag to start authentication")
parser.add_argument("-r", "--run", action="store_true", help="Flag to run bot")
parser.add_argument("-ch", "--channel", action="store_true", help="Flag to enable join to channel")
parser.add_argument("-t", "--tokens", type=str, help="Name of the file to load tokens")
parser.add_argument("-p", "--proxies", type=str, help="Name of the file to load proxies")
parser.add_argument("-s", "--strings", help="Enable using string sessions", action='store_true')
args = parser.parse_args()
if args.channel:
JOIN_CHANNEL = True
if args.tokens:
bot = Main(BOT_NAME, COUNT, JOIN_CHANNEL, CHANNEL_NAME, DELAY_MIN, DELAY_MAX, REFER_ID, args.tokens, args.proxies, args.strings)
if not args.strings:
bot.check_sessions_folder()
if args.auth:
auth = Auth(args.tokens, args.proxies)
auth.start()
if args.run:
bot.start()
if not args.auth and not args.run:
parser.error("At least one of --auth or --run must be provided")
sys.exit(1)
else:
print("Error: File with tokens not specified.")
print("Please specify the file containing tokens using the -t or --tokens option.")
sys.exit(1)
print("Done")