Greetings, I apologize if this has been discussed previously.
I host a TeamSpeak server and had the idea of implementing a chat bot as in the old days of IRC. What I’d like to do is have the bot send random lines of chat on occasion. I was thinking of using trivia, or simply lines of nonsense silliness. I thought I would create a txt document as my database then have AppleScript copy random lines at random intervals and paste these lines into the chat client window and hit . Is such a thing possible? Maybe I would need to have multiple documents nested in a folder and have AppleScript open a random document, execute a Select All, Copy, Paste into TeamSpeak, . Anyway, those ideas are bouncing around in my noggin. If I need to clarify my intent, please let me know.
Try this. Tweak the items below to your needs, but this should do it.
Save it as an application, and tick the “Keep Open” check.
on idle {}
set ran to random number from 0 to 600 --set the range of seconds
doit()
return ran
end idle
on doit()
set theListing to (open for access ":Users:<yourUsername>:Desktop:123.txt") -- set to your filename and path
set listContents to (read theListing for (get eof theListing))
set delimitedList to paragraphs of listContents
set theChoice to some item of delimitedList
tell application "TextEdit" -- set to your application (teamspeak)
activate
delay 3 -- the delay may need to be longer depending on how long it takes to switch.
tell application "System Events" to keystroke theChoice
tell application "System Events" to keystroke return
end tell
end doit