Guest User

Чат от k06a, перезалив SeryiBaran

a guest
Dec 12th, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. @rem BatChat
  2. @echo off
  3. cls
  4. pushd "%~dp0"
  5. echo Current DIR: "%CD%"
  6. if "%~1" == "talk_widget" goto talker
  7.  
  8. rem ================================================
  9.  
  10. rem ////////////////////
  11. :auth
  12. echo Enter chat filename to connect ("abc" for example):
  13. set /p chat=^>
  14. echo Enter your nick:
  15. set /p nick=^>
  16. start call %0 talk_widget %chat% %nick%
  17.  
  18. rem ////////////////////
  19. :listener
  20. cls
  21. call title "| Chat: %chat% | User: %nick% |"
  22. if exist %chat%_history type %chat%_history
  23. if not exist %chat% echo. 2>%chat%
  24.  
  25. :listener_loop
  26. ping 127.0.0.1 -n 1 -w 20 > nul
  27. set oldtext=%text%
  28. set /p text=<%chat%
  29. if not "%text%" == "%oldtext%" echo %text%
  30. goto listener_loop
  31. rem ////////////////////
  32.  
  33. rem ================================================
  34.  
  35. rem ////////////////////
  36. rem // %2 - chat name //
  37. rem // %3 - user nick //
  38. rem ////////////////////
  39. :talker
  40. set chat=%~2
  41. set nick=%~3
  42. cls
  43. call title "| Chat: %chat% | User: %nick% |"
  44. call ::cs_in
  45. echo (%TIME% %nick% connected)>%chat%
  46. call ::cs_out
  47. echo (%TIME% %nick% connected)>>%chat%_history
  48.  
  49. :talker_loop
  50. cls
  51. echo Dear %nick%, type message to send:
  52. set /p msg=^>
  53. call ::cs_in
  54. echo [%TIME% %nick%]: %msg%>%chat%
  55. call ::cs_out
  56. echo [%TIME% %nick%]: %msg%>>%chat%_history
  57. goto talker_loop
  58. rem ////////////////////
  59.  
  60. rem ================================================
  61.  
  62. rem ////////////////////
  63. :cs_in
  64. if exist "%chat%_cs" ping 127.0.0.1 -n 1 -w 50 > nul
  65. set cs_value=%RANDOM%
  66.  
  67. :cs_in_loop
  68. echo %cs_value%>%chat%_cs
  69. set /p ret=<%chat%_cs
  70. if "%ret%" == "%cs_value%" exit /b
  71. ping 127.0.0.1 -n 1 -w 10 > nul
  72. goto :cs_in_loop
  73. rem ////////////////////
  74.  
  75. rem ////////////////////
  76. :cs_out
  77. del %chat%_cs
  78. exit /b
  79. rem ////////////////////
  80.  
  81. rem ================================================
Add Comment
Please, Sign In to add comment