Created
March 11, 2012 16:45
-
-
Save joealcorn/2017096 to your computer and use it in GitHub Desktop.
for importing bans from banned-players.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
''' | |
No values are url encoded so will fail if any spaces/special chars exist | |
apikey and pathToBanList need to be changed, the rest will work as-is | |
''' | |
import urllib2 | |
apikey = 'your api key here' | |
reason = 'Imported' | |
adminName = 'Console' | |
pathToBanList = '/home/joe/Desktop/banned.txt' | |
def addBan(admin, user, reason): | |
addBanUrl = "http://www.mcbouncer.com/api/addBan/%(apikey)s/%(admin)s/%(user)s/%(reason)s" % { "apikey": apikey, "admin": admin, "user": user, "reason": reason} | |
doban = urllib2.urlopen(addBanUrl) | |
response = doban.read() | |
doban.close() | |
return response | |
if __name__ == '__main__': | |
playerList = open(pathToBanList) | |
players = playerList.readlines() | |
for player in players: | |
name = player.strip() | |
print addBan(adminName, name, reason) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment