diff --git a/actions/__init__.py b/actions/__init__.py index 0f2a090..85ca192 100644 --- a/actions/__init__.py +++ b/actions/__init__.py @@ -52,7 +52,7 @@ actions = [ }, { "type": "response", - "pattern": "/.^[^!]*hm+/", + "pattern": "/^[^!]*hm+/", "callback": score_word("hmm", "hm+") }, { @@ -67,7 +67,7 @@ actions = [ }, { "type": "response", - "pattern": "/^[^!]*o+f/", + "pattern": "/^[^!]*oo+f/", "callback": score_word("oof", "o+f") }, { @@ -85,4 +85,4 @@ actions = [ "pattern": "/!whois \S+/", "callback": whois } -] \ No newline at end of file +] diff --git a/bot/core.py b/bot/core.py index b07092f..cf98f97 100644 --- a/bot/core.py +++ b/bot/core.py @@ -89,7 +89,8 @@ class Bot: def leave(self, chan): message = "PART {} :Bye-bye!" self.send(message, chan) - self.places.remove(chan) + if chan in self.places: + self.places.remove(chan) def ping(self, message): response = message.split("PING :")[1] diff --git a/coroutines/__init__.py b/coroutines/__init__.py index 67fd216..9c27359 100644 --- a/coroutines/__init__.py +++ b/coroutines/__init__.py @@ -40,15 +40,5 @@ coroutines = [ "use": "description", "channels": ["#tildeverse"] } - }, - { - "worker": use(RSS), - "interval": 16, - "state": { - "alias": "cosmic", - "source": "https://cosmic.voyage/rss.xml", - "use": "title", - "channels": ["#cosmic"] - } } ] \ No newline at end of file diff --git a/coroutines/rss.py b/coroutines/rss.py index 6e3a2e3..c6f443a 100644 --- a/coroutines/rss.py +++ b/coroutines/rss.py @@ -51,8 +51,14 @@ class RSS: 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) + metadata = "(posted by {}) <{}>".format(user, guid) + 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: self.bot.send_message(channel, response)