Closed zerocarbthirty closed 5 years ago
Hi, I made a little progress here.
This requires apscheduler and it seems to work outside of Cardinal but when I try to make it into a plugin I get this error: "ValueError: The following arguments have not been supplied: self, cardinal, user, channel, msg" I guess I am still confused as to how other plugins such as 'calculator' get the "self" variables defined. Can someone help me?
from apscheduler.schedulers.background import BackgroundScheduler
class announcementPlugin(object):
def twitter(self, cardinal, user, channel, msg):
cardinal.sendMsg(channel, 'Follow me on Twitter! https://twitter.com')
scheduler = BackgroundScheduler()
scheduler.add_job(twitter, 'interval', seconds=3)
scheduler.start()
def setup():
return announcementPlugin()
Hey @zerocarbthirty, as far as your first question goes, I don't know of any plugins that handle this yet. However, if you take a look at the "remind" plugin, it does use a timer in order to "schedule" messages. I'm not familiar with apscheduler
, but Python has a library for this built-in: https://docs.python.org/2/library/sched.html
As far as your second question goes, I added Github's syntax highlighting to your comment. However, it appears as though apscheduler
is calling twitter()
. Normally, the bot itself would call functions with the specified parameters. I suggest writing an __init__
function, to register a scheduler using Python's built-in library. You will not receive all those parameters as Python's scheduling library will be calling the function, not the Cardinal IRC bot. So you may need to either create a configuration file, or hardcode the values you want (such as the channel).
Feel free to join #cardinal
on irc.darkscience.net/+6697
(SSL required), and I can try to help you through this a little more. It seems like a fundamental gap in how Python and Cardinal work. :) I'm happy to help you implement this.
Okay, I assumed that because Cardinal was calling the code that Cardinal's variables would be defined in that space. I have a few other types of commands I need as well, is there some way that I could compensate you to create a few skeleton plugins with a couple of different use cases? They would be available to everybody of course and that way I could focus more on the content of what i'm doing rather than worrying as much about the boat the content is delivered in? If not I will keep hammering away at it =) I love Cardinal and I think it could be the premier bot for nerds who play games on Twitch. (me)
Has anyone implemented a plugin that will make a bot do "something" every X seconds?
for example the bot could just say "Welcome to the channel..." or "check out my Youtube" or "follow me on twitter" every 60 seconds.. bonus if you can define multiple messages and have it say them every X amount seconds individually.