def send_messages(users): i = 0 for u in users: user = User(u) if user.get_time() == time_zone( ) and user.get_last_day() != strftime('%x'): # message limitation # # this is necessary because telegram api # limits us to 30 messages per second # in addition, we have other threads that # also need to respond to user requests # so I set a limit of 10 messages per second # from this thread if i == 5: i = 0 sleep(1) user.set_last_day() if user.check_data() == 'data error': # data error i += 1 print('problem_data') print(u) try_send(u, Template.data_error()) elif user.check_data() == 'no await': # no message waiting print('no message waiting') print(u) elif user.check_data() == 'good': # all rigtht i += 1 w = Words(user) words = w.get_words() print('ok') try_send(u, words) else: sleep(5 * 60)
while not max_mishits.isdecimal() or int(max_mishits) < 1 or int( max_mishits) > 11: max_mishits = input("Podaj poprawną liczbę! ") win_result, max_mishits = int(win_result), int(max_mishits) words = Words() max_word_len = input( "jak długie mogą być słowa? (minimalnie: {} maksymalnie: {}) ".format( words.min_len, words.max_len)) while not max_word_len.isdecimal() or int( max_word_len) < words.min_len or int(max_word_len) > words.max_len: max_word_len = input("Podaj poprawną liczbę! ") max_word_len = int(max_word_len) min_word_len = input( "jak krótnie mogą być słowa? (minimalnie: {} maksymalnie: {}) ".format( words.min_len, max_word_len)) while not min_word_len.isdecimal() or int( min_word_len) < words.min_len or int(min_word_len) > max_word_len: min_word_len = input("Podaj poprawną liczbę! ") min_word_len = int(min_word_len) print(min_word_len, max_word_len) game = Game(win_result, max_mishits, words.get_words(min_word_len, max_word_len))