Bug fixes to handle spam / capital letters

This commit is contained in:
aewens 2018-09-16 00:27:38 -04:00
parent 97cdb98542
commit d90d1a9567
6 changed files with 25 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
# App-specific
settings.json
settings.demo.json
data/*.json
irc/

View File

@ -8,7 +8,10 @@ def botlist(self, name, source, response):
"!rollcall",
"!summon",
"!banish",
"!pardon"
"!pardon",
"!hmmscore",
"!hmmscoreboard",
"!whois"
])
args = (botnick, author, email, about, commands)
message = "{} | {} <{}> | {} | {}".format(*args)

11
app.py
View File

@ -9,10 +9,15 @@ from coroutines import coroutines
debug = False
kingme = [] if debug else ["#chaos"]
channels = ["#bots", "#insane"]
# if not debug:
# channels.extend([])
if not debug:
channels.extend([
"#meta",
"#team",
"#chaos",
"#tildeverse"
])
bot = Bot("127.0.0.1", 6667, "BabiliBot|py", channels)
bot = Bot("127.0.0.1", 6667, "BabiliBot", channels)
responses = Responses(bot)
tasks = Tasks(bot)

View File

@ -17,6 +17,9 @@ class Responses:
def allowed(self, name, source):
memories = self.bot.memories
users = memories["users"]
if name not in users:
return False
if name in users and "blacklist" in users[name]:
reason = users[name]["blacklist"]["reason"]
message = "is ignoring {} for reason '{}'".format(name, reason)
@ -41,6 +44,11 @@ class Responses:
return True
def parse(self, name, source, response):
users = self.bot.memories["users"]
if name not in users:
return False
response = response.lower()
check = {
"name": name,
"source": source,

View File

@ -15,7 +15,7 @@ coroutines = [
"state": {
"alias": "bbj",
"source": "http://localhost:7099/api",
"channels": ["#bots"] #team
"channels": ["#team"]
}
},
{
@ -25,7 +25,7 @@ coroutines = [
"alias": "title",
"source": "https://tilde.news/newest.rss",
"use": "title",
"channels": ["#bots"] # "#meta", "#tildeverse"
"channels": ["#meta", "#tildeverse"]
}
},
{
@ -35,7 +35,7 @@ coroutines = [
"alias": "links-comments",
"source": "https://tilde.news/comments.rss",
"use": "summary",
"channels": ["#bots"] #tildeverse
"channels": ["#tildeverse"]
}
}
]

View File

@ -49,7 +49,7 @@ class RSS:
self.memory["known"].append(guid)
use = sub(r"(<\/?[^>]+>)|\\n", "", item.findtext([self.use], ""))
use = sub(r"(<\/?[^>]+>)|\\n", "", item.findtext(self.use, ""))
user = item.findtext("author", "").split("@")[0]
post = "{} (posted by {}) <{}>".format(use, user, guid)
response = "[{}] {}".format(self.alias, post)