facts: show the source of facts, if desired

This commit is contained in:
Brian S. Stephan 2015-06-20 10:46:52 -05:00
parent fe3a5ede3d
commit 934f83b734
1 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,8 @@ from __future__ import unicode_literals
import logging
from irc.client import NickMask
from ircbot.lib import Plugin
from facts.models import Fact
@ -38,7 +40,13 @@ class Facts(Plugin):
fact = Fact.objects.random_fact(category, regex)
if fact:
return self.bot.reply(event, fact.fact)
if fact.category.show_source:
nick = NickMask(fact.nickmask).nick
msg = "{0:s} ({1:s})".format(fact.fact, nick)
else:
msg = fact.fact
return self.bot.reply(event, msg)
plugin = Facts