# This Python file uses the following encoding: utf-8 from config import * from functions import * def send_halloween_email(user): domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="halloween",domain=domain,user=user),title=u"πŸŽƒ Hey Adventurer! Check out our new Halloween Zone! πŸŽƒ",text="Adventure Land has a new Halloween Zone!") def send_xmas_email(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="xmas",domain=domain,user=user),title=u"πŸŽ„ Hey Adventurer! Winterland is Here. Xmas Drops are Everywhere! +Steam Greenlight πŸŽ„",text="Adventure Land's Xmas Event is Here'!") except: logging.info("Email failed: %s"%user.k()) log_trace() def send_xmas2_email(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="xmas2",domain=domain,user=user),title=u"πŸŽ„ Hey Adventurers! Our Xmas Event is Live! πŸŽ„",text="Adventure Land's Xmas Event is Here'!") except: logging.info("Email failed: %s"%user.k()) log_trace() def send_xmas3_email(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="xmas3",domain=domain,user=user),title=u"πŸŽ„ Hey Adventurers! Our Holiday Season Event is Here and We have Snowballs Now! β˜ƒοΈ",text="Adventure Land's Holiday Season Event is Here'!") except: logging.info("Email failed: %s"%user.k()) log_trace() def send_cvalentines_email(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="cvalentines",domain=domain,user=user),title=u"⛩️ Chinese New Year + Valentine's Day Events! Grand Prize: Dragon Armor πŸ’˜",text="Adventure Land's Chinese New Year Event is Here'!") except: logging.info("Email failed: %s"%user.k()) log_trace() def send_easter_email(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="easter",domain=domain,user=user),title=u"🐰 πŸ₯š Easter Event on Adventure Land! +Map Editor πŸ—ΊοΈ 🐰",text="Adventure Land's Easter Event is Here'!") except: logging.info("Email failed: %s"%user.k()) log_trace() def send_easter_email2(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="easter2",domain=domain,user=user),title=u"🐰 Adventure Land's Easter Event is Here! πŸ₯š",text="Adventure Land's Easter Event is Here!") except: logging.info("Email failed: %s"%user.k()) log_trace() def send_anniversary_email(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="anniversary",domain=domain,user=user),title=u"πŸŽ‚ 🎁 Anniversary Event on Adventure Land! πŸŽ‰ 🍰",text="Adventure Land's Anniversary Event is Here'!") except: logging.info("Email failed: %s"%user.k()) log_trace() def send_halloween_email2(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="halloween2",domain=domain,user=user),title=u"New Map: Spooky Town on Adventure Land, Mummies, Franky, Ghosts, New Drops! Test πŸŽƒ 😱",text="Adventure Land has a new map!") except: logging.info("Email failed: %s"%user.k()) log_trace() def send_halloween_email3(user): try: domain=gdi() send_email(domain,user.info.email,html=shtml("htmls/contents/announcement_email.html",purpose="halloween3",domain=domain,user=user),title=u"Halloween Event on Adventure Land! New Cooperative Boss: Franky πŸŽƒ",text="Adventure Land has a new boss!") except: logging.info("Email failed: %s"%user.k()) log_trace() def all_user_cron(num): rpcs=[] for user in User.query(User.random_number==num): #logging.info(user) if len(user.info.characters): user.name=user.info.characters[0]["name"] else: user.name="#%s"%user.info.signupth rpcs.append(user.put_async()) if len(rpcs)>=50: #SDK-old for rpc in rpcs: rpc.wait() rpcs=[] for rpc in rpcs: rpc.wait() #SDK-old def all_user_cron(num): #<datetime.now(): user.banned=True user.put() def all_user_cron(num): #<',methods=['GET','POST']) @ndb.toplevel def serve_all_cron(mname=""): domain=gdi(request); user=get_user(request,domain) if not (user and getattr(user,"admin",False) or request.headers.get('X-AppEngine-Cron')): return "no permission" if mname=="user": for n in range(1,101): deferred.defer(all_user_cron,n,_queue="important") if mname=="mail": for n in range(1,101): deferred.defer(all_mail_cron,n,_queue="important") if mname=="character": for n in range(1,101): deferred.defer(all_character_cron,n,_queue="important") if mname=="backups": #originally, backups were on-access, but they need to be all at the same time, so a reversal restores the ~whole state of the game [19/11/18] for n in range(1,101): deferred.defer(all_ubackup_cron,n,_queue="important") deferred.defer(all_cbackup_cron,n,_queue="important") if mname=="process_backups": for n in range(1,101): deferred.defer(all_process_cron,n,_queue="important") return "" @app.route('/cr/check_servers',methods=['GET','POST']) @ndb.toplevel def serve_server_checker(): domain=gdi(request); user=get_user(request,domain) if not (user and getattr(user,"admin",False) or request.headers.get('X-AppEngine-Cron')): return "no permission" check_servers() return "" @app.route('/cr/unstuck',methods=['GET','POST']) @ndb.toplevel def serve_unstuck(): domain=gdi(request); user=get_user(request,domain) if not (user and getattr(user,"admin",False) or request.headers.get('X-AppEngine-Cron')): return "no permission" servers=get_servers() for server in servers: if msince(server.created)>10: #no widespread network issue characters=Character.query(Character.online==True, Character.server == server.k(), Character.last_sync < datetime.now()-timedelta(minutes=30)).fetch() for character in characters: m=msince(character.last_sync) character.online=False character.server="" character.put() send_email(gdi(),"kaansoral@gmail.com",html="Stuck for %s minutes"%m,title="UNSTUCK %s from %s"%(character.name,server.k())) return "" @app.route('/cr/hourly',methods=['GET','POST']) @ndb.toplevel def serve_hourly(): domain=gdi(request); user=get_user(request,domain) if not (user and getattr(user,"admin",False) or request.headers.get('X-AppEngine-Cron')): return "no permission" deferred.defer(verify_steam_installs) return "" if random.randrange(0,20)==2: user=get_by_iid("user|%s"%get_character("Wizard").owner) if random.randrange(0,20)==2: add_cash(user,100*random.randrange(1,50)) else: add_cash(user,200) if random.randrange(0,20)==2: user=get_by_iid("user|%s"%get_character("Oragon").owner) if random.randrange(0,20)==2: add_cash(user,100*random.randrange(1,50)) else: add_cash(user,200) #user=get_by_iid("user|%s"%get_character("Trexnamedtod").owner) #add_cash(user,25) #user=get_by_iid("user|%s"%get_character("Emerald").owner) #add_cash(user,5) return ""