Advertisement
Jacob_DiDiodato

Twitch Bot Control Panel

Mar 9th, 2017
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.39 KB | None | 0 0
  1. ;Project Name: twitchwriter.au3
  2. ;Author Name: Jacob DiDiodato
  3. ;Project Version: 1.0
  4. ;Last Edit: Thursday March 9th 2017 @ 3:33 AM
  5. ;This program is a simple bot for a twitch stream. It will send a message that you give it to the twitch chat if the chat is positioned correctly (The chatbox must have a position in it that is 1160X 615Y) every 20 minutes (approx.)
  6. ;Usage: Begin the program follow the prompts and the first thing you should do is select "edit messages" because the program, by default, has no messages in it and won't print anything unless it actually has a message to print
  7. ;Notes: The program has space for 5 messages by default. In order to increase it edit the number on line 13
  8.  
  9. #include <MsgBoxConstants.au3>
  10. #include <AutoItConstants.au3>
  11. #include <GUIConstantsEx.au3>
  12.  
  13. Global $MAXMESSAGES = 5
  14.  
  15. Global $array[$MAXMESSAGES]
  16. Global $arrPos = 0
  17. Global $timePassed = 0
  18. Global $second = 1000
  19. Global $minute = 60 * $second
  20.  
  21. For $i = 0 To (UBound($array) - 1) Step 1
  22.    $array[$i] = ""
  23. Next
  24.  
  25. MsgBox(0, "Waiting", "First, select the twitch stream window")
  26.  
  27. Opt('MustDeclareVars', 1)
  28.  
  29. Func SendMsg($string)
  30.    If $string <> "" Then
  31.       MouseClick("left", 1160, 615)
  32.       Send($string)
  33.       Send("{Enter}")
  34.       $arrPos = $arrPos + 1
  35.    ElseIf $array[0] == "" Then
  36.       Return
  37.    Else
  38.       $arrPos = 0
  39.       SendMsg($array[$arrPos])
  40.    EndIf
  41. EndFunc
  42.  
  43. Func EditMessages()
  44.    If IsArray($array) Then
  45.       For $i = 0 To (UBound($array) - 1) Step 1
  46.          Local $input
  47.  
  48.          $input = InputBox("New Message", "Enter a new message for message #" & ($i + 1) & ". Previous message was: " & $array[$i] & ". Enter nothing to stop input.")
  49.  
  50.          If $input == "" Then
  51.             For $j = $i To (UBound($array) - 1) Step 1
  52.                $array[$j] = ""
  53.             Next
  54.             Return
  55.          Else
  56.             $array[$i] = $input
  57.          EndIf
  58.  
  59.          $arrPos = 0
  60.       Next
  61.    Else
  62.       MsgBox(0, "Error", "This variable is not an array")
  63.    EndIf
  64.  
  65. EndFunc
  66.  
  67. Func DisplayMessages($array)
  68.    If IsArray($array) Then
  69.       Local $MsgBoxMsg = ""
  70.       For $i = 0 To (UBound($array) - 1) Step 1
  71.          $MsgBoxMsg &= "Message " & String($i + 1) & ": " & $array[$i] & @LF
  72.       Next
  73.       MsgBox(0, "Messages", $MsgBoxMsg)
  74.    Else
  75.       MsgBox(0, "Error", "This variable is not an array")
  76.    EndIf
  77. EndFunc
  78.  
  79. Func MainGUI()
  80.   Local $Button1, $Button2, $Button3, $Msg1, $Msg2, $Msg3, $Msg4, $Msg5, $buttonClicked
  81.  
  82.   GUICreate("Twitch Bot Control Panel", 320, 40)
  83.  
  84.   Opt("GUICoordMode", 2)
  85.   $Button1 = GUICtrlCreateButton("Send Message", 10, 10, 100)
  86.   $Button2 = GUICtrlCreateButton("Edit Messages", 0, -1)
  87.   $Button3 = GUICtrlCreateButton("Display Messages", 0, -1)
  88.  
  89.   GUISetState()
  90.  
  91.   ; Run the GUI until the window is closed
  92.   While 1
  93.     Local $hTimer = TimerInit()
  94.     $buttonClicked = GUIGetMsg()
  95.     Select
  96.      Case $buttonClicked = $GUI_EVENT_CLOSE
  97.        ExitLoop
  98.      Case $buttonClicked = $Button1
  99.        If $arrPos == $MAXMESSAGES Then
  100.          $arrPos = 0
  101.        EndIf
  102.        SendMsg($array[$arrPos])
  103.        $timePassed = 0
  104.      Case $buttonClicked = $Button2
  105.        EditMessages()
  106.      Case $buttonClicked = $Button3
  107.        DisplayMessages($array)
  108.     EndSelect
  109.     Local $fDiff = TimerDiff($hTimer)
  110.     $timePassed = $timePassed + $fDiff
  111.     ;MsgBox(0, "", "Current time passed: " & String($timePassed))
  112.     If $timePassed > ($minute * 20) Then
  113.       If $arrPos == $MAXMESSAGES Then
  114.          $arrPos = 0
  115.        EndIf
  116.        SendMsg($array[$arrPos])
  117.        $timePassed = 0
  118.     EndIf
  119.   WEnd
  120. EndFunc
  121.  
  122. MainGUI()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement