mrshu / brutal-plugins

A set of plugins for brutal, the mighty chatbot
Apache License 2.0
4 stars 2 forks source link

sn: Added command to delete last note from user. #94

Closed JakubNvk closed 9 years ago

JakubNvk commented 9 years ago

To: @mrshu Cc: @pepol @Adman

mrshu commented 9 years ago

@JakubNvk this only deletes the first sticky note that can be found for a given user. Is that what you really wanted to do? I don't think so.

What I thought you'd do would be having two parameters, say nick and id and this command would then delete the nick's note with id id, provided that the user who requested deletion is the original author.

All you'd need to do would be to check if self.notes[nick][id] exists, if event.meta['nick'] is its sender and then just delete it (hopefuly that should work).

JakubNvk commented 9 years ago

@mrshu ping

mrshu commented 9 years ago

@JakubNvk thanks for doing this but I think you overcomplicated things.

Here is how I'd go about doing it:

  1. Check whether the user has some notes in self.notes
  2. Check whether the note-id can be an index in self.notes[user]
  3. Check whether the user who executed this command is the original sender of the note.
  4. If all of the above is true, pop the note and update self.notes.
Adman commented 9 years ago

@mrshu @JakubNvk What I would suggest is that after poping the note, we should check whether the notes list for given user is empty. It true, remove that key from self.notes

JakubNvk commented 9 years ago

@Adman I like that idea! Added it.

mrshu commented 9 years ago

@JakubNvk Thanks for the updates! Apart from those two small nitpicks this looks good!

JakubNvk commented 9 years ago

@mrshu allright, shall I squash?

mrshu commented 9 years ago

@JakubNvk go for it!

mrshu commented 9 years ago

@JakubNvk feel free to merge it too =)