def get(self): if not database.get_setting(Setting.ENABLED): return response = Response() if prob(0.2): response.add_msg_or_voice(random_of(good_night_phrases)) elif prob(0.05): response.add_msg(get_9gag_post_url()) if prob(0.5): response.add_msg_or_voice(laughter) main.send_to_group(response)
def execute(message): chat = message['chat'] chat_id = chat['id'] text = message['text'] if text.startswith('/test'): text = text.lstrip('/test') voice_prob = 0.2 resp = Response(mood=Mood.NEUTRAL, voice_probability=voice_prob) resp.add_msg_or_voice(text) main.send_to_group(resp) else: main.send_response(str(chat_id), responder.reply_to(message))
def get(self): if not database.get_setting(Setting.ENABLED): return database.check_nicknames() response = Response() bdays = has_birthday(database.get_user_list()) if bdays: for bday_user in bdays: first_name = bday_user.first_name if bday_user.nickname: first_name = bday_user.nickname response.add_msg(first_name + u' ' + random_of(birthday_wishes)) if prob(0.2): response.add_msg_or_voice(random_of(greetings_morning)) if prob(0.08): w = apis.openweathermap.Weather() if prob(0.5): response.add_msg(random_of(address) + u'! ' + describe_wheather(w)) temperature = w.getTemperature() desc = w.getDescription() if temperature < 5 and prob(0.2): response.add_msg(u'Zieht euch ne Jacke an, es werden ' + str(temperature) + u' Grad') elif temperature > 20 and prob(0.2): response.add_msg(u'Auf zum Strabi! Es werden' + str(temperature) + u'Grad') elif desc == 'Snow' and prob(0.2): response.add_msg(u'Fahrt vorsichtig ' + random_of(address) + u'. Es gibt heute schnee.') elif 7 < temperature < 20 and prob(0.01): response.add_msg_or_voice(u'Wetter wird heut Mittel..') if prob(0.1): user = database.get_random_user() if user.nickname: return else: user.set_nickname(random_line(Textfile.NAMES).rstrip('\n')) response.add_msg(user.first_name + u' ' + random_of(new_nickname) + u' ' + user.nickname) main.send_to_group(response)
def get(self): if not database.get_setting(Setting.ENABLED): return response = Response() if prob(0.1): # bad mood database.set_setting(Setting.MOOD, Mood.BAD) if prob(0.4): response.add_msg_or_voice(random_of(badMoodMessage)) elif prob(0.1): database.set_setting(Setting.MOOD, Mood.GOOD) response.add_msg_or_voice(u'Der heutige Tag ist wirklich ' + random_line(Textfile.COMPLIMENTS)) else: database.set_setting(Setting.MOOD, Mood.NEUTRAL) lastSender = database.get_last_sender(main.GROUP_CHAT_ID) if lastSender: if lastSender.date_time < datetime.datetime.now() - datetime.timedelta(days=1): if prob(0.2): response.add_msg_or_voice(u'Was los hier? Seit ' + str((datetime.datetime.now() - lastSender.date_time).hour) + u' stunden keine nachricht?') else: response.add_msg_or_voice(random_of(quietTooLongMessages)) main.send_to_group(response)