diff --git a/apreciabot.py b/apreciabot.py index ba0d5a1..bdf9de0 100644 --- a/apreciabot.py +++ b/apreciabot.py @@ -42,8 +42,9 @@ for i in range(0, max_notifications - 5): n = notifications[i] if str(n['id']) not in last_ids: # Mentions data are HTML paragraphs so we delete everything between <> to clean it up - rawContent = BeautifulSoup(n['status']['content'], "html.parser").get_text() - content = re.sub(no_unicode_spaces_pattern, "", rawContent).split(" ") + rawContent = n['status']['content'].replace("
", " ") + text = BeautifulSoup(rawContent, "html.parser").get_text() + content = re.sub(no_unicode_spaces_pattern, "", text).split(" ") try: first_mention = content[0] target = "@" + content[1] diff --git a/common.py b/common.py index 6ac5ef2..34da97e 100644 --- a/common.py +++ b/common.py @@ -45,8 +45,13 @@ def get_new_notifications(api, bot_name, types=None): notifications = api.notifications(types=types) new_notifications = [] new_notifications_ids = [] + max_notification = 0 + if len(notifications) < 2: + max_notification = len(notifications) + else: + max_notification = len(notifications) // 2 - for i in range(0, len(notifications) // 2): + for i in range(0, max_notification): if str(notifications[i]['id']) not in last_notifications: new_notifications.append(notifications[i])