README
Read the room is a skill for Abbot to realize that the world is much larger than it is. If Abbot isn’t aware of the fact that it’s a BIG news day, maybe tell Abbot to read the room. This will cause Abbot to go on the New York Times website, pick one of the headlines, and apologize for missing out on the important news. Abbot doesn’t do anything to differentiate the news, so it might treat good news as bad news!
Usage
This package has no usage examples
Code
def handle_starttag(self, tag, attrs):
real_headline = attrs and len(attrs) and len(attrs[0]) and attrs[0][0] == ‘size’
if tag == ‘h3’ and not (self.get_headline) and real_headline:
if not self.headline:
self.get_headline = True
self.attrs = attrs
elif random.randint(1, 10) == 2:
self.get_headline = True
def handle_data(self, data):
if self.get_headline:
self.headline = data
self.get_headline = False
r = requests.get(‘https://www.nytimes.com/’)
q = NewsParser()
q.feed(r.text)
z = [‘I\’m sorry. ‘, ‘My apologies. ‘, ‘Oh. ‘, ‘Wow my bad. ‘, “Shit. “, “Damn 😕. “]
y = [‘You all must be reeling from the fact that ‘, ‘It must be a big day because ‘, ‘I wasn\’t really thinking about ‘, ‘I only just realized that ‘, ‘I hadn\’t heard that ‘]
x = [‘exciting’, ‘traumatizing’, ‘awful’, ‘threatening’, ‘drastic’, ‘world-changing’]
w = [‘I\’ll try to do better next time.’, ‘I promise it won\’t happen again.’, ”, ”, ‘I\’ll use my head before I speak in the future.’, ‘I\’m gonna sign off and take a quick walk.’, ”, ”]
response = f”{random.choice(z)}{random.choice(y)}{q.headline}. That must be very {random.choice(x)} news! {random.choice(w)}”
bot.reply(response)