Fixed RSS formatting, fixed bug in oofscore, fixed bug in core for leaving channels
This commit is contained in:
parent
675a8099b5
commit
7acbceca8e
|
@ -52,7 +52,7 @@ actions = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "response",
|
"type": "response",
|
||||||
"pattern": "/.^[^!]*hm+/",
|
"pattern": "/^[^!]*hm+/",
|
||||||
"callback": score_word("hmm", "hm+")
|
"callback": score_word("hmm", "hm+")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ actions = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "response",
|
"type": "response",
|
||||||
"pattern": "/^[^!]*o+f/",
|
"pattern": "/^[^!]*oo+f/",
|
||||||
"callback": score_word("oof", "o+f")
|
"callback": score_word("oof", "o+f")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -85,4 +85,4 @@ actions = [
|
||||||
"pattern": "/!whois \S+/",
|
"pattern": "/!whois \S+/",
|
||||||
"callback": whois
|
"callback": whois
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -89,7 +89,8 @@ class Bot:
|
||||||
def leave(self, chan):
|
def leave(self, chan):
|
||||||
message = "PART {} :Bye-bye!"
|
message = "PART {} :Bye-bye!"
|
||||||
self.send(message, chan)
|
self.send(message, chan)
|
||||||
self.places.remove(chan)
|
if chan in self.places:
|
||||||
|
self.places.remove(chan)
|
||||||
|
|
||||||
def ping(self, message):
|
def ping(self, message):
|
||||||
response = message.split("PING :")[1]
|
response = message.split("PING :")[1]
|
||||||
|
|
|
@ -40,15 +40,5 @@ coroutines = [
|
||||||
"use": "description",
|
"use": "description",
|
||||||
"channels": ["#tildeverse"]
|
"channels": ["#tildeverse"]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"worker": use(RSS),
|
|
||||||
"interval": 16,
|
|
||||||
"state": {
|
|
||||||
"alias": "cosmic",
|
|
||||||
"source": "https://cosmic.voyage/rss.xml",
|
|
||||||
"use": "title",
|
|
||||||
"channels": ["#cosmic"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -51,8 +51,14 @@ class RSS:
|
||||||
|
|
||||||
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)
|
metadata = "(posted by {}) <{}>".format(user, guid)
|
||||||
response = "[{}] {}".format(self.alias, post)
|
header = "[{}] {}".format(self.alias, use)
|
||||||
|
splitter = " "
|
||||||
|
max_size = 450 - len(splitter)
|
||||||
|
if len(header) + len(metadata) >= max_size:
|
||||||
|
header_size = max_size - len(metadata)
|
||||||
|
header = header[:header_size]
|
||||||
|
response = "{}{}{}".format(header, splitter, metadata)
|
||||||
for channel in self.channels:
|
for channel in self.channels:
|
||||||
self.bot.send_message(channel, response)
|
self.bot.send_message(channel, response)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue