BluNET - Home of Ultimate Twitch Bot

Guest


Author Topic: [Request] Custom commands with complicated behevior via scripting  (Read 5964 times)

Zwei

  • Posts: 8
    • View Profile
I made my own python bot awhile back. The functionality I made it was extremley complicated, but so useful I currently run the bot on a few channels. One of the people that use my bot also has his own bot running using ultimate twitch bot, and we were considering merging until we realized that the functionality of my bot could not be implemented in ultimate twitch bot 2.0.2 or ultimate twitch bot 3 alpha.

The way I believe problems like this (not being able to add certain functionality in UTB commands) could be solved is to add user-made "plugin" functionality, where users could make their own python/lua/whatever plugins that would tie into the rest of the bot, so you could have some python code run once a certain command is triggered instead of the default "just respond with this" setup UTB currently has going on.

This would greatly expand the functionality and flexibility of UTB, allowing users to implement more complex and customized functionality to their twitch bot setup.

I understand concerns you may have about stuff like bots logging chat and doing other malicious stuff through scripts, but with python and lua anyone could just open the plugin file in a text editor and make sure nothing sketchy is going on. Good plugin developers should include comments, so paranoid people can see just why each line is there.

As always with scripting, you have to remind people of one of the golden rules of the internet-think before you trust something.

Thanks for considering this feature. I feel like people would be able to do so much more with ultimate twitch bot were this to be implemented.
« Last Edit: June 26, 2015, 01:54:56 AM by SeeingBlue »

SeeingBlue

  • Administrator
  • *****
  • Posts: 748
  • Admin of all this
    • View Profile
    • BluNET
  • Twitch ID: SeeingBlue
Re: [Request] Custom commands with complicated behevior via scripting
« Reply #1 on: June 26, 2015, 01:53:57 AM »
I'm not opposed to this idea, but I don't have much experience with python. I would be willing to work with you to implement something like this though.

Would it be as simple as setting a file path to some python script and executing it?
Want the Latest News?

Follow me on Social Media for News on BluNET & Ultimate Twitch Bot.

Zwei

  • Posts: 8
    • View Profile
Re: [Request] Custom commands with complicated behevior via scripting
« Reply #2 on: June 26, 2015, 09:47:45 AM »
Importing a python script from a directory would be part of it, but details of the implementation would depend on how UTB is currently coded. Here is one way it could be done.

Have the python script include commands as string variables in the header, and have UTB call a function inside of the python script once one of those is said in chat, containing the entire message and the user that sent the message. From there, the function returns the string to respond with, or "None" as an acknowledgement that the command was successful even if there was no response. In between would be the code that would define this "complicated behevior". This would also prevent spying, as the script would only know the message when the command is used. (P.S. for the event of commands with params after, UTB would match with the command if it is at the beginning and has a word boundary after it)

I'm not very experienced with API's or importing plugins. I will do some research on that.

P.S. If you have any problems in python, stackoverflow is an awesome site. 99% of the time, a) your problem has already been answered or b) the nerds there will be able to answer within 24 hours.

EDIT: So essentially a small bit of python in UTB would do something like this: https://lkubuntu.wordpress.com/2012/10/02/writing-a-python-plugin-api/

EDIT 2: To include this python element in UTB, you might want to read up on the stuff here: https://docs.python.org/2/extending/embedding.html

Another thing: Here is an example plugin to show how it would look. This plugin implements the suggestion nightcodex had: http://pastebin.com/H7dfueVN

Something I forgot to include: There should be a 3rd parameter to the command, "permissionLevel", 0-2. It is the permission level of the user that sent the command. 0 = normal person, 1 = mod, and 2 = broadcaster.
« Last Edit: June 26, 2015, 12:31:28 PM by Zwei »

SeeingBlue

  • Administrator
  • *****
  • Posts: 748
  • Admin of all this
    • View Profile
    • BluNET
  • Twitch ID: SeeingBlue
Re: [Request] Custom commands with complicated behevior via scripting
« Reply #3 on: June 29, 2015, 09:08:26 AM »
UTB already does what your pastebin example is showing. Searches incoming messages for a keyword, if keyword is detected run a specific sub routine. Implementing python does seem a little over my head right now though. Not sure it will get added anytime soon, got much more to add before I can justify learning something new.
Want the Latest News?

Follow me on Social Media for News on BluNET & Ultimate Twitch Bot.

Zwei

  • Posts: 8
    • View Profile
Re: [Request] Custom commands with complicated behevior via scripting
« Reply #4 on: June 29, 2015, 10:46:54 PM »
I completely understand. Especially integrating the program into the C++ (or whatever language you use) is very advanced programming, and I understand that perhaps this isn't top on the priority list. I also understand learning a new, VERY different language in order to implement a singular feature may not seem worth it. I'm glad you at least considered the idea :/

Best wishes in continuing development of UTB!

If you ever come back to this suggestion, you may want to look into the "ctypes" library that comes bundled with python 2.5 and later. It may help alot with tying the python loader into the existing application.

Oops. EDIT: This link for integrating python into thing https://wiki.python.org/moin/AppsWithPythonScripting#Tools_For_Integrating_Python should have sent you that one to start off :3
« Last Edit: June 30, 2015, 10:44:24 AM by Zwei »

Zwei

  • Posts: 8
    • View Profile
Re: [Request] Custom commands with complicated behevior via scripting
« Reply #5 on: July 04, 2015, 04:23:20 PM »
Sorry about the double post. Perhaps instead of using python for scripting you could use .NET stuff (I know you use .NET from an error report someone had) in order to load .dll libs instead. A bit harder to develop plugins, but easier on your end.

https://code.msdn.microsoft.com/windowsdesktop/Creating-a-simple-plugin-b6174b62

https://code.msdn.microsoft.com/windowsdesktop/Creating-a-simple-plugin-b45f1d4e
« Last Edit: July 05, 2015, 12:24:19 AM by Zwei »

SeeingBlue

  • Administrator
  • *****
  • Posts: 748
  • Admin of all this
    • View Profile
    • BluNET
  • Twitch ID: SeeingBlue
Re: [Request] Custom commands with complicated behevior via scripting
« Reply #6 on: July 05, 2015, 04:17:15 AM »
Thank you for the research on this topic, I will investigate this.
Want the Latest News?

Follow me on Social Media for News on BluNET & Ultimate Twitch Bot.

LawlyPopzz

  • Posts: 65
  • Crazy But Intelligent
    • View Profile
  • Twitch ID: lawlypopzz
Re: [Request] Custom commands with complicated behevior via scripting
« Reply #7 on: September 03, 2015, 11:51:26 AM »
Thank you for the research on this topic, I will investigate this.

https://www.youtube.com/watch?v=UHOr7MBIFtE <-- thats a pretty good video showing how someone would add a plugin system to there projects