• Members 2 posts
    Oct. 31, 2014, 4:02 a.m.


    I am looking for a solution to get the latest posts to an irc channel, but don't know where to start. My bot is based on the Ruby cinch framework and I already have developed RSS readers and Twitter interfaces for it. I can run a separate forum bot though, so a Ruby compatible solution is not mandatory.

    The easiest solution I could think of would be just reading the database state, and when written to, it would read the newest post. But this feels pretty clunky.

    In short, I would like to know how to pass notifications and posts to external applications. Passing notifications on 'likes' and other events would be a plus.

    Any tips from the more knowledgeable developers on how to design this?

  • Oct. 31, 2014, 5:52 p.m.


    Because this is 0.5 we are speaking, your best bet would be to use Django's build in "events" system called signals to plug in your own signal handler for "post_save" signal that is emitted after data is saved to database.


    Your signal should listen for saves being made to misago.models.Post and see where post is made to avoid pulling out posts made in secret forums or such.

  • Members 2 posts
    Nov. 5, 2014, 4:14 p.m.

    Thank you for the tips, I have already found some good examples from that post_save keyword you gave me.

    I have done a quick pseudo-draft:

    from django.db.models.signals import post_save
    from misago.threads.models.post import Post
    def send(msg):
        # do stuff with msg
    def irc(sender, post):
        send('%s posted: %s' % (user, post))
    post_save.connect(irc, sender=Post)

    Does this look correct?
    What model do I have to use if I want to get the author and the post as a string? I'll worry about proper post sanitation later.

  • Nov. 5, 2014, 4:30 p.m.

    Make sure you check created argument for True to actually be certain that it was called for newly created post.