Skip to content

Commit

Permalink
Wil not select channel users who opt out with not me
Browse files Browse the repository at this point in the history
  • Loading branch information
bibliotechy committed Oct 4, 2013
1 parent acabea3 commit 3820b8b
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions plugins/Cast/plugin.py
Expand Up @@ -35,6 +35,7 @@
import supybot.ircdb as ircdb
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
import supybot.dbi as dbi

import random
import re
Expand Down Expand Up @@ -139,9 +140,29 @@
}

class Cast(callbacks.Plugin):


class DB(plugins.DbiChannelDB):
class DB(dbi.DB):
class Record(dbi.Record):
__fields__ = [
'op'
]


def __init__(self, irc):
self.__parent = super(Cast, self)
self.__parent.__init__(irc)
self.db = plugins.DB('NotMe',{'flat':self.DB})()

def _notme(self, channel):
result = [r.op for r in self.db.select(channel, lambda x: True)]
result.sort()
return result


def _query_tmdb(self, cmd, args):
url = "http://api.themoviedb.org/2.1/%s/en/json/%s/%s" % (cmd,TMDBK,urllib.quote(str(args)))
print url
doc = web.getUrl(url, headers=HEADERS)
try:
json = simplejson.loads(doc)
Expand All @@ -153,7 +174,7 @@ def tmdb(self, irc, msg, args, channel, opts, play):
"""[<movie>]
Cast <movie> from the current channel participants using information retrieved from themoviedb.org."""
random.seed()
nicks = list(irc.state.channels[channel].users)
nicks = list(set(irc.state.channels[channel].users) - set(self._notme(channel)))
random.shuffle(nicks)

maxlen = 20
Expand Down Expand Up @@ -245,7 +266,7 @@ def cast(self, irc, msg, args, channel, work_type, thing):
return False

random.seed()
nicks = list(irc.state.channels[channel].users)
nicks = list(set(irc.state.channels[channel].users) - set(self._notme(channel)))
random.shuffle(nicks)

record = None
Expand Down

0 comments on commit 3820b8b

Please sign in to comment.