Best Python code snippet using localstack_python
main1.py
Source:main1.py
...15session = requests.Session()161718# вÑвод ÑообÑений в беÑедÑ19def send_messages(id1, text, attr=''):20 """2122 :param id1: id Ñого, Ñ ÐºÐµÐ¼ Ð¼Ñ Ð¾Ð±ÑаемÑÑ23 :param text: ÑообÑÐµÐ½Ð¸Ñ Ð´Ð»Ñ Ð²Ñвода24 :param attr: пÑовеÑка на пÑÑÑоÑÑ ÑообÑениÑ25 :return:26 """27 random_id = random.randint(0, 1000000)28 if not attr:29 vk.method('messages.send', {'chat_id': id1, 'message': text, 'random_id': random_id})30 else:31 vk.method('messages.send',32 {'chat_id': id1, 'message': text, 'random_id': random_id, 'attachment': attr})333435# Ð¸Ð¼Ñ Ð¿Ð¾ ид36def _get_user_name(self, user_id):37 """3839 :param user_id: id полÑзоваÑелÑ40 :return: ÐÐ¼Ñ Ð¿Ð¾Ð»ÑзоваÑелÑ41 """42 request = requests.get("https://vk.com/id" + str(user_id))43 bs = bs4.BeautifulSoup(request.text, "html.parser")44 user_name = str(bs.findAll("title")[0])45 print(user_name.split(' | ')[0])46 return user_name.split()[0][7:]474849# ÑколÑко дней до...50def t_d(chat_id, msg):51 """5253 :param chat_id: id ÑаÑа в коÑоÑом обÑабаÑÑваеÑÑÑ Ð·Ð°Ð¿ÑÐ¾Ñ Ð¿Ð¾Ð»ÑзоваÑелÑ54 :param msg: ÑообÑение полÑзоваÑелÑ55 в оÑÐ²ÐµÑ Ð²Ð¾Ð·Ð²ÑаÑаем ÑообÑение по запÑоÑÑ56 """57 try:58 date1 = msg.lower()[16:]59 if date1.lower() == "леÑа" or date1.lower() == "леÑо":60 if 5 < datetime.date.today().month < 9:61 send_messages(chat_id, f'Уже леÑо!')62 date1 = datetime.date.today()63 elif datetime.date.today().month >= 9:64 d = datetime.date.today().year + 165 date1 = datetime.date(d, 6, 1)66 else:67 d = datetime.date.today().year68 date1 = datetime.date(d, 6, 1)69 elif date1.lower() == "веÑнÑ" or date1.lower() == "веÑна":70 if 2 < datetime.date.today().month < 6:71 send_messages(chat_id, f'Уже веÑна!')72 date1 = datetime.date.today()73 elif datetime.date.today().month >= 6:74 d = datetime.date.today().year + 175 date1 = datetime.date(d, 3, 1)76 else:77 d = datetime.date.today().year78 date1 = datetime.date(d, 3, 1)79 elif date1.lower() == "оÑенÑ" or date1.lower() == "оÑени":80 if 8 < datetime.date.today().month < 12:81 send_messages(chat_id, f'Уже оÑенÑ!')82 date1 = datetime.date.today()83 elif datetime.date.today().month >= 12:84 d = datetime.date.today().year + 185 date1 = datetime.date(d, 9, 1)86 else:87 d = datetime.date.today().year88 date1 = datetime.date(d, 9, 1)89 elif date1.lower() == "зима" or date1.lower() == "зимÑ":90 if (datetime.date.today().month < 3) or (datetime.date.today().month == 12):91 send_messages(chat_id, f'Уже зима!')92 date1 = datetime.date.today()93 else:94 d = datetime.date.today().year95 date1 = datetime.date(d, 12, 1)96 elif date1.lower() == "нового года" or date1.lower() == "новÑй год":97 d = datetime.date.today().year + 198 date1 = datetime.date(d, 1, 1)99 else:100 inp = date1.split('.')101 if len(inp) != 3:102 send_messages(chat_id, f'Такой даÑÑ Ð½ÐµÑ! ÐожеÑ, Ð²Ñ Ð¸Ð¼ÐµÐ»Ð¸ в Ð²Ð¸Ð´Ñ ÑегоднÑ?')103 date1 = datetime.date.today()104 else:105 date1 = [int(x) for x in inp]106 date1 = datetime.date(date1[-1], date1[-2], date1[0])107 cur_date = datetime.date.today()108 delta = date1 - cur_date109 send_messages(chat_id, f'ÐÑÑалоÑÑ Ð²Ñего {delta.days} дней. ÐÑо не Ñак Ñж и много')110 except ValueError:111 send_messages(chat_id, f'ÐеподÑ
одÑÑий ÑоÑÐ¼Ð°Ñ - введиÑе даÑÑ Ð² ÑоÑмаÑе дд.мм.гггг')112 except TypeError:113 send_messages(chat_id, f'ÐÑибка Ñипа ÑообÑениÑ')114115116# Ñлова наобоÑоÑ117def abirgame(chat_id, word):118 """119120 :param chat_id: id ÑаÑа в коÑоÑом обÑабаÑÑваеÑÑÑ Ð·Ð°Ð¿ÑÐ¾Ñ Ð¿Ð¾Ð»ÑзоваÑелÑ121 :param word: Ñлово коÑоÑое нам напиÑал полÑзоваÑелÑ122 :return: ÐÑпÑавлÑем ÑообÑение либо вÑÑ
одим из ÑÑнкÑии123 """124 if word.lower() == 'Ñенок':125 return False126 else:127 send_messages(chat_id, word[::-1])128 return True129130131# веÑÑ Ð½Ðµ веÑÑ132def true_or_false(chat_id, inpu, number):133 """134135 :param chat_id: id ÑаÑа в коÑоÑом обÑабаÑÑваеÑÑÑ Ð·Ð°Ð¿ÑÐ¾Ñ Ð¿Ð¾Ð»ÑзоваÑелÑ136 :param inpu: ÑообÑение на вÑ
од Ð¾Ñ Ð¿Ð¾Ð»ÑзоваÑелÑ137 :param number: Ð½Ð¾Ð¼ÐµÑ ÐºÐ°ÑÑоÑки вопÑоÑа138139 """140 if inpu == 'Ñ
ваÑиÑ':141 send_messages(chat_id, 'Ðадно, болÑÑе не бÑдÑ')142 return False, 0143 if ans_dict[inpu] == ANS_CARDS[number]:144 send_messages(chat_id, 'Ð¢Ñ Ð¿Ñав')145 else:146 send_messages(chat_id, 'Ðе Ñгадал')147 number = random.randint(0, len(QUE_CARDS) - 1)148 send_messages(chat_id, QUE_CARDS[number])149 return True, number150151152# виÑелиÑа153def gallows(chat_id, char):154 """155156 :param chat_id: id ÑаÑа в коÑоÑом обÑабаÑÑваеÑÑÑ Ð·Ð°Ð¿ÑÐ¾Ñ Ð¿Ð¾Ð»ÑзоваÑелÑ157 :param char: ÑообÑение полÑзоваÑелÑ158 :return: возвÑаÑаем Ñо, Ñгадал ли полÑзоваÑÐµÐ»Ñ Ð±ÑквÑ159 """160 global nu, visTrue, current_ans, wrong161 char = char.lower()162 if char == 'ÑдаÑÑÑ':163 send_messages(chat_id, 'ÐÑ Ð·Ð°ÐºÐ¾Ð½Ñили игÑÑ')164 visTrue = False165 send_messages(chat_id, f'ÐÑавилÑнÑй оÑвеÑ: {ANWERS[nu+1]}')166 return visTrue167 if not char.isalpha() or len(char) != 1:168 send_messages(chat_id, 'ÐведиÑе Ð¾Ð´Ð½Ñ Ð±ÑквÑ, пожалÑйÑÑа')169 send_messages(chat_id, ' '.join(current_ans))170 send_messages(chat_id, 'ÐведиÑе бÑквÑ: ')171 return visTrue172 if char in current_ans:173 send_messages(chat_id, 'ÐÑа бÑква Ñже оÑкÑÑÑа')174 send_messages(chat_id, ' '.join(current_ans))175 send_messages(chat_id, 'ÐведиÑе бÑквÑ: ')176 return visTrue177 elif char in ANWERS[nu].lower() and char not in current_ans:178 for flag in range(len(ANWERS[nu])):179 if char == ANWERS[nu][flag].lower():180 current_ans[flag] = char181 if '-' not in current_ans:182 send_messages(chat_id, f'ÐÑавилÑнÑй оÑвеÑ: {ANWERS[nu]}')183 send_messages(chat_id, 'ÐоздÑавлÑем, Ð²Ñ Ð²ÑигÑали!')184 visTrue = False185 return visTrue186 send_messages(chat_id, ' '.join(current_ans))187 send_messages(chat_id, 'ÐведиÑе бÑквÑ: ')188 return visTrue189 else:190 wrong += 1191 if wrong == MAX_WRONG:192 send_messages(chat_id, 'ÐопÑÑок не оÑÑалоÑÑ. ÐÑ Ð¿ÑоигÑали =((')193 send_messages(chat_id, f'ÐÑавилÑнÑй оÑвеÑ: {ANWERS[nu]}')194 visTrue = False195 return visTrue196 send_messages(chat_id, f'Такой бÑÐºÐ²Ñ Ð½ÐµÑ. ÐÑÑалоÑÑ Ð¿Ð¾Ð¿ÑÑок: {MAX_WRONG - wrong}')197 send_messages(chat_id, ' '.join(current_ans))198 send_messages(chat_id, 'ÐведиÑе бÑквÑ: ')199 return visTrue200201202203def know_nomber(chat_id, text, num, knownumTrue, raund):204 """205206 :param chat_id: id ÑаÑа в коÑоÑом обÑабаÑÑваеÑÑÑ Ð·Ð°Ð¿ÑÐ¾Ñ Ð¿Ð¾Ð»ÑзоваÑелÑ207 :param text: ÑообÑение полÑзваÑелÑ208 :param num: загаданное ÑиÑло209 :param knownumTrue: паÑамеÑÑ Ð² ÑпиÑке210 :param raund: Ð½Ð¾Ð¼ÐµÑ ÑаÑнда211212 """213 if text == num:214 send_messages(chat_id, 'ÐеÑно! Ðобеда =)) С ' + str(raund) + " попÑÑки")215 return [False, 1]216 elif text < num:217 send_messages(chat_id, 'ÐолÑÑе беÑи!')218 raund += 1219 else:220 send_messages(chat_id, 'Ðного! УменÑÑай')221 raund += 1222 return knownumTrue, raund223224225# кÑеÑÑики-нолики226def krestnul(p, desk, c):227 """228229 :param p: Ð½Ð¾Ð¼ÐµÑ Ð¸Ð³Ñока230 :param desk: ÑиÑÑнок наÑей доÑки231 :param c: кооÑдинаÑÑ ÐºÐ»ÐµÑки коÑоÑÑÑ Ð´Ð°Ð» полÑзоваÑелÑ232 :return:233 """234 c = [int(c[0]), int(c[2])]235 if desk[c[0]][c[1]] == '.':236 if p == 1:237 desk[c[0]][c[1]] = '+'238 else:239 desk[c[0]][c[1]] = '0'240 send_messages(chat_id, f' '.join(desk[0]))241 send_messages(chat_id, f' '.join(desk[1]))242 send_messages(chat_id, f' '.join(desk[2]))243 send_messages(chat_id, f' '.join(desk[3]))244 else:245 send_messages(chat_id, 'ÐевеÑнÑй Ñ
од')246 return 0, desk247 if desk[1][1] == desk[1][2] == desk[1][3] == '+' or desk[2][1] == desk[2][2] == desk[2][248 3] == '+' or \249 desk[3][1] == desk[3][2] == desk[3][3] == '+' or desk[1][1] == desk[2][1] == desk[3][250 1] == '+' or \251 desk[1][2] == desk[2][2] == desk[3][2] == '+' or desk[1][3] == desk[2][3] == desk[3][252 3] == '+' or \253 desk[1][1] == desk[2][2] == desk[3][3] == '+' or desk[3][1] == desk[2][2] == desk[1][254 3] == '+':255 send_messages(chat_id, "Ðобеда 1-ого игÑока!")256 return 0, desk257 if desk[1][1] == desk[1][2] == desk[1][3] == '0' or desk[2][1] == desk[2][2] == desk[2][258 3] == '0' or \259 desk[3][1] == desk[3][2] == desk[3][3] == '0' or desk[1][1] == desk[2][1] == desk[3][260 1] == '0' or \261 desk[1][2] == desk[2][2] == desk[3][2] == '0' or desk[1][3] == desk[2][3] == desk[3][262 3] == '0' or \263 desk[1][1] == desk[2][2] == desk[3][3] == '0' or desk[3][1] == desk[2][2] == desk[1][264 3] == '0':265 send_messages(chat_id, "Ðобеда 2-ого игÑока!")266 return 0, desk267 return 1, desk268269270271272273def share(a):274 """275 ФÑнкÑÐ¸Ñ Ð´Ð»Ñ Ð¾Ð±ÑабоÑки ÑиÑла Ð´Ð»Ñ Ð¸Ð³ÑÑ276 :param a: ÑиÑло Ð´Ð»Ñ Ð¾Ð±ÑабоÑки277 :return: ÑпиÑок ÑиÑел278 """279 return a // 1000, (a // 100) % 10, (a % 100) // 10, a % 10280281282def cow(a, b):283 """284 Ðадаем колнки по Ð·Ð°Ð´Ð°Ð½Ð½Ð¾Ð¼Ñ Ð¸Ð½ÑеÑвалÑ285 :param a: ÑазмеÑ286 :param b: ÑазмеÑ287288 """289 bull, ccow = 0, 0290 for i in range(4):291 if a[i] == b[i]:292 bull += 1293 elif a[i] in b:294 ccow += 1295 return bull, ccow296297298def change(res):299 global s300 q = list(map(lambda x: [cow(share(x), res), x],301 [i for i in range(1234, 9876) if len(set(str(i))) == 4]))302 w = []303 for elem in q:304 if history(elem[1], s):305 w.append(elem)306 return min(w, key=lambda x: (x[0][0], x[0][1]))[1]307308# иÑÑоÑÐ¸Ñ Ð·Ð°Ð¿ÑоÑа309def history(x, ss):310 for elem in ss:311 if cow(share(x), elem[0]) != elem[1]:312 return False313 return True314315316# игÑовÑе пеÑеменнÑе317knownumTrue, gorodaTrue, abirTrue, visTrue, tofTrue, bikTrue = False, False, False, False, False, False318raund, raund1, bol, i, number = 0, 0, 0, -1, 0319word_b = ''320cur_towns = []321s = []322desk = [[' ', '1', '2', '3'], ['1', '.', '.', '.'], ['2', '.', '.', '.'], ['3', '.', '.', '.']]323MAX_WRONG = 5324global num325326# запÑÐ¾Ñ Ð² вк327def bik(chat_id, res, normal):328 pass329330if __name__ == '':331 longpoll = VkBotLongPoll(vk, 204241258)332 for event in longpoll.listen():333 print(event.type)334 if event.type == VkBotEventType.MESSAGE_NEW: #ÐÑли поÑвилоÑÑ ÑообÑение - обÑабаÑÑваем335 if event.from_chat:336 chat_id = event.chat_id337 msg = event.object.message["text"].lower()338 bad_words = ['ленÑ', "ÑоÑка", "ÑнÑние", "ÑкÑка"] # Ñлова-маÑкеÑÑ339 if msg == "пÑивеÑ":340 send_messages(chat_id,341 'ÐÑивеÑ, ÑÑÐ¾Ð±Ñ ÑзнаÑÑ, ÑÑо Ñ Ð¼Ð¾Ð³Ñ Ð¿Ð¸Ñи "командÑ"')342 try:343 dey = event.message.action['type']344 invite_id = event.message.action['member_id']345 except:346 dey = ''347 invite_id = -100348 if dey == 'chat_invite_user':349 send_messages(chat_id, f"ÐÑивеÑик, {_get_user_name(chat_id, str(invite_id))}!")350 elif set(msg.split()) & set(bad_words):351 send_messages(chat_id, 'Ðез плоÑ
иÑ
Ñлов!')352 elif msg.lower() == "кÑо Ñ":353 name = _get_user_name(chat_id, str(invite_id))354 if name == '404':355 send_messages(chat_id, f"Я не знаÑ")356 else:357 send_messages(chat_id, f"Ð¢Ñ - {name}, не забÑвай об ÑÑом!")358 elif msg.lower().count("кÑо ид - "):359 invite_id = msg.lower().split('кÑо ид - ')[1]360 name = _get_user_name(chat_id, str(invite_id))361 if name == '404':362 send_messages(chat_id, f"Я не знаÑ")363 else:364 send_messages(chat_id, f"ÐÑо - {name}, не забÑвай об ÑÑом!")365 elif msg.lower().count("добавиÑÑ ÑÑазÑ"):366 frazes.append(msg[15:])367 send_messages(chat_id, f'ÐаÑа ÑÑаза - {msg[15:]} - добавлена в ÑпиÑок')368 elif msg.lower() == "командÑ":369 attachments = []370 image = random.choice(image_urls)371 photo = upload.photo_messages(photos=image)[0]372 attachments.append('photo{}_{}'.format(photo['owner_id'], photo['id']))373 send_messages(chat_id, koms, ','.join(attachments))374 elif msg.lower() == "гÑÑÑÑно":375 send_messages(chat_id, f'ÐÑе бÑÐ´ÐµÑ Ð¾ÐºÐµÐ¹!)')376 elif msg.lower() == "веÑело":377 send_messages(chat_id, f'Так деÑжаÑÑ! ÐолнÑй впеÑед! Ðа абоÑда-аж!')378 elif msg.lower() == "кÑеÑÑики-нолики":379 bol = 1380 i = 1381 send_messages(chat_id,382 f"Ðа наÑнеÑÑÑ Ð±Ð¸Ñва! Ход игÑока {1}. ÐведиÑе кооÑдинаÑÑ Ñипа: 1 3")383 elif bol and len(msg.lower()) == 3 and set(msg.lower()) & set('123'):384 p = i % 2385 if p == 0:386 p = 2387 c = msg388 bol, desk = krestnul(p, desk, c)389 i += 1390 if bol:391 if p == 2:392 b = 1393 else:394 b = 2395 send_messages(chat_id, f"Ход игÑока {b}")396 elif msg.lower() == "Ñгадайка":397 send_messages(chat_id, f'Угадайка. ÐоеÑ
али. ÐÐедиÑе ÑиÑло')398 num = random.randint(1, 100)399 raund = 1400 knownumTrue = True401 elif knownumTrue and msg.isdigit():402 knownumTrue, raund = know_nomber(chat_id, int(msg), num, knownumTrue, raund)403 elif msg.lower() == "пÑогноз": # пÑевдопÑедÑказание днÑ404 attachments = []405 image = random.choice(im_uri)406 photo = upload.photo_messages(photos=image)[0]407 attachments.append('photo{}_{}'.format(photo['owner_id'], photo['id']))408 send_messages(chat_id, random.choice(futurum), ','.join(attachments))409 elif msg.lower() == 'каÑÑинка':410 attachments = []411 image = random.choice(f1)412 photo = upload.photo_messages(photos=image)[0]413 attachments.append('photo{}_{}'.format(photo['owner_id'], photo['id']))414 send_messages(chat_id, '', ','.join(attachments))415 elif msg.lower() == 'ÑÑаза':416 send_messages(chat_id, random.choice(frazes))417 elif msg.lower() == "гоÑода":418 raund1 = 1419 gorodaTrue = True420 send_messages(chat_id, f'ÐоÑода. ÐаÑинайÑе Ñ "ÐоÑод ..."')421 cur_towns = []422 word_b = ''423 elif msg.lower() == "виÑелиÑа":424 visTrue = True425 send_messages(chat_id,426 f'ÐаÑа задаÑа оÑвеÑиÑÑ Ð½Ð° загадкÑ, ÑгадÑÐ²Ð°Ñ Ñлово по одной бÑкве. '427 f'ÐÑли Ñ
оÑиÑе законÑиÑÑ Ð¸Ð³ÑÑ Ð´Ð¾ÑÑоÑно, напиÑиÑе "ÑдаÑÑÑ". '428 f'У Ð²Ð°Ñ ÐµÑÑÑ Ð¿Ñаво на {MAX_WRONG} оÑибок.'429 f' ЧÑÐ¾Ð±Ñ Ð²Ð²ÐµÑÑи бÑÐºÐ²Ñ Ð½Ð°ÑниÑе ÑообÑение Ñ "ÐÑква "')430 nu = random.randint(0, len(QUESTIONS) - 1)431 send_messages(chat_id, QUESTIONS[nu])432 wrong = 0433 current_ans = ['-'] * len(ANWERS[nu])434 send_messages(chat_id, ' '.join(current_ans))435 send_messages(chat_id, 'ÐведиÑе бÑквÑ: ')436 elif msg.lower().count("бÑква ") and visTrue:437 letter = msg.lower().split("бÑква ")[1]438 visTrue = gallows(chat_id, letter)439 elif msg.lower().count("ÑдаÑÑÑ") and visTrue:440 visTrue = gallows(chat_id, 'ÑдаÑÑÑ')441 elif msg.lower().count("ÑколÑко дней до"):442 t_d(chat_id, msg)443 elif msg.lower() == "абÑÑвалг":444 abirTrue = True445 send_messages(chat_id, f'ТоÑобоан Ð°Ð²Ð¾Ð»Ñ Ð¼ÐµÑип\n *Ñенок - конеÑ')446 elif abirTrue:447 abirTrue = abirgame(chat_id, msg)448 elif msg.lower() == "веÑÑ Ð½Ðµ веÑÑ":449 tofTrue = True450 send_messages(chat_id, f'ÐаÑа задаÑа ÑгадаÑÑ, пÑавдиво ли данное вÑÑказÑвание')451 number = random.randint(0, len(QUE_CARDS) - 1)452 send_messages(chat_id, QUE_CARDS[number])453 elif tofTrue and ((msg.lower() in ans_dict) or msg.lower() == 'Ñ
ваÑиÑ'):454 tofTrue, number = true_or_false(chat_id, msg.lower(), number)455 elif msg.lower().count('поÑÑиÑай'):456 msg = msg.split('поÑÑиÑай ')[1]457 try:458 st = eval(msg)459 send_messages(chat_id, f'ÐÑдеÑ: {st}')460 except ZeroDivisionError:461 send_messages(chat_id, f'ÐÑибка! ÐелиÑÑ Ð½Ð° 0 нелÑзÑ!')462 except TypeError:463 send_messages(chat_id, f'Я ÑÐµÐ±Ñ Ð½Ðµ понимаÑ. Ðе забÑÐ´Ñ Ð¿Ñо ввод ÑиÑÑами')464 except SyntaxError:465 send_messages(chat_id, f'Я ÑÐµÐ±Ñ Ð½Ðµ понимаÑ. Ðе забÑÐ´Ñ Ð¿Ñо ввод ÑиÑÑами')466 except NameError:467 send_messages(chat_id, f'Я ÑÐµÐ±Ñ Ð½Ðµ понимаÑ. Ðе забÑÐ´Ñ Ð¿Ñо ввод ÑиÑÑами')468 elif msg.lower() == "бÑки и коÑовÑ":469 bikTrue = True470 send_messages(chat_id,471 f'Ð¦ÐµÐ»Ñ Ð¸Ð³ÑÑ - ÑгадаÑÑ ÑиÑло из 4 ÑазнÑÑ
ÑиÑÑ Ð¿Ð¾ колиÑеÑÑÐ²Ñ Ð¾Ð±ÑиÑ
ÑиÑÑ(коÑов) '472 f'и ÑиÑÑ, коÑоÑÑе наÑ
одÑÑÑÑ Ð½Ð° нÑжном меÑÑе(бÑков)')473 send_messages(chat_id, 'ÐведиÑе ÑеÑÑÑеÑ
знаÑное ÑиÑло:')474 elif bikTrue and (len(msg) == 4 and msg.isdigit()):475 res = share(int(msg)) # пÑинимаем полÑзоваÑелÑÑкое ÑиÑло476 normal = share(change(res)) # новÑй задÑманнÑй коÑÑеж
...
main.py
Source:main.py
1import os2import time3from datetime import date 4from datetime import datetime5def send_messages(phone_number, message):6 os.system('osascript send.scpt {} "{}"'.format(phone_number, message))7def get_today():8 return datetime.today().strftime('%A')9def get_hour():10 return datetime.now().strftime("%H:%M")11now = get_hour()12day = get_today()13phone = "8185578599"14send_messages(phone, "Hello, This is TheGamingCube's Bot")15send_messages(phone, "This will be a bot that notifies you when you have class!")16while True:17 time.sleep(60)18 now = get_hour()19 day = get_today()20 print("now =", now)21 print("today = ", day)22 if day == "Monday" or day == "Wednesday":23 if now == "7:55":24 send_messages(phone, "You Have Class in 5 Minutes, get ready to join")25 elif now == "7:59":26 send_messages(phone, "One Minute Till AP Bio!")27 send_messages(phone, "https://us02web.zoom.us/j/96182082414?pwd=eUc0SXpsS09ndmhhVWRzamtIcmRrQT09")28 elif now == "9:25":29 send_messages(phone, "You Have Class in 5 Minutes, get ready to join")30 elif now == "9:29":31 send_messages(phone, "One Minute Till AP Calculus BC!")32 send_messages(phone, "https://zoom.us/j/95979662195?pwd=d1RKRDFsaUR2ZUFMemowRVNGUTcxUT09")33 elif now == "10:55":34 send_messages(phone, "You Have Class in 5 Minutes, get ready to join")35 elif now == "10:59":36 send_messages(phone, "One Minute Till Digital Photo!")37 send_messages(phone, "https://meet.google.com/lookup/edzlr67rei?authuser=1&hs=179")38 elif now == "14:30":39 send_messages(phone,"Attendence Forms")40 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=1")41 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=2")42 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=3")43 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=7")44 if day == "Monday" and now == "14:59":45 send_messages(phone, "One Minute Till XC Google Meets")46 send_messages(phone, "https://meet.google.com/lookup/edzlr67rei?authuser=1&hs=179")47 elif day == "Tuesday" or day == "Thursday":48 if now == "7:55":49 send_messages(phone, "You Have Class in 5 Minutes, get ready to join")50 elif now == "7:59":51 send_messages(phone, "One Minute Till AP Gov!")52 send_messages(phone, "https://us02web.zoom.us/j/89078038414?pwd=M3VUc1pyU1FWQlI5QS9ySGFjZ0pjQT09")53 elif now == "9:25":54 send_messages(phone, "You Have Class in 5 Minutes, get ready to join")55 elif now == "9:29":56 send_messages(phone, "One Minute Till ERWC(English)!")57 send_messages(phone, "https://us02web.zoom.us/j/82412177292?pwd=UXpIWmVhKzJmb296WWt2eG1WV2s5Zz09")58 elif now == "14:30":59 send_messages(phone,"Attendence Forms")60 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=4")61 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=5")62 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=7")63 64 elif day == "Friday":65 if now == "8:55":66 send_messages(phone, "If you would like to attend office hours find the class and time on here")67 send_messages(phone, "https://docs.google.com/document/d/1zWlMsYWrB7KzbIUgNECZ-hWzDCvJBQuUCTP6wPg1fKU/edit")68 send_messages(phone, "AP Bio - https://us02web.zoom.us/j/96343587368?pwd=WGpTTXFNSDRLcVVkSTN4bzRZQ1FmZz09")69 send_messages(phone, "AP Calc BC - https://zoom.us/j/95904304937?pwd=dGEwUnVrU1FObFZiUzBKV0lENTd1dz09")70 send_messages(phone, "Digital Photo does not have friday office hours")71 send_messages(phone, "AP Gov - https://us02web.zoom.us/j/84029102432?pwd=WGE5TE9jRndjRENQMWRQTndLYWJXUT09")72 send_messages(phone, "ERWC - https://us02web.zoom.us/j/82383516265?pwd=OFE4Z0ljZnltZDR1NkVuWGxlMWlUdz09")73 if now == "15:00":74 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=1")75 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=2")76 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=3")77 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=4")78 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=5")79 send_messages(phone,"https://docs.google.com/forms/d/e/1FAIpQLScs81tH_SGnpBdnfYlYtWQqSzB-zYz15Azon99WuRO_kKyk7Q/viewform?entry.1828733646=Cody&entry.761704581=Lin&entry.1242183593=7")80 elif day == "Saturday":81 if now == "12:25":82 send_messages(phone, "You Have Class in 5 Minutes, get ready to join")83 elif now == "12:29":84 send_messages(phone, "One Minute Till CS 130 - Introduction to Algorithms (GCC)")85 send_messages(phone, "https://cccconfer.zoom.us/j/93266916651?pwd=enN3em1xMzRjbTlFRWpXMEN1aVRnZz09")86 87 else:88 if now == "12:00":...
test_send_messages.py
Source:test_send_messages.py
...22 """23 Verify that send_messages returns nothing if no messages are passed.24 """25 sendgrid_backend = SendGridBackend(api_key="test")26 self.assertEqual(sendgrid_backend.send_messages(emails=[]), None)27 def test_sending(self):28 """Verify that send_messages returns sent count if message is sent."""29 sendgrid_backend = SendGridBackend(api_key="test")30 sendgrid_backend.sg.client = Mock()31 self.assertEqual(32 sendgrid_backend.send_messages(emails=[self.test_message]), 133 )34 def test_failing_silently(self):35 """Verify that send_messages can fail silently."""36 sendgrid_backend = SendGridBackend(api_key="test")37 sendgrid_backend.sg.client = Mock()38 http_error = HTTPError(url="", code=999, msg=None, hdrs=None, fp=None)39 sendgrid_backend.sg.client.mail.send.post = Mock(40 side_effect=http_error41 )42 self.assertFalse(sendgrid_backend.fail_silently)43 with self.assertRaises(HTTPError):44 sendgrid_backend.send_messages(emails=[self.test_message])45 sendgrid_backend.fail_silently = True46 self.assertEqual(47 sendgrid_backend.send_messages(emails=[self.test_message]), 0...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!