Permalink
Browse files

Fixing debug problem

  • Loading branch information...
Clinton Ecker
Clinton Ecker committed Oct 27, 2008
1 parent 470770d commit 8ff7a000f9b2f8b6a039c2fd1fa0469a20bbc188
Showing with 21 additions and 12 deletions.
  1. +1 −1 twittersmash/admin.py
  2. +16 −10 twittersmash/management/commands/smash_stuff.py
  3. +4 −1 twittersmash/models.py
View
@@ -10,7 +10,7 @@ class FeedAdmin(admin.ModelAdmin):
list_display = ('name', 'url', 'last_checked', 'polling_rate')
class TwitterAccountAdmin(admin.ModelAdmin):
- list_display = ('username', 'philter', 'minimum_datetime', 'strip_tags', 'prepend_names', 'active')
+ list_display = ('username', 'philter', 'philter_replies', 'minimum_datetime', 'strip_tags', 'prepend_names', 'active')
admin.site.register(Message, MessageAdmin)
admin.site.register(Feed, FeedAdmin)
@@ -19,7 +19,7 @@
class Command(BaseCommand):
help = "Loops through feeds and determines if messages need to be sent to any twitter accounts"
option_list = BaseCommand.option_list + (
- make_option('--dryrun', '-d', action='store_true', dest='dryrun', default=False,
+ make_option('--dryrun', '-D', action='store_true', dest='dryrun', default=False,
help='Go through the motions but commit nothing to Twitter'),
make_option('--quiet', '-q', action='store_true', dest='quiet', default=False,
help='Don\t print anything to console'),
@@ -41,7 +41,7 @@ def handle(self, *args, **options):
for account in accounts:
reply_re = re.compile(r'\@%s' % account.username)
# Prepare keywords
- keywords = account.philter.lower().split(',')
+ keywords = account.philter.lower().strip().split(',')
keywords = map(string.strip, keywords)
# Prep minimum DT
if account.minimum_datetime:
@@ -122,22 +122,28 @@ def handle(self, *args, **options):
print " * Skipped because of time restrictions"
else:
# Check to see if this message contains any of the keywords
- for keyword in keywords:
- if keyword in message.lower():
- send_to_twitter = True
- break
+ if keywords:
+ for keyword in keywords:
+ if keyword in message.lower():
+ send_to_twitter = True
+ break
+ else:
+ send_to_twitter = True
# Check to see if the message was directed at this account
- if reply_re.search(message):
- send_to_twitter = True
- message = reply_re.sub('', message).strip()
+ if account.philter_replies:
+ if reply_re.search(message):
+ send_to_twitter = True
+ message = reply_re.sub('', message).strip()
if send_to_twitter:
if account.strip_tags:
print "Removing tags"
message = tag_re.sub('', message)
-
+
+ if account.append_tags:
+ pass
# Clean up whitespace
message = message.strip()
View
@@ -25,9 +25,12 @@ class TwitterAccount(models.Model):
username = models.CharField(_('username'), blank=True, max_length=80)
password = models.CharField(_('password'), blank=True, max_length=80)
philter = models.CharField(_('filter'), help_text='Only messages containing this phrase will be passed on to the twitter account. For multiple phrases, seperate them by a comma.', blank=True, max_length=80)
+ philter_replies = models.BooleanField(_('filter replies'), help_text="Tick this box to filter @replies automatically", default=True)
minimum_datetime = models.DateTimeField(_('minimum datetime'), help_text='Do not smash tweets that occured before this date/time', blank=True, null=True)
strip_tags = models.BooleanField(_('strip tags'), default=False)
- prepend_names = models.BooleanField(default=True)
+ prepend_names = models.BooleanField(_('prepend names'), help_text="Tick this box to prepend the names of the individual twitter accounts to the smashed message", default=True)
+ append_tags = models.BooleanField(_('append tags'), help_text="Take all tags and put them at the end", default=True)
+
active = models.BooleanField(_('active'), default=True)
feeds = models.ManyToManyField(Feed)

0 comments on commit 8ff7a00

Please sign in to comment.