Hexchat twitch script question reddit / irc ---------------------------------------------------------------------- Montaru · 2015-06-06 01:45 Okay, I have a couple questions for me to try to make a twich bot. * A way to have a check to see if a user in the chat is an op ([I had tried the is_op() from this, but couldn't get it to work](https://gith ub.com/TingPing/plugins/blob/f5931e53cdc508a2d401ccc5ea8d62e206364095/ HexChat/banhelper.py)) ~~and to check their name (I tired n = word[0] with if (hexchat.nickcmp(n,"montaru") ==0, as well as just if n =="montaru" but any account could use the command I put under it.)~~ * A way to check additional info from a chat event. So, putting in "!changeGame Bayonetta" or "!changeGame Kirby 64" would change a string to the game after the !changeGame. * Making a timer and exporting the time stamp to a separate file with a command. This is to help with a highlight command, so when it is implemented, the time from where the timer started is recorded and I can access it outside the chat Code is in python. [This is the skeleton base I'm using](https://github.com/poklj/Pybot/blob/master/pybot1.py) ---------------------------------------------------------------------- TingPing · 2015-06-07 23:13 > A way to have a check to see if a user in the chat is an op That script is technically correct but the Twitch IRC server is... a pretty broken IRC server and often is out of sync. > A way to check additional info from a chat event. So, putting in "!changeGame Bayonetta" or "!changeGame Kirby 64" would change a string to the game after the !changeGame. Just `hook_print("Channel Message", ...)` and do whatever. See also: [the docs](https://hexchat.readthedocs.org/en/latest/script_python.htm l#hexchat.hook_print) Not quite sure i understand your timer comment. > Code is in python. This is the skeleton base I'm using I'm not really sure there is any value in basing a script off that, it doesn't do anything special and just adds extra crap that may only confuse someone unfamiliar with hexchat/python. ---------------------------------------------------------------------- Montaru · 2015-06-08 17:57 Nevermind, got it to work ---------------------------------------------------------------------- Montaru · 2015-06-08 18:37 Okay new problem, I'm not being able to change the string. I have "game" initialized as None at the start, but it won't change with game = word[1].replace("changeGame","") or if it is being changed, it won't be read in def currentGame(): hexchat.command("say Current game being played is {}".format(game)) (though before I type changeGame, the command works fine to just say None) As well, to explain the timer. Have an internal stopwatch being run, and whenever someone types in something, "+ht" as an example, it takes the current time from that timer and pastes it into a txt document that I can view later. What I need now is how to initialize this stopwatch, and how to grab the time, I found a way to move prints into a txt file. ---------------------------------------------------------------------- TingPing · 2015-06-09 01:24 > As well, to explain the timer. Have an internal stopwatch being run, and whenever someone types in something, "+ht" as an example, it takes the current time from that timer and pastes it into a txt document that I can view later. What I need now is how to initialize this stopwatch, and how to grab the time, I found a way to move prints into a txt file. You don't need a timer: [time.time()](https://docs.python.org/2/library/time.html#time.time) >Okay new problem, I'm not being able to change the string. I have "game" initialized as None at the start, but it won't change Probably want to mark it global to edit it? game = '' def func(): global game game = 'something' ---------------------------------------------------------------------- Montaru · 2015-06-09 02:43 The time function works, but I'm looking for a small interval instead of the entire area of time from the first of January. So when I say "!startStream" the timer becomes 0. Then I can pick up that from that timer. [I tried the one from mestrelion, but couldn't get it to initialize if this is even what I'm looking for.](http://stackoverflow.com/questions/3393612/run-certain-code- every-n-seconds) Also, the global suggestion wasn't working. ---------------------------------------------------------------------- TingPing · 2015-06-09 02:57 Ok, so just get the time when something starts, get the time when something ends, and subtract it so you know how long it lasted. EDIT: If you actually need a timer to stop something after X seconds, see `hexchat.hook_timer()` ---------------------------------------------------------------------- Montaru · 2015-06-09 03:33 Okay, I'm not sure if you are fully understanding what I am trying to use this timer for. So, what I'm looking for with the timer is something to start at around the time I start the stream. And whenever someone in the chat types in "+ht" it will take the time from that timer, and type it into a text file. That's all the bot needs to do. Later after the stream, I can look into that text file, and go to those parts of the stream in the past boradcasts, and make it into a highlight. One thing I can try in the morning is save the initial time to subtract from the "+ht" grabs, but if you can see an easier way, I'm all ears. As well, apparently it isn't letting me change the initialized things with a command from the "changeGame" attempts ---------------------------------------------------------------------- TingPing · 2015-06-09 03:39 > One thing I can try in the morning is save the initial time to subtract from the "+ht" grabs, but if you can see an easier way, I'm all ears. Yes that is exactly what I suggested and the exact correct way to do it. You care about specific snapshots in time. > As well, apparently it isn't letting me change the initialized things with a command from the "changeGame" attempts My comment about global is the only issue I can think of. If you pastebin a full script or maybe stop by #hexchat on freenode to debug it further. ---------------------------------------------------------------------- Montaru · 2015-06-09 18:47 Okay, I have gotten the code to be just about exactly as I wanted it to work (aside from the op thing). Thank you for all your help, as well as my apologies for anytime I might had come across as rude and or stupid. ---------------------------------------------------------------------- swtsplin · 2015-06-10 06:37 http://www.reddit.com/r/Twitch/comments/398qry/time_stamp_help/ the same thread in other sub, is it what you wanted? ---------------------------------------------------------------------- Montaru · 2015-06-10 08:52 Also, I found out the problem with the is_op(), it checks if the script is using an op'd account not who is saying. Don't know how to fix it, but, just so you know.