Skip to content

Instantly share code, notes, and snippets.

@sunshinekitty
Created January 28, 2015 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunshinekitty/791ceed5c78158e8edfd to your computer and use it in GitHub Desktop.
Save sunshinekitty/791ceed5c78158e8edfd to your computer and use it in GitHub Desktop.
League Spammer
# -*- coding: utf-8 -*-
"""
leaguelib.py
~~~~~~~~~
Includes class for interacting with League API
:copyright: (c) 2015 by Alex Edwards.
"""
import json
import requests
import sys
class League():
def __init__(self):
self.__endpoint = "https://na.api.pvp.net/api/lol/na"
self.__apikey = "YOUR_API_KEY"
self.__headers = { 'Accept': 'application/json',
'Accept-Language': 'en-US',
'Accept-Charset': 'utf-8',
'Content-Type': 'application/json'}
def _get(self, url):
'''Performs GET request to given URL'''
requrl = self.__endpoint + url + '?api_key=' + self.__apikey
req = requests.get(requrl, headers=self.__headers, verify=False)
if req.status_code in range(200, 300):
return json.loads(req.text)
print("ERROR")
print(json.loads(req.text))
sys.exit(1)
def get_match_history(self, summoner_id):
'''Returns match history'''
return self._get('/v2.2/matchhistory/' + summoner_id)
def get_match(self, match_id):
'''Returns a matches data'''
return self._get('/v2.2/match/' + match_id)
def get_summoner_by_name(self, summoner):
'''Returns summoner info'''
return self._get('/v1.4/summoner/by-name/' + summoner)
def send_text(numstring, message):
message = {"number": numstring, "message": message}
r = requests.post("http://textbelt.com/text", data=message)
return r.status_code, r.text
# -*- coding: utf-8 -*-
"""
leaguespam.py
~~~~~~~~~
Script for spamming people
:copyright: (c) 2015 by Alex Edwards.
"""
import leaguelib
import os.path
import time
summoner_name = "LEAGUE_USERNAME"
phone_number = "USERS_CELL_NUMBER"
league = leaguelib.League()
text = leaguelib.send_text
cache_file = 'lastmatchid-' + summoner_name + '.txt'
if not os.path.isfile(cache_file):
f = open(cache_file,'w')
f.write('0') # invalid id to start
f.close()
with open(cache_file,'r') as f:
last_match_id = f.readline() # first line of file
summoner_id = str(league.get_summoner_by_name(summoner=summoner_name)[summoner_name]['id'])
while True:
N_last_match_data = league.get_match_history(summoner_id)['matches'][9]
N_last_match_id = N_last_match_data['matchId']
if N_last_match_id != int(last_match_id): # New match detected!!!
f = open(cache_file,'w')
f.write(str(N_last_match_data['matchId'])) # Write new ID
f.close()
last_match_id = N_last_match_id # Last match ID
last_match_data = N_last_match_data
last_match_data_user = last_match_data["participants"][0]["stats"]
win_loss = "win you didn't deserve" if (last_match_data_user["winner"]) else "fucking loss"
level = last_match_data_user["champLevel"]
level = "That game must have lasted 2 hours for you to get to level %s." % level if (int(level) > 16) else "You really suck ass to have only gotten to level %s." % level
deaths = last_match_data_user["deaths"]
ranked = "It must be so hard playing in BRONZE 5 LOL." if (last_match_data["queueType"] == "RANKED_SOLO_5x5") else "You didn't even play ranked LOL FAGGOT."
phrase = "Good job on the %s! %s Fucking pleb. %s Next time try dieing less than %s times. LOL" \
% (win_loss, level, ranked, deaths)
print(phrase)
print(text(phone_number, phrase))
time.sleep(61)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment