forked from aewens/babili-bot
Bug fixes to handle spam / capital letters
This commit is contained in:
parent
97cdb98542
commit
d90d1a9567
|
@ -1,5 +1,6 @@
|
||||||
# App-specific
|
# App-specific
|
||||||
settings.json
|
settings.json
|
||||||
|
settings.demo.json
|
||||||
data/*.json
|
data/*.json
|
||||||
irc/
|
irc/
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,10 @@ def botlist(self, name, source, response):
|
||||||
"!rollcall",
|
"!rollcall",
|
||||||
"!summon",
|
"!summon",
|
||||||
"!banish",
|
"!banish",
|
||||||
"!pardon"
|
"!pardon",
|
||||||
|
"!hmmscore",
|
||||||
|
"!hmmscoreboard",
|
||||||
|
"!whois"
|
||||||
])
|
])
|
||||||
args = (botnick, author, email, about, commands)
|
args = (botnick, author, email, about, commands)
|
||||||
message = "{} | {} <{}> | {} | {}".format(*args)
|
message = "{} | {} <{}> | {} | {}".format(*args)
|
||||||
|
|
11
app.py
11
app.py
|
@ -9,10 +9,15 @@ from coroutines import coroutines
|
||||||
debug = False
|
debug = False
|
||||||
kingme = [] if debug else ["#chaos"]
|
kingme = [] if debug else ["#chaos"]
|
||||||
channels = ["#bots", "#insane"]
|
channels = ["#bots", "#insane"]
|
||||||
# if not debug:
|
if not debug:
|
||||||
# channels.extend([])
|
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)
|
responses = Responses(bot)
|
||||||
tasks = Tasks(bot)
|
tasks = Tasks(bot)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ class Responses:
|
||||||
def allowed(self, name, source):
|
def allowed(self, name, source):
|
||||||
memories = self.bot.memories
|
memories = self.bot.memories
|
||||||
users = memories["users"]
|
users = memories["users"]
|
||||||
|
if name not in users:
|
||||||
|
return False
|
||||||
|
|
||||||
if name in users and "blacklist" in users[name]:
|
if name in users and "blacklist" in users[name]:
|
||||||
reason = users[name]["blacklist"]["reason"]
|
reason = users[name]["blacklist"]["reason"]
|
||||||
message = "is ignoring {} for reason '{}'".format(name, reason)
|
message = "is ignoring {} for reason '{}'".format(name, reason)
|
||||||
|
@ -41,6 +44,11 @@ class Responses:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def parse(self, name, source, response):
|
def parse(self, name, source, response):
|
||||||
|
users = self.bot.memories["users"]
|
||||||
|
if name not in users:
|
||||||
|
return False
|
||||||
|
|
||||||
|
response = response.lower()
|
||||||
check = {
|
check = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"source": source,
|
"source": source,
|
||||||
|
|
|
@ -15,7 +15,7 @@ coroutines = [
|
||||||
"state": {
|
"state": {
|
||||||
"alias": "bbj",
|
"alias": "bbj",
|
||||||
"source": "http://localhost:7099/api",
|
"source": "http://localhost:7099/api",
|
||||||
"channels": ["#bots"] #team
|
"channels": ["#team"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ coroutines = [
|
||||||
"alias": "title",
|
"alias": "title",
|
||||||
"source": "https://tilde.news/newest.rss",
|
"source": "https://tilde.news/newest.rss",
|
||||||
"use": "title",
|
"use": "title",
|
||||||
"channels": ["#bots"] # "#meta", "#tildeverse"
|
"channels": ["#meta", "#tildeverse"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ coroutines = [
|
||||||
"alias": "links-comments",
|
"alias": "links-comments",
|
||||||
"source": "https://tilde.news/comments.rss",
|
"source": "https://tilde.news/comments.rss",
|
||||||
"use": "summary",
|
"use": "summary",
|
||||||
"channels": ["#bots"] #tildeverse
|
"channels": ["#tildeverse"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -49,7 +49,7 @@ class RSS:
|
||||||
|
|
||||||
self.memory["known"].append(guid)
|
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]
|
user = item.findtext("author", "").split("@")[0]
|
||||||
post = "{} (posted by {}) <{}>".format(use, user, guid)
|
post = "{} (posted by {}) <{}>".format(use, user, guid)
|
||||||
response = "[{}] {}".format(self.alias, post)
|
response = "[{}] {}".format(self.alias, post)
|
||||||
|
|
Loading…
Reference in New Issue