def broadcast_image(): users = mongo.db.USER_CMS bc = mongo.db.BROADCAST check_user_activation_key = users.find_one( {'user_activation_key': request.form['user_activation_key']}) if bool(check_user_activation_key): url = request.form['url'] dt = request.form['timestamp'] # 'Jun 1 2005 1:33PM' datetime_object = datetime.strptime(dt, '%Y-%m-%d %H:%M') # for user in USER.find(): # page.send(user['id_user'], Attachment.Image(url)) page.send("1370330196399177", Attachment.Image(url)) page.send("1437973719614452", Attachment.Image(url)) # luu broadcast new_bc = { 'type': 'image', 'content': url, 'timestamp': datetime_object } bc.insert_one(new_bc) return 'True' else: return 'False'
def broadcast_video_broadcast(): users = mongo.db.USER_CMS bc = mongo.db.BROADCAST # check_user_activation_key = users.find_one( # {'user_activation_key': request.form['user_activation_key']}) username = users.find_one({'username': request.form['username']}) password = users.find_one({'password': request.form['password']}) if bool(password): if bool(username): url = request.form['url'] dt = request.form['timestamp'] # 'Jun 1 2005 1:33PM' datetime_object = datetime.strptime(dt, '%Y-%m-%d %H:%M') # for user in USER.find(): # page.send(user['id_user'], Attachment.Video(url)) page.send("1370330196399177", Attachment.Video(url)) page.send("1437973719614452", Attachment.Video(url)) # luu broadcast # new_bc = { # 'type': 'video', # 'content': url, # 'timestamp': datetime_object # } # bc.insert_one(new_bc) return 'True' else: return 'False' else: return 'False'
def broadcast_video(url): users = mongo.db.USER_CMS check_user_activation_key = users.find_one( {'user_activation_key': request.form['user_activation_key']}) if bool(check_user_activation_key): # for user in USER.find(): # page.send(user['id_user'], Attachment.Video(url)) page.send("1370330196399177", Attachment.Video(request.form['url'])) page.send("1437973719614452", Attachment.Video(request.form['url'])) return 'True' else: return 'False'
def image_fs(sender_id, sizeFont, hlv, first_name, last_name, x_Text, y_Text): userName = last_name + ' ' + first_name font = ImageFont.truetype("./font.ttf", sizeFont) imageFile = "image/" + hlv + ".jpg" im = Image.open(imageFile) draw = ImageDraw.Draw(im) draw.text((x_Text, y_Text), userName, (0, 0, 0), font=font) draw = ImageDraw.Draw(im) name_fansigned = "/home/hoangphuc/Bot_Pictures/fs_" + hlv + \ sender_id + ".jpg" im.save(name_fansigned) hlv_dict = { 'sb': 'Soobin', 'vct': 'Vũ Cát Tường', 'ht': 'Hương Tràm', 'tc': 'Tiên Cookie' } text1 = hlv_dict.get( hlv) + " đang viết lời chúc dành cho bạn. " + userName + " chờ xíu nhé 😉" page.send(sender_id, text1) page.send(sender_id, Attachment.Image( "http://210.211.109.211/weqbfyretnccbsaf/fs_" + hlv + sender_id + ".jpg")) text2 = 'Phía trên là hình fansign của ' + \ hlv_dict.get( hlv) + ' dành riêng cho bạn. Hãy chia sẻ món quà này ngay kèm hashtag #gionghatvietnhifansign nha bạn ơi' buttons = [ Template.ButtonPostBack("Fansign khác", "fansign"), Template.ButtonPostBack("Home", "home") ] page.send(sender_id, Template.Buttons(text2, buttons)) print('da gui hinh fansign')
def minigame2_handle_result(message, sender_id): message = message.lower() huong_tram = ["đỉnh", "xinh", "bánh bèo"] vu_cat_tuong = ["chất", "cá tính", "phũ"] soobin = ["đẹp trai", "ế", "cao"] tien_cookie = ["hit", "cute", "nhọ"] if message in huong_tram: game2_hlv_url = "http://210.211.109.211/weqbfyretnccbsaf/game2_huongtram.jpg" page.send(sender_id, Attachment.Image(game2_hlv_url)) text = "Chính xác!!!!!!!!" buttons = [ Template.ButtonPostBack("Đoán thêm lần nữa 😻", "minigame2_menu"), Template.ButtonPostBack("Home", "home") ] page.send(sender_id, Template.Buttons(text, buttons)) elif message in vu_cat_tuong: game2_hlv_url = "http://210.211.109.211/weqbfyretnccbsaf/game2_vucattuong.jpg" page.send(sender_id, Attachment.Image(game2_hlv_url)) text = "Chính xác!!!!!!!!" buttons = [ Template.ButtonPostBack("Đoán thêm lần nữa 😻", "minigame2_menu"), Template.ButtonPostBack("Home", "home") ] page.send(sender_id, Template.Buttons(text, buttons)) elif message in soobin: game2_hlv_url = "http://210.211.109.211/weqbfyretnccbsaf/game2_soobin.jpg" page.send(sender_id, Attachment.Image(game2_hlv_url)) text = "Chính xác!!!!!!!!" buttons = [ Template.ButtonPostBack("Đoán thêm lần nữa 😻", "minigame2_menu"), Template.ButtonPostBack("Home", "home") ] page.send(sender_id, Template.Buttons(text, buttons)) elif message in tien_cookie: game2_hlv_url = "http://210.211.109.211/weqbfyretnccbsaf/game2_tiencookie.jpg" page.send(sender_id, Attachment.Image(game2_hlv_url)) text = "Chính xác!!!!!!!!" buttons = [ Template.ButtonPostBack("Đoán thêm lần nữa 😻", "minigame2_menu"), Template.ButtonPostBack("Home", "home") ] page.send(sender_id, Template.Buttons(text, buttons))
def minigame1_handle_quick_reply(sender_id, quick_reply_payload): hinh_hlv = "http://210.211.109.211/weqbfyretnccbsaf/" + \ danh_sach_hinh_anh_HLV[quick_reply_payload] page.send(sender_id, Attachment.Image(hinh_hlv)) space = " " a = "Bạn đã dự đoán dự đoán thành công đội có thí sinh đạt được vị trí cao nhất của chương trình. Dự đoán của bạn đang dành cho team của" seq = (a, quick_reply_payload) text = space.join(seq) buttons = [ Template.ButtonPostBack("Bình chọn lại", "minigame1_vote"), Template.ButtonPostBack("Home", "home") ] page.send(sender_id, Template.Buttons(text, buttons)) USER.update_one( {'id_user': sender_id}, {'$set': {'HLV_da_binh_chon': quick_reply_payload}} ) return
def broadcast_image(sender_id, image_name): page.send(sender_id, Attachment.Image(url + image_name))
def broadcast_video(sender_id, video_name): page.send(sender_id, Attachment.Video(url + video_name))
def send_file(recipient): page.send(recipient, Attachment.File( CONFIG['SERVER_URL'] + "/assets/test.txt"))
def send_video(recipient): page.send(recipient, Attachment.Video( CONFIG['SERVER_URL'] + "/assets/allofus480.mov"))
def send_audio(recipient): page.send(recipient, Attachment.Audio( CONFIG['SERVER_URL'] + "/assets/sample.mp3"))
def send_gif(recipient): page.send(recipient, Attachment.Image( CONFIG['SERVER_URL'] + "/assets/instagram_logo.gif"))
def send_image(recipient): page.send(recipient, Attachment.Image( CONFIG['SERVER_URL'] + "/assets/rift.png"))