def on_enter_4(self, event): reply_token = event.reply_token send_image( reply_token, "https://raw.githubusercontent.com/fancyshon/TOC_Project/master/img/%E9%AB%94%E8%82%B2.png" ) self.back(event)
def on_enter_5(self, event): reply_token = event.reply_token send_image( reply_token, "https://raw.githubusercontent.com/fancyshon/TOC_Project/master/img/%E9%A2%A8%E7%B4%80.png" ) self.back(event)
def on_enter_3(self, event): reply_token = event.reply_token send_image( reply_token, "https://raw.githubusercontent.com/fancyshon/TOC_Project/master/img/%E5%89%AF%E7%8F%AD%E9%95%B7.png" ) self.back(event)
def on_enter_2(self, event): reply_token = event.reply_token send_image( reply_token, "https://raw.githubusercontent.com/fancyshon/TOC_Project/master/img/%E5%AD%B8%E8%97%9D.png" ) self.back(event)
async def send_motives(self, ctx): """Distributes motive cards""" if not ctx.game.motives: asyncio.create_task(ctx.send("Need to shuffle motives first!")) return for name in gamedata.CHARACTERS: channel = ctx.text_channels[f"{name}-clues"] motive = ctx.game.motives[name] utils.send_image(channel, utils.MOTIVE_DIR / f"Motive {motive}.png", ctx)
def on_enter_hit(self, event): global highest global lowest global guess print("I'm entering hit") reply_token = event.reply_token send_image(reply_token) username=display_name(event) push_message(event,username+" 引爆了炸彈!!") highest=100 lowest=1 guess=0 push_message(event,"再次輸入menu選取要的功能吧><") self.go_back()
async def send_motives(self, ctx): """Distributes motive cards""" if not ctx.game.motives: asyncio.create_task(ctx.send(loc["send_motives"]["NeedToShuffle"])) return for name in gamedata.CHARACTERS: channel = ctx.text_channels[LOCALIZATION_DATA["channels"]["clues"] [name]] motive = ctx.game.motives[name] utils.send_image( channel, utils.get_image(dirs.MOTIVE_DIR, f"Motive-{motive}"), ctx)
def process_command(sender, message): """Background task to send an email with Flask-Mail.""" intent = parser.get_intent(message.lower()) args = parser.get_entities(message, intent) print intent print args if intent == 'time': send_message(sender, time.strftime('%I:%M %p')) elif intent == 'expense' and 'interval' in args: result = p.process(intent, args) if args['exp_type'] == 'all': send_image(sender, 'plot.png', result, True) else: send_message(sender, result, False) elif intent == 'echo' and 'message' in args: speak(args['message']) elif intent == 'snap' or intent == 'stream': url_link = get_link(intent) send_message(sender, url_link, False) elif intent == 'email' and 'action' in args: result = p.process(intent, args) print result send_message(sender, result) elif intent == 'security' and 'action' in args: result = p.process(intent, args) send_message(sender, result) elif intent == 'stock' and 'company' in args: result = p.process(intent, args) send_message(sender, result) elif intent == 'weather' and 'city' in args: result = p.process(intent, args) send_message(sender, result) elif intent == 'switch' and 'action' in args: result = p.process(intent, args) send_message(sender, result) elif intent == 'route' and 'destination' in args: result = p.process(intent, args) send_message(sender, result, not args['directions']) elif intent == 'wiki' and 'query' in args: result = p.process(intent, args) send_message(sender, result) else: result = 'Sorry, I didnt get that.' send_message(sender, result)
async def alice(self, ctx, choice: int = 0): """ Sends a specified Alice poster, or a random one if no argument is passed This will also update the Alice value in the game data. """ if choice < 0 or choice > 10: asyncio.create_task( ctx.send(LOCALIZATION_DATA["errors"]["UserInputError"])) return if not choice: choice = random.randint(1, 10) ctx.game.alice = choice alice = utils.get_image(dirs.POSTER_DIR, f"Alice-Briarwood-{ctx.game.alice}") utils.send_image(LOCALIZATION_DATA["channels"]["resources"], alice, ctx)
def on_enter_state1(self, event): print("I'm entering state1") reply_token = event.reply_token temp = random.randint(1, 5) if (temp == 1): send_image(reply_token, "https://i.imgur.com/Crfclsh.jpg") elif (temp == 2): send_image(reply_token, "https://i.imgur.com/RPNUZHq.jpg") elif (temp == 3): send_image(reply_token, "https://i.imgur.com/xdxCt6b.jpg") else: send_image(reply_token, "https://i.imgur.com/TmZEeKT.jpg") self.go_back()
def send_clue(self, ctx, time: int): # Sends clue based on picked_clues value # Find character who the clue has been assigned to for name in ctx.game.clue_assignments: if time in ctx.game.clue_assignments[name]: character = name break else: raise ValueError("Missing clue") # Send clue card channel = utils.get_text_channels( ctx.game.guild)[LOCALIZATION_DATA["channels"]["clues"][character]] choice = ctx.game.picked_clues[time] path = utils.get_image(dirs.CLUE_DIR / str(time), f"{time}-{choice}") utils.send_image(channel, path) # Send suspect/location card to player's clues channel suspect = self.draw_suspect(ctx, time) path = filepaths.MASTER_PATHS[suspect] utils.send_image(channel, path) # Send suspect/location card to respective drawn cards channel if suspect in gamedata.SUSPECTS: channel = LOCALIZATION_DATA["channels"]["cards"]["suspects-drawn"] elif suspect in gamedata.LOCATIONS: channel = LOCALIZATION_DATA["channels"]["cards"]["locations-drawn"] else: channel = LOCALIZATION_DATA["channels"]["bot-channel"] channel = utils.get_text_channels(ctx.game.guild)[channel] # Confirmed culprit/location if time <= 30: if suspect in gamedata.SUSPECTS: asyncio.create_task( channel.send(LOCALIZATION_DATA["messages"]["Culprit"])) elif suspect in gamedata.LOCATIONS: asyncio.create_task( channel.send( LOCALIZATION_DATA["messages"]["AliceLocation"])) else: print("Something has gone very very wrong.") asyncio.create_task( channel.send(LOCALIZATION_DATA["errors"]["UnknownError"])) utils.send_image(channel, path) # Update next_clue unless at end if ctx.game.next_clue != 20: for i in range(len(gamedata.CLUE_TIMES)): if gamedata.CLUE_TIMES[i] == ctx.game.next_clue: ctx.game.next_clue = gamedata.CLUE_TIMES[i + 1] break
def on_enter_state2(self, event): print("I'm entering state2") reply_token = event.reply_token temp = random.randint(1, 4) if (temp == 1): send_image(reply_token, "https://i.imgur.com/7YanpSm.jpg") elif (temp == 2): send_image(reply_token, "https://i.imgur.com/zP0yDYr.jpg") else: send_image(reply_token, "https://i.imgur.com/Xhk0Ztk.jpg") self.go_back()
def send_clue(self, ctx, time: int): # Sends clue based on picked_clues value # Find character who the clue has been assigned to for name in ctx.game.clue_assignments: if time in ctx.game.clue_assignments[name]: character = name break else: raise ValueError("Missing clue") # Send clue card channel = utils.get_text_channels(ctx.game.guild)[f"{character}-clues"] choice = ctx.game.picked_clues[time] path = utils.CLUE_DIR / str(time) / f"{time}-{choice}.png" utils.send_image(channel, path) # Send suspect/location card to player's clues channel suspect = self.draw_suspect(ctx, time) path = utils.MASTER_PATHS[suspect] utils.send_image(channel, path) # Send suspect/location card to respective drawn cards channel if suspect in gamedata.SUSPECTS: channel = "suspects-drawn" elif suspect in gamedata.LOCATIONS: channel = "locations-drawn" else: channel = "bot-channel" channel = utils.get_text_channels(ctx.game.guild)[channel] # Confirmed culprit/location if time <= 30: if suspect in gamedata.SUSPECTS: asyncio.create_task(channel.send("CULPRIT:")) elif suspect in gamedata.LOCATIONS: asyncio.create_task(channel.send("ALICE'S LOCATION:")) else: asyncio.create_task( channel.send("Something has gone very very wrong.")) utils.send_image(channel, path) # Update next_clue unless at end if ctx.game.next_clue != 20: for i in range(len(gamedata.CLUE_TIMES)): if gamedata.CLUE_TIMES[i] == ctx.game.next_clue: ctx.game.next_clue = gamedata.CLUE_TIMES[i + 1] break
def on_enter_show_fsm(self, event): print("I'm entering state3") reply_token = event.reply_token # send_text_message(reply_token, "Trigger state3") send_image(reply_token, 'https://i.imgur.com/yRq0e1U.png') self.go_back()
async def init(self, ctx): """Initial setup before character selection""" if ctx.game.start_time: await ctx.send("Game has already begun!") return elif ctx.game.init and ctx.game.automatic: # Disallow unless manual mode is enabled await ctx.send("Initialization already run!") return await ctx.send("Initializing game") # Introduction images utils.send_image("player-resources", utils.MASTER_PATHS["guide"], ctx) utils.send_image("player-resources", utils.MASTER_PATHS["character_sheet"], ctx) utils.send_image("player-resources", utils.MASTER_PATHS["intro"], ctx) ctx.game.alice = random.randint(1, 10) alice = utils.POSTER_DIR / ("Alice Briarwood " + str(ctx.game.alice) + utils.IMAGE_EXT) utils.send_image("player-resources", alice, ctx) # Send characters, suspects, and locations to appropriate channels utils.send_folder("character-cards", utils.CHARACTER_IMAGE_DIR, ctx) utils.send_folder("suspect-cards", utils.SUSPECT_IMAGE_DIR, ctx) utils.send_folder("location-cards", utils.LOCATION_IMAGE_DIR, ctx) # Instructions for Charlie Barnes channel = ctx.text_channels["charlie-clues"] prompts = "\n".join([ "Read introduction", "Introduce Alice from poster", "Introduce/pick characters", "Explain character cards", "Explain motive cards", "Character backgrounds", "Relationships", "Suspects and locations", "!setup_clues", "Explain clue cards", "Explain searching", "Game guide", "Voicemails", "Stream timer (https://www.youtube.com/watch?v=ysOOFIOAy7A)", "!start", "Send first message", ]) prompts = utils.codeblock(prompts) background = " ".join([ "CHARLIE BARNES moved away from Silent Falls", "with their mom at the end of the last school year", "after their parents divorced. They just arrived in", "town to stay with their dad for winter break, and", "hope to see Alice and the others while they’re here.", "A few days ago, Alice stopped responding.", "They haven’t heard from her since.", ]) background = utils.codeblock(background) asyncio.create_task(channel.send(prompts)) asyncio.create_task(channel.send(background)) # Character and motive cards in clues channels for name in gamedata.CHARACTERS: channel = ctx.text_channels[f"{name}-clues"] utils.send_image(channel, utils.MASTER_PATHS[name], ctx) # Shuffle and send motives if in automatic mode if ctx.game.automatic: await self.bot.cogs["Manual"].shuffle_motives(ctx) asyncio.create_task(self.bot.cogs["Manual"].send_motives(ctx)) ctx.game.init = True
def webhook_handler(): signature = request.headers["X-Line-Signature"] # get request body as text body = request.get_data(as_text=True) app.logger.info(f"Request body: {body}") # parse webhook body try: events = parser.parse(body, signature) except InvalidSignatureError: abort(400) # if event is MessageEvent and message is TextMessage, then echo text for event in events: if not isinstance(event, MessageEvent): continue if not isinstance(event.message, TextMessage): continue if not isinstance(event.message.text, str): continue print(f"\nFSM STATE: {machine.state}") print(f"REQUEST BODY: \n{body}") response = True if event.message.text.lower() == "show fsm": send_image(event.reply_token, "https://tranquil-brook-42124.herokuapp.com/show-fsm") else: if event.message.text == "重新開始": machine.state = "begin" send_text_message( event.reply_token, "已重新開始\n\n我們發現學藝股長的大秘密那天,是這樣開始的...\n\n--------------\n輸入 人物介紹 查看角色\n輸入 故事開始 開始這段故事\n你的所有選擇將會影響故事的走向" ) if event.message.text.lower() == "start": machine.start(event) elif event.message.text == "人物介紹": machine.introduction(event) if machine.state == "intro": if event.message.text == "1": machine.go1(event) elif event.message.text == "2": machine.go2(event) elif event.message.text == "3": machine.go3(event) elif event.message.text == "4": machine.go4(event) elif event.message.text == "5": machine.go5(event) elif event.message.text == "離開": machine.fin_intro(event) elif machine.state == "begin": if event.message.text == "故事開始": machine.go_to_part1(event) elif machine.state == "part1": if event.message.text == '1': machine.go_to_part2_1(event) elif event.message.text == '2': machine.go_to_part2_2(event) elif machine.state == "part2_1": if event.message.text == '1': machine.truth(event) elif event.message.text == '2': machine.dare(event) elif machine.state == "part3_1": if event.message.text == "不想回答": machine.ans(event) elif machine.state == "answer": if event.message.text == "哇,好尷尬...": machine.os(event) elif event.message.text == "哈哈哈,我就知道": machine.laugh_at(event) elif event.message.text == "阻止大家": machine.stop(event) elif machine.state == "bully": if event.message.text == "沒我的事": machine.nothing(event) elif event.message.text == "他們太誇張了,我會幫你想辦法處理的": machine.concern(event) elif machine.state == "part3_2": if event.message.text == "親臉頰就好了吧?": machine.kiss(event) elif event.message.text == "喇機!喇機!(眾人在鼓譟)": machine.french_kiss(event) elif event.message.text == "阻止大家": machine.stop(event) elif machine.state == "cheek_kiss": if event.message.text == "他沒說甚麼,開玩笑應該沒關係吧": machine.kidding(event) elif event.message.text == "別欺負他,住手拉!": machine.concern(event) elif machine.state == "french_kiss": if event.message.text == "跟他說:回來上課吧,我會幫你跟大家說清楚": machine.concern(event) elif event.message.text == "沒我的事": machine.nothing(event) elif machine.state == "part2_2": if event.message.text == '1': machine.truth(event) elif event.message.text == '2': machine.dare(event) elif machine.state == "part4_1": if event.message.text == "其實我也有點好奇": machine.tell_secret(event) elif machine.state == "secret": if event.message.text == "果然呢": machine.murmur(event) elif event.message.text == '早就覺得她很奇怪': machine.laugh(event) elif event.message.text == "阻止班長": machine.stop(event) elif machine.state == "part4_2": if event.message.text == "打開書包": machine.open(event) elif machine.state == "open_bag": if event.message.text == "哇!超讚的八卦": machine.gossip(event) elif event.message.text == "學藝應該很崩潰吧": machine.be_sympathy(event) elif machine.state == "suicide_ending" or machine.state == "bad_ending": if event.message.text == "繼續": machine.end(event) if response == False: send_text_message(event.reply_token, "Not Entering any State") print(machine.state) return "OK"
#!/usr/bin/env python3 import cv2 import numpy as np import sys import os #from src.utils import image_to_bytes from config import HOST, PORT1, IMG_DTYPE from utils import load_image, send_image machine_name = 'CLIENT' path = 'test.jpg' # show what we sended image = load_image(path) image = send_image(image, HOST, PORT1, True, machine_name, IMG_DTYPE) image = image.astype('uint8') while (1): cv2.imshow(machine_name, image) k = cv2.waitKey(50) if k == 27: # Esc key to stop break
def on_enter_state2(self, event): reply_token = event.reply_token url = "https://i.imgur.com/tbWMm4D.jpg" send_image(reply_token, url) self.go_back()
def send_chart(interval): plaid = PlaidHandler() result = plaid.get_summary(interval) send_image(MESSENGER_ID['arun'], 'plot.png', result, True)
def on_enter_fsm(self, event): print("I'm entering fsm") reply_token = event.reply_token send_image(reply_token, "https://i.imgur.com/1FZk9ww.png") self.go_back()
async def clue_check(self, ctx): """Runs clue check every 5 minutes and calls send_clue()""" minutes_remaining = 90 check_interval = 5 while minutes_remaining > 0: # Normal cards if ctx.game.automatic: if minutes_remaining in gamedata.CLUE_TIMES and minutes_remaining <= ctx.game.next_clue: self.bot.cogs["Manual"].send_clue(ctx, minutes_remaining) if minutes_remaining == 30 and ctx.game.picked_clues[ minutes_remaining] == 1: flip = random.choice(["Heads", "Tails"]) for character in ctx.game.clue_assignments: if 30 in ctx.game.clue_assignments[character]: channel = character + "-clues" break channel = ctx.text_channels[channel] asyncio.create_task(channel.send(flip)) # 10 min card elif minutes_remaining == 10: channel = ctx.game.ten_char + "-clues" ending = random.choice( list(i for i in ctx.game.endings if ctx.game.endings[i])) clue = utils.CLUE_DIR / "10" / f"10-{ending}.png" utils.send_image(channel, clue, ctx) if ending != 3: ctx.game.three_flip = True else: ctx.game.second_culprit = True check_interval = 1 # Ending 3 elif minutes_remaining == 8 and ctx.game.second_culprit: culprit = ctx.game.suspects_drawn[30] remaining_suspects = [] for suspect in gamedata.SUSPECTS: if suspect != culprit: remaining_suspects.append(suspect) second = random.choice(remaining_suspects) # Send to clues channel path = utils.SUSPECT_IMAGE_DIR / ( gamedata.SUSPECTS[second] + ".png") channel = ctx.game.ten_char + "-clues" utils.send_image(channel, path, ctx) # Send to suspects-drawn channel channel = ctx.text_channels["suspects-drawn"] asyncio.create_task(channel.send("SECOND CULPRIT:")) utils.send_image(channel, path, ctx) # Endings 1 and 2 elif minutes_remaining == 3 and ctx.game.three_flip: flip = random.choice(["Heads", "Tails"]) channel = ctx.game.ten_char + "-clues" channel = ctx.text_channels[channel] asyncio.create_task(channel.send(flip)) await asyncio.sleep(check_interval * 60 / ctx.game.game_speed) # Manual else: # Wait for the buffer before sending the reminder await asyncio.sleep(gamedata.REMINDER_BUFFER * 60 / ctx.game.game_speed) # Check if player hasn't drawn the clue yet if minutes_remaining <= ctx.game.next_clue: # Find character who owns the clue for name in ctx.game.clue_assignments: if minutes_remaining in ctx.game.clue_assignments[ name]: character = name break channel = ctx.text_channels[character + "-clues"] await channel.send( f"Reminder: You have the {ctx.game.next_clue} minute clue card" ) # Wait out the rest of the interval await asyncio.sleep( (check_interval - gamedata.REMINDER_BUFFER) * 60 / ctx.game.game_speed) minutes_remaining -= check_interval