Skip to content

Channel Changer Plugin #7

Open
Open

Description

@jfredett

When an approved user sends the command

!join-channel <channel>

Percy should join that channel

When an approve user sends the command

!leave-channel <channel>

Percy should leave, the channel in this case should default to the current channel.

Activity

  1. colwem commented on Jul 22, 2012

    @colwem
    Contributor

    Starting work on this issue.

  2. colwem commented on Jul 22, 2012

    @colwem
    Contributor

    I need some assistance. for some reason I can't get anything to match using

    match /match_regex/

    or any of the other forms of that feature in cinch. I even tried making my own cinch project in which I simple copied their demo of that feature and it still isn't working. Could I have something miss configured? could I be missing a prereq. I can't believe that this feature would need any other package since regex is built in.

  3. jfredett commented on Jul 22, 2012

    @jfredett
    ContributorAuthor

    Hmm, do you have your code up in a fork somewhere?

    One thing to make sure is that you're loading the plugin in the rake start command. In the plugin list.

  4. jfredett commented on Jul 22, 2012

    @jfredett
    ContributorAuthor

    Ah- I see (looked at your fork) -- you don't need to add the ! at the beginning of the command. Cinch will add that for you.

  5. colwem commented on Jul 22, 2012

    @colwem
    Contributor

    Ok thank you. I now have it mostly working. It also defaults to

    !leave-channel
    

    is equivalent to

    !leave-channel [current_channel]
    

    Future work

    • I don't have user privelages done and I don't really know where to go on that.
      • how should we manage user privilages.
      • I don't understant irc at all yet so I don't know if there are any built in irc user roles or anything that we should use or wether it should all just be maintained by the bot.
    • check for failure due to malformed channel name or other error and inform the user.
    • rspec. I created an rspec template but I have to figure out how to write specs with cinch

    Git?

    I've updated my branch of the fork. will that be included in the pull request I issued earlier or will I need to request a pull again.

  6. jfredett commented on Jul 22, 2012

    @jfredett
    ContributorAuthor

    Cool.

    As for User Privileges. I think it can just be controlled by an ENV Var at start up, and a command for any privileged user to add another.

    IRC does have a notion of a 'registered' user -- but that's per-server (eg, on freenode, you can register your nickname). Ideally, we only allow registered nicknames to do anything required by an approved user. I think you would need to learn Freenode's IRC API (a series of messages, usually sent to/received from the ChanServ and NickServ users). For a first pass, a series of hardcoded names should suffice.

    When updating a branch associated with a pull request, any update is automatically propagated to the PR. Thus, if you intend to submit two separate PR's, you should have two separate branches. I recommend trying to only have one open at a time, because otherwise you'll end up in rebase hell.

  7. colwem commented on Jul 23, 2012

    @colwem
    Contributor

    I've got an issue I would like some help with. I'm trying to extend the Cinch::User class to contain something like

    class Cinch::User
    
      roles = [:channel => ["colwem", "jfredett"]]
    
      def role? role
        roles[role].include? self
      end
    end
    
    #so that I can call 
    
    do_role_action if irc.user.role? :role

    But I'm really at a loss for exactly how to do this. It's a matter of scope and I've never been very good at scope in ruby (I've never been very good at ruby actually).

    I would like to share my code however I've run into a problem with my understanding of git and github. I've made a branch 'channel_changer' and I would like to push it to github so you can look at it. However I did

    git checkout channel_changer
    git add .
    git commit -m "comment"
    git push
    

    But I can't find branch on github. How do I push the branch such that I can get it on github?

  8. jfredett commented on Jul 23, 2012

    @jfredett
    ContributorAuthor

    As for the first bit, I would recommend, emphatically, not monkey patching the Cinch::User class. since it's responsibility (representing an IRC user) is highly dissimilar from the responsibility of determine user capabilities. Essentially, the relationship between users and their 'approved' status is that of a "HAS_A", not an "IS_A" -- that is to say, it's not a property, but an association. A user may be associated with a "Role" of being approved. To accomplish this, I would structure it as follows:

    class UserRole
      def self.approved?(username)
        ENV["APPROVED_USERS"].include?(username)
      end
    end

    This way, you code becomes:

    do_action if UserRole.approved?(irc.user)

    (mod API mistakes on my part).

    We could then naturally extend that UserRole object to include other roles. Also, we could do:

    class UserRole
      def self.if_approved?(user)
        yield if approved?(user)
      end
    end

    This way, we alter the API to look like:

    UserRole.if_approved?(user) do
      do_action
    end

    Which I think reads a little nicer.

    This way also avoids any sort of weird scope bugs.


    As for the git issue, you probably need to specify git push origin channel_changer, git push -- iirc -- will not, by default, push branches. I could be wrong on that, but it's usually better to do 'git push origin ' (even in the case of master) -- so that you never accidentally push the wrong branch.

    After that, there is a 'branch' dropdown in the upper lefthand corner of the directory listing, should be able to push that and see where the branch lives.

  9. colwem commented on Jul 23, 2012

    @colwem
    Contributor

    Ok jfredett I've added a UserRole class with one class method approved?. I've pushed it with git push origin channel_changer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions