def main_menu_get_option(self, inp): inp = inp.lower() if inp == '1': self.interp = self.character_login self.interp() elif inp == '2': self.sock.dispatch(helpsys.get_help('motd', server=True)) self.sock.dispatch('') self.main_menu() elif inp == 'l': self.sock.dispatch( 'Thanks for playing. We hope to see you again soon.') comm.wiznet(f"{self.sock.host} disconnecting from Akrios.") self.sock.handle_close() self.clear() del self elif inp == 'd': self.sock.dispatch('Sorry to see you go. Come again soon!') comm.wiznet(f"Character {self.name} deleted by {self.sock.host}") os.remove(f"{world.playerDir}/{self.name}.json") self.sock.handle_close() self.clear() del self else: self.main_menu()
def get_char_password(self, inp): inp = inp.encode('utf-8') md5_object = hashlib.md5(inp) if md5_object.hexdigest() != self.password: self.sock.dispatch("\n\rI'm sorry, that isn't the correct password. Good bye.") self.sock.handle_close() else: self.sock.do_echo_telnet() for person in player.playerlist: if person.name == self.name: self.sock.dispatch('\n\rYour character seems to be logged in already. Reconnecting you.') del(person.sock.owner) person.sock.close() del(person.sock) testsock = self.sock self.clear() person.sock = testsock person.sock.owner = person person.sock.promptable = True person.write = person.sock.dispatch comm.wiznet('{0} reconnecting from link death.'.format(person.name)) return comm.wiznet("{0} logged into main menu.".format(self.name.capitalize())) self.sock.dispatch('') self.sock.dispatch('Welcome back {0}'.format(self.name.capitalize())) self.sock.dispatch('You last logged in on {0}'.format(self.lasttime)) self.sock.dispatch('From this host: {0}'.format(self.lasthost)) self.sock.dispatch('') self.lasttime = time.ctime() self.lasthost = self.sock.host.strip() self.main_menu() self.interp = self.main_menu_get_option
def getKnown(self, idnum=None): """ Used to return a string for display. You can assign a string alias for another players ID number so you see that string instead of the default if you don't "know" them. Keyword arguments: idnum -- Integer representing another player Return value: A blank string if they don't have an alias set, or a string representing the alias for the other player. Example: None Additional notes: None """ if id == None: comm.wiznet("You must provide an ID to lookup. getKnown:livingthing.py") return elif idnum not in self.knownpeople.keys(): return '' else: return self.knownpeople[idnum]
def event_frontend_receive_message(event_): fe_ = event_.owner fe_.handle_read() if fe_.inbound_frame_buffer: # Assign rcvd_msg to a FEReceivedMessage instance. rcvd_msg = fe_.receive_message() ret_value = rcvd_msg.parse_frame() log.info(f'Received : {rcvd_msg}') if ret_value: # if rcvd_msg.message['event'] == "games/connect": # game = ret_value.capitalize() # message = f"\n\r{{GGrapevine Status Update: {game} connected to network{{x" # is_status_msg = True if rcvd_msg.message['event'] == "player/input": uuid_, addr, port, message = ret_value comm.wiznet(f"FE: {uuid_}@{addr}:{port} sent: {message}") if 'event' in rcvd_msg.message and rcvd_msg.message['event'] == 'restart': comm.wiznet("Received restart event from Front End.") restart_fuzz = 15 + rcvd_msg.restart_downtime fe_.fesocket_disconnect() nextevent = Event() nextevent.owner = fe_ nextevent.ownertype = "frontend" nextevent.eventtype = "frontend restart" nextevent.func = event_frontend_restart nextevent.passes = restart_fuzz * PULSE_PER_SECOND nextevent.totalpasses = nextevent.passes fe_.events.add(nextevent)
def move(self, tospot=None, fromspot=None): """ Takes two arguments, tospot and fromspot, removes the thing from the fromspot and adds them to the the tospot. Keyword arguments: tospot -- A location to move to fromspot -- A location to move from Return value: None Example: None Additional notes: None """ if tospot == None: comm.wiznet("Received None value in move:livingthing.py") return else: if fromspot != None: fromspot.contents.remove(self) tospot.contents.append(self) self.location = tospot
def get_roll_stats(self, inp): inp = inp.lower() if inp == 'y' or inp == 'yes': self.sock.dispatch(helpsys.get_help('motd', server=True)) self.sock.dispatch('') newplayer = player.Player() newplayer.filename = f"{world.playerDir}/{self.name}.json" testsock = self.sock newplayer.name = self.name newplayer.password = self.password newplayer.lasttime = time.ctime() newplayer.lasthost = self.sock.host newplayer.race = self.newchar['race'] newplayer.aid = str(uuid.uuid4()) newplayer.equipped = { k: None for k in newplayer.race.wearlocations } newplayer.gender = self.newchar['gender'] newplayer.discipline = self.newchar['discipline'] newplayer.position = 'standing' newplayer.maximum_stat = self.newstats newplayer.current_stat = self.newstats self.clear() newplayer.sock = testsock newplayer.sock.owner = newplayer newplayer.prompt = '{pAkriosMUD{g:{x ' newplayer.sock.promptable = True newplayer.write = newplayer.sock.dispatch player.playerlist.append(newplayer) player.playerlist_by_name[newplayer.name] = newplayer player.playerlist_by_aid[newplayer.aid] = newplayer newplayer.sock.state['logged in'] = True newroom = area.room_by_vnum_global(1001) newplayer.move(newroom) newplayer.alias['s'] = 'south' newplayer.alias['n'] = 'north' newplayer.alias['e'] = 'east' newplayer.alias['w'] = 'west' newplayer.alias['ne'] = 'northeast' newplayer.alias['nw'] = 'northwest' newplayer.alias['sw'] = 'southwest' newplayer.alias['se'] = 'southeast' newplayer.alias['l'] = 'look' newplayer.alias['page'] = 'beep' newplayer.alias['u'] = 'up' newplayer.alias['d'] = 'down' newplayer.interp('look') newplayer.save() event.init_events_player(newplayer) comm.wiznet( f"{newplayer.name} @ {newplayer.sock.host} is a new character entering Akrios." ) del self else: self.roll_stats() self.show_stats() self.sock.dispatch('Are these statistics acceptable? ', trail=False)
def event_frontend_restart(fe_): comm.wiznet("Front end restart event initiated") del frontend.fesocket frontend.fesocket = frontend.FESocket() frontend_connected = frontend.fesocket.fesocket_connect() if not frontend_connected: comm.wiznet("Could not connect to Front End in event restart")
def getKnown(self, idnum=None): if id == None: comm.wiznet("You must provide an ID to lookup. getKnown:livingthing.py") return elif idnum not in self.knownpeople.keys(): return '' else: return self.knownpeople[idnum]
def fesocket_disconnect(self): comm.wiznet('fesocket_disconnect: Disconnecting from front end.') self.state['connected'] = False self.state['authenticated'] = False self.inbound_frame_buffer.clear() self.outbound_frame_buffer.clear() self.events.clear() self.close()
def event_grapevine_restart(): comm.wiznet("Grapevine restart event initiated") del grapevine.gsocket grapevine.gsocket = grapevine.GrapevineSocket() grapevine_connected = grapevine.gsocket.gsocket_connect() if not grapevine_connected: comm.wiznet("Could not connect to Grapevine in event restart")
def move(self, tospot=None, fromspot=None): if tospot == None: comm.wiznet("Received None value in move:livingthing.py") return else: if fromspot != None: fromspot.contents.remove(self) tospot.contents.append(self) self.location = tospot
def handle_accept(self): newconn = login.Login() connection, address = self.accept() sock = ConnSocket(connection, address) newconn.sock = sock newconn.sock.owner = newconn connlist.append(sock) newconn.greeting() comm.wiznet('Accepting connection from: {0}'.format(newconn.sock.host)) return sock
def handle_accept(self): newconn = login.Login() connection, address = self.accept() sock = ConnSocket(connection, address) newconn.sock = sock newconn.sock.owner = newconn connlist.append(sock) newconn.greeting() comm.wiznet(f"Accepting connection from: {newconn.sock.host}") return sock
def gsocket_disconnect(self): comm.wiznet( 'gsocket_disconnect: Disconnecting from Grapevine Network.') self.state['connected'] = False self.state['authenticated'] = False self.inbound_frame_buffer.clear() self.outbound_frame_buffer.clear() self.events.clear() self.subscribed.clear() self.other_games_players.clear() self.close()
def received_chan_unsub(self, sent_refs): """ We at some point sent a channel unsubscribe. This is verifying Grapevine received that. We unsub in our local list. Grapevine 1.0.0 """ if 'ref' in self.message and self.message['ref'] in sent_refs: orig_req = sent_refs.pop(self.message['ref']) channel = orig_req['payload']['channel'] self.gsock.subscribed[channel] = False comm.wiznet(f"Grapevine unsubscribed from channel {channel}")
def fesocket_connect(self): try: result = self.connect('ws://localhost:8989') comm.wiznet('fesocket_connect: Attempting connection to front end.') comm.wiznet(f'fesocket_connect result: {result}') except ConnectionError or ConnectionRefusedError or ConnectionAbortedError as err: log.error(f'Exception raised in fesocket_connect: {err}') return False # We need to set the below on the socket as websocket.WebSocket is # blocking by default. :( self.sock.setblocking(0) return True
def login(self, name): if name: new_conn = login.Login(name, softboot=True) else: new_conn = login.Login() new_conn.sock = self new_conn.sock.owner = new_conn if not name: new_conn.greeting() comm.wiznet(f"Accepting connection from: {new_conn.sock.host}") else: new_conn.interp = new_conn.character_login new_conn.interp()
def gsocket_connect(self): try: result = self.connect('wss://grapevine.haus/socket') log.info('gsocket_connect: Attempting connection to Grapevine.') log.info(f'gsocket_connect result: {result}') except ConnectionError or ConnectionRefusedError or ConnectionAbortedError as err: log.error(f'Exception raised in gsocket_connect: {err}') return False # We need to set the below on the socket as websocket.WebSocket is # blocking by default. :( self.sock.setblocking(0) self.msg_gen_authenticate() comm.wiznet('gsocket_connect: Sending Auth to Grapevine Network.') return True
def get_roll_stats(self, inp): inp = inp.lower() if inp == 'y' or inp == 'yes': self.sock.dispatch(helpsys.get_help('motd', server=True)) self.sock.dispatch('') newplayer = player.Player() newplayer.filename = "{0}/{1}".format(world.playerDir, self.name) testsock = self.sock newplayer.name = self.name newplayer.password = self.password newplayer.capability.append('player') newplayer.lasttime = time.ctime() newplayer.lasthost = self.sock.host newplayer.race = self.newchar['race'] newplayer.aid = self.newchar['aid'] newplayer.gender = self.newchar['gender'] newplayer.discipline = self.newchar['discipline'] newplayer.aesthetic = self.newchar['aesthetic'] newplayer.position = 'standing' newplayer.maximum_stat = self.newstats newplayer.current_stat = self.newstats self.clear() newplayer.sock = testsock newplayer.sock.owner = newplayer newplayer.prompt = '{papmMUD{g:{x ' newplayer.sock.promptable = True newplayer.write = newplayer.sock.dispatch player.playerlist.append(newplayer) newroom = area.roomByVnum(101) newplayer.move(newroom) newplayer.alias['s'] = 'south' newplayer.alias['n'] = 'north' newplayer.alias['e'] = 'east' newplayer.alias['w'] = 'west' newplayer.alias['ne'] = 'northeast' newplayer.alias['nw'] = 'northwest' newplayer.alias['sw'] = 'southwest' newplayer.alias['se'] = 'southeast' newplayer.alias['l'] = 'look' newplayer.alias['page'] = 'beep' newplayer.interp('look') newplayer.save() comm.wiznet("{0} is a new character entering APM.".format(newplayer.name)) del(self) else: self.roll_stats() self.show_stats() self.sock.dispatch('Are these statistics acceptable? ', trail=False)
def character_login(self): path = f"{world.playerDir}/{self.name}.json" if os.path.exists(path): newobject = player.Player(path) testsock = self.sock self.clear() newobject.sock = testsock newobject.sock.owner = newobject newobject.sock.promptable = True newobject.sock.state['logged in'] = True newobject.write = newobject.sock.dispatch if not self.softboot: newobject.write("") newobject.write(helpsys.get_help("motd", server=True)) newobject.write("") comm.wiznet( f"{newobject.name.capitalize()} logging in from {newobject.sock.host}." ) player.playerlist.append(newobject) player.playerlist_by_name[newobject.name] = newobject player.playerlist_by_aid[newobject.aid] = newobject event.init_events_player(newobject) newobject.logpath = os.path.join(world.logDir, f"{newobject.name}.log") if newobject.position == "sleeping": newobject.write("You are sleeping.") else: newobject.interp("look") if self.softboot: newobject.write('') newobject.write('Something feels different.') if grapevine.LIVE: log.debug( f"Sending player login to Grapevine : {newobject.name}") asyncio.create_task( grapevine.msg_gen_player_login(newobject.name)) asyncio.create_task( frontend.msg_gen_player_login(newobject.name, newobject.sock.session)) newobject.lasttime = time.ctime() newobject.lasthost = newobject.sock.host else: self.sock.dispatch( "There seems to be a problem loading your file! Notify Jubelo." ) log.error(f"{path} does not exist!") self.main_menu() self.interp = self.main_menu_get_option
async def cmd_grapevine_channels_broadcast(message): name, game, message, channel = message if name is None or game is None: comm.wiznet("Received channels/broadcast with None type") return message = ( f"\n\r{{GGrapevine {{B{channel}{{x Chat{{x:{{y{name.capitalize()}" f"@{game.capitalize()}{{x:{{G{message}{{x") if message != "": grape_enabled = [ players for players in player.playerlist if players.oocflags_stored['grapevine'] == 'true' ] for eachplayer in grape_enabled: if channel in eachplayer.oocflags['grapevine_channels']: eachplayer.write(message)
def get_char_password(self, inp): inp = inp.encode("utf-8") if not bcrypt.checkpw(inp, self.password.encode("utf-8")): self.sock.dispatch( "\n\rI'm sorry, that isn't the correct password. Good bye.") asyncio.create_task( frontend.msg_gen_player_login_failed(self.name, self.sock.session)) asyncio.create_task(self.sock.handle_close()) else: # self.sock.do_echo() for person in player.playerlist: if person.name == self.name: self.sock.dispatch( "\n\rYour character seems to be logged in already. Reconnecting you." ) del person.sock.owner del person.sock testsock = self.sock self.clear() person.sock = testsock person.sock.owner = person person.sock.promptable = True person.write = person.sock.dispatch comm.wiznet(f"{person.name} reconnecting from link death.") return comm.wiznet(f"{self.name.capitalize()} logged into main menu.") self.sock.dispatch("") self.sock.dispatch("") self.sock.dispatch(f"Welcome back {self.name.capitalize()}!") self.sock.dispatch(f"You last logged in on {self.lasttime}") self.sock.dispatch(f"From this host: {self.lasthost}") self.sock.dispatch("") log.info( f"{self.name.capitalize()} logged into main menu. Last login {self.lasttime} from {self.lasthost}" ) self.lasttime = time.ctime() self.lasthost = self.sock.host.strip() asyncio.create_task( frontend.msg_gen_player_login(self.name.capitalize(), self.sock.session)) self.main_menu() self.interp = self.main_menu_get_option
def main_menu_get_option(self, inp): inp = inp.lower() if inp == '1': self.interp = self.character_login self.interp('') elif inp == '2': self.sock.dispatch(helpsys.get_help('motd', server=True)) self.sock.dispatch('') self.main_menu() elif inp == 'l': self.sock.dispatch('Thanks for playing. We hope to see you again soon.') comm.wiznet("{0} disconnecting from APM.".format(self.sock.host)) self.sock.handle_close() elif inp == 'd': self.sock.dispatch('Sorry to see you go. Come again soon!') os.remove('{0}/{1}'.format(world.playerDir, self.name)) self.sock.close() else: self.main_menu()
def received_chan_sub(self, sent_refs): """ We have attempted to subscribe to a channel. This is a response message from Grapevine. If failure, we make sure we show unsubscribed in our local list. if success, we make sure we show subscribed in our local list. Grapevine 1.0.0 """ if 'ref' in self.message and self.message['ref'] in sent_refs: orig_req = sent_refs.pop(self.message['ref']) if self.is_event_status('failure'): channel = orig_req['payload']['channel'] self.gsock.subscribed[channel] = False comm.wiznet( f"Grapevine failed to subscribe to channel {channel}") elif self.is_event_status('success'): channel = orig_req['payload']['channel'] self.gsock.subscribed[channel] = True comm.wiznet( f"Grapevine successfully subscribed to channel {channel}")
def addKnown(self, idnum=None, name=None): """ Assigns a string alias for a particular players ID number. (AID) Keyword arguments: idnum -- Integer representing another living thing (player) name -- A string to be used as an alias for this other player. Return value: None Example: None Additional notes: None """ if idnum == None or name == None: comm.wiznet("You must provide id and name arguments. addKnown:livingthing.py") return else: self.knownpeople[idnum] = name
def character_login(self, inp): path = '{0}\{1}'.format(world.playerDir, self.name) if os.path.exists(path): newobject = player.Player(path) testsock = self.sock self.clear() newobject.sock = testsock newobject.sock.owner = newobject newobject.sock.promptable = True newobject.write = newobject.sock.dispatch newobject.write('') newobject.write(helpsys.get_help('motd', server=True)) newobject.write('') comm.wiznet('{0} logging into APM.'.format(newobject.name.capitalize())) player.playerlist.append(newobject) newobject.logpath = '{0}\{1}'.format(world.logDir, newobject.name) comm.log(newobject.logpath, 'Logging in from: {0}'.format(newobject.sock.host)) newobject.interp('look') newobject.lasttime = time.ctime() newobject.lasthost = newobject.sock.host else: self.sock.dispatch('There seems to be a problem loading your file! Notify an admin.') self.main_menu() self.interp = self.main_menu_get_option
def received_auth(self): """ We received an event Auth event type. Determine if we are already authenticated, if so subscribe to the channels as determined in msg_gen_chan_subscribed in the GrapevineSocket Object. Otherwise, if we are not authenticated yet we send another authentication attempt via msg_gen_authenticate(). This is in place for path hiccups or restart events. Grapevine 1.0.0 """ if self.is_event_status('success'): self.gsock.state['authenticated'] = True self.gsock.state['connected'] = True self.gsock.msg_gen_chan_subscribe() comm.wiznet('Received authentication success from Grapevine.') self.gsock.msg_gen_player_status_query() comm.wiznet('Sending player status query to all Grapevine games.') elif not self.gsock.state['authenticated']: comm.wiznet( 'received_auth: Sending Authentication message to Grapevine.') self.gsock.msg_gen_authenticate()
def event_grapevine_receive_message(event_): grapevine_ = event_.owner grapevine_.handle_read() if grapevine_.inbound_frame_buffer: # Assign rcvd_msg to a GrapevineReceivedMessage instance. rcvd_msg = grapevine_.receive_message() ret_value = rcvd_msg.parse_frame() if ret_value: # We will receive a "tells/send" if there was an error telling a # foreign game player. if rcvd_msg.message['event'] == "tells/send": caller, target, game, error_msg = ret_value message = (f"\n\r{{GGrapevine Tell to {{y{target}@{game}{{G " f"returned an Error{{x: {{R{error_msg}{{x") for eachplayer in player.playerlist: if eachplayer.disp_name == caller: if eachplayer.oocflags_stored['grapevine'] == 'true': eachplayer.write(message) return if rcvd_msg.message['event'] == "tells/receive": sender, target, game, sent, message = ret_value message = ( f"\n\r{{GGrapevine Tell from {{y{sender}@{game}{{x: " f"{{G{message}{{x.\n\rReceived at : {sent}.") for eachplayer in player.playerlist: if eachplayer.disp_name == target.capitalize(): if eachplayer.oocflags_stored['grapevine'] == 'true': eachplayer.write(message) return # Received Grapevine Info that goes to all players goes here. message = "" channel = "" is_status_msg = False if rcvd_msg.message['event'] == "games/connect": game = ret_value.capitalize() message = f"\n\r{{GGrapevine Status Update: {game} connected to network{{x" is_status_msg = True if rcvd_msg.message['event'] == "games/disconnect": game = ret_value.capitalize() message = f"\n\r{{GGrapevine Status Update: {game} disconnected from network{{x" is_status_msg = True if rcvd_msg.message['event'] == "channels/broadcast": name, game, message, channel = ret_value if name is None or game is None: comm.wiznet("Received channels/broadcast with None type") return message = ( f"\n\r{{GGrapevine {{B{channel}{{x Chat{{x:{{y{name.capitalize()}" f"@{game.capitalize()}{{x:{{G{message}{{x") if rcvd_msg.is_other_game_player_update(): name, inout, game = ret_value if name is None or game is None: comm.wiznet("Received other game player update") return message = ( f"\n\r{{GGrapevine Status Update{{x: {{y{name.capitalize()}{{G " f"has {inout} {{Y{game.capitalize()}{{x.") is_status_msg = True if message != "": grape_enabled = [ players for players in player.playerlist if players.oocflags_stored['grapevine'] == 'true' ] if is_status_msg: for eachplayer in grape_enabled: eachplayer.write(message) else: for eachplayer in grape_enabled: if channel in eachplayer.oocflags[ 'grapevine_channels']: eachplayer.write(message) return
def wrapped_f(*args, **kwargs): caller, args_ = args kwargs_ = kwargs if 'disabled' in self.dec_kwargs: caller.write("That command is disabled") return if not set(self.dec_kwargs['capability']) & set(caller.capability): caller.write("Huh?") return # If the command has target requirements perform those here. if 'target' in self.dec_kwargs: target, post = Command.targets[self.dec_kwargs['target']]( caller, args_) if target is False and post is None: caller.write("\n\rNot a valid target.") caller.write(self.dec_kwargs['generic_fail']) return elif post is False: caller.write( "\n\rArguments are required for this command.") caller.write(self.dec_kwargs['generic_fail']) return else: kwargs_['target'] = target kwargs_['post'] = post # Verify all checks that must be True are True if 'truth_checks' in self.dec_kwargs and len( self.dec_kwargs['truth_checks']) > 0: for eachcheck in self.dec_kwargs['truth_checks']: if eachcheck in Command.checks: true_false, msg = Command.checks[eachcheck]( caller, args_, **self.dec_kwargs) if true_false is False: caller.write(msg) return # Verify all checks that must be False are False if 'false_checks' in self.dec_kwargs and len( self.dec_kwargs['false_checks']) > 0: for eachcheck in self.dec_kwargs['false_checks']: if eachcheck in Command.checks: gen_fail = self.dec_kwargs['generic_fail'] true_false, msg = Command.checks[eachcheck]( caller, args_, **self.dec_kwargs) if true_false: caller.write(msg) return try: command(caller, args_, **kwargs_) except Exception as err: to_log = (f"Error in command execution:\n\r" f"Player: {caller.name}\n\r" f"Command: {command}\n\r" f"Args: {args_}\n\r" f"KwArgs: {kwargs_}\n\r" f"Error: {err}") log.error(f"\n\r{to_log}") comm.wiznet(f"Command execution error: {to_log}") caller.write("Something terrible has happened. Sorry!") return
def addKnown(self, idnum=None, name=None): if idnum == None or name == None: comm.wiznet("You must provide id and name arguments. addKnown:livingthing.py") return else: self.knownpeople[idnum] = name
def event_grapevine_receive_message(event_): grapevine_ = event_.owner grapevine_.handle_read() if grapevine_.inbound_frame_buffer: # Assign rcvd_msg to a GrapevineReceivedMessage instance. rcvd_msg = grapevine_.receive_message() ret_value = rcvd_msg.parse_frame() if ret_value: # We will receive a "tells/send" if there was an error telling a # foreign game player. if rcvd_msg.message['event'] == "tells/send": caller, target, game, error_msg = ret_value message = (f"\n\r{{GGrapevine Tell to {{y{target}@{game}{{G " f"returned an Error{{x: {{R{error_msg}{{x") for eachplayer in player.playerlist: if eachplayer.disp_name == caller: if eachplayer.oocflags_stored['grapevine'] == 'true': eachplayer.write(message) return if rcvd_msg.message['event'] == "tells/receive": sender, target, game, sent, message = ret_value message = (f"\n\r{{GGrapevine Tell from {{y{sender}@{game}{{x: " f"{{G{message}{{x.\n\rReceived at : {sent}.") for eachplayer in player.playerlist: if eachplayer.disp_name == target.capitalize(): if eachplayer.oocflags_stored['grapevine'] == 'true': eachplayer.write(message) return if rcvd_msg.message['event'] == "games/status": if ret_value: # We've received a game status request response from # grapevine. Do what you will here with the information, # Not going to do anything with it in Akrios at the moment. return # Received Grapevine Info that goes to all players goes here. message = "" channel = "" is_status_msg = False if rcvd_msg.message['event'] == "games/connect": game = ret_value.capitalize() message = f"\n\r{{GGrapevine Status Update: {game} connected to network{{x" is_status_msg = True if rcvd_msg.message['event'] == "games/disconnect": game = ret_value.capitalize() message = f"\n\r{{GGrapevine Status Update: {game} disconnected from network{{x" is_status_msg = True if rcvd_msg.message['event'] == "channels/broadcast": name, game, message, channel = ret_value if name is None or game is None: comm.wiznet("Received channels/broadcast with None type") return message = (f"\n\r{{GGrapevine {{B{channel}{{x Chat{{x:{{y{name.capitalize()}" f"@{game.capitalize()}{{x:{{G{message}{{x") if rcvd_msg.is_other_game_player_update(): name, inout, game = ret_value if name is None or game is None: comm.wiznet("Received other game player update") return message = (f"\n\r{{GGrapevine Status Update{{x: {{y{name.capitalize()}{{G " f"has {inout} {{Y{game.capitalize()}{{x.") is_status_msg = True if message != "": grape_enabled = [players for players in player.playerlist if players.oocflags_stored['grapevine'] == 'true'] if is_status_msg: for eachplayer in grape_enabled: eachplayer.write(message) else: for eachplayer in grape_enabled: if channel in eachplayer.oocflags['grapevine_channels']: eachplayer.write(message) return if 'event' in rcvd_msg.message and rcvd_msg.message['event'] == 'restart': comm.wiznet("Received restart event from Grapevine.") restart_fuzz = 15 + rcvd_msg.restart_downtime grapevine_.gsocket_disconnect() nextevent = Event() nextevent.owner = grapevine_ nextevent.ownertype = "grapevine" nextevent.eventtype = "grapevine restart" nextevent.func = event_grapevine_restart nextevent.passes = restart_fuzz * PULSE_PER_SECOND nextevent.totalpasses = nextevent.passes grapevine_.events.add(nextevent)