Esempio n. 1
0
def weapons(error=''):
  template_info = {'nav_cell': 'Weapon Stock', 'signin_action': '/weapons', 'error_msg': error}
  try:
    if not error and 'steamID' in session:
      bp_json = get_user_backpack(session['steamID'])
      template_info['result'] = tf2toolbox.weapons.bp_weapons(bp_json, session)
  except TF2ToolboxException as e:
    template_info['error_msg'] = str(e)

  return render_template('weapon_stock.html', template_info=template_info, session=session)
Esempio n. 2
0
def bptext():
  template_info = {'nav_cell': 'Backpack Text', 'signin_action': '/bptext'}
  if request.method == 'POST' and request.form['form_id'] == 'bptext' and 'steamID' in session:
    try:
      bp_json = get_user_backpack(session['steamID'])
      template_info['bptext_result_string'] = tf2toolbox.bptext.bp_parse(bp_json, request.form, session)
      template_info['bptext_params'] = tf2toolbox.bptext.bptext_form_to_params(request.form)
    except TF2ToolboxException as e:
      template_info['error_msg'] = str(e)
    return render_template('bptext_result.html', template_info=template_info, session=session)

  return render_template('bptext_form.html', template_info=template_info, session=session)
Esempio n. 3
0
def metal(error=''):
  template_info = {'nav_cell': 'Metal Maker', 'signin_action': '/metal', 'error_msg': error}

  if not error and request.method == 'POST' and request.form['form_id'] == 'metal' and 'steamID' in session:
    try:
      bp_json = get_user_backpack(session['steamID'])
      template_info['result'] = tf2toolbox.metal.bp_metal(bp_json, request.form)
      template_info['metal_params'] = tf2toolbox.metal.metal_form_to_params(request.form)
    except TF2ToolboxException as e:
      template_info['error_msg'] = str(e)
    return render_template('metal_result.html', template_info=template_info, session=session)

  return render_template('metal_form.html', template_info=template_info, session=session)
Esempio n. 4
0
      steamID64 = resolve_vanity_url(steamURL[len('http://steamcommunity.com/id/'):])
      if steamID64 is None:
        return
      session['customURL'] = steamURL[len('http://steamcommunity.com/id/'):]
    else:
      steamID64 = steamURL[len('http://steamcommunity.com/profiles/'):]

    for key, value in get_player_info(steamID64).iteritems():
      session[key] = value
  except UnicodeEncodeError, e:
    raise TF2ToolboxException('Your Steam Community URL contained an invalid character.')

  if 'username' not in session or 'avatar' not in session or 'steamID' not in session:
    raise TF2ToolboxException("We were unable to retrieve info for that profile.\n")

  bp_json = get_user_backpack(session['steamID'])
  if not bp_json:
    return
  session['num_bp_slots'] = bp_json['result']['num_backpack_slots']


def send_notification_email(subject, message):
  # Read the email info file and parse
  msg = MIMEText(message)
  msg['Subject'] = subject
  msg['To'] = app.config['EMAIL_RECEIVER']
  # Send the email via Gmail.
  s = smtplib.SMTP(app.config['SMTP_SERVER'])
  s.ehlo()
  s.starttls()
  s.ehlo()