Merge pull request #137 from thenoodle68/develop
Fixing mistakes and mcstatus update.
This commit is contained in:
commit
fabda30543
5 changed files with 27 additions and 27 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,3 +11,4 @@ gitflow
|
|||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
.idea/
|
||||
plugins/data/GeoLiteCity.dat
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
Plugin which (de)cyphers a string
|
||||
Doesn't cypher non-alphanumeric strings yet.
|
||||
by instanceoftom
|
||||
All character cyphering added - TheNoodle
|
||||
"""
|
||||
|
||||
from util import hook
|
||||
chars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||
len_chars = len(chars)
|
||||
|
||||
|
||||
@hook.command
|
||||
|
@ -20,19 +19,15 @@ def cypher(inp):
|
|||
out = ""
|
||||
passwd_index = 0
|
||||
for character in inp:
|
||||
try:
|
||||
chr_index = chars.index(character)
|
||||
passwd_chr_index = chars.index(passwd[passwd_index])
|
||||
chr_index = ord(character)
|
||||
passwd_chr_index = ord(passwd[passwd_index])
|
||||
|
||||
out_chr_index = (chr_index + passwd_chr_index) % len_chars
|
||||
out_chr = chars[out_chr_index]
|
||||
out_chr_index = (chr_index + passwd_chr_index) % 255
|
||||
out_chr = chr[out_chr_index]
|
||||
|
||||
out += out_chr
|
||||
|
||||
passwd_index = (passwd_index + 1) % len_passwd
|
||||
except ValueError:
|
||||
out += character
|
||||
continue
|
||||
return out
|
||||
|
||||
|
||||
|
@ -46,11 +41,7 @@ def decypher(inp):
|
|||
|
||||
passwd_index = 0
|
||||
for character in inp:
|
||||
try:
|
||||
chr_index = chars.index(character)
|
||||
passwd_index = (passwd_index + 1) % len_passwd
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
passwd_index -= 1
|
||||
reversed_message = inp[::-1]
|
||||
|
@ -58,10 +49,10 @@ def decypher(inp):
|
|||
out = ""
|
||||
for character in reversed_message:
|
||||
try:
|
||||
chr_index = chars.index(character)
|
||||
passwd_chr_index = chars.index(passwd[passwd_index])
|
||||
chr_index = ord(character)
|
||||
passwd_chr_index = ord(passwd[passwd_index])
|
||||
|
||||
out_chr_index = (chr_index - passwd_chr_index) % len_chars
|
||||
out_chr_index = (chr_index - passwd_chr_index) % 255
|
||||
out_chr = chars[out_chr_index]
|
||||
|
||||
out += out_chr
|
||||
|
|
|
@ -3,7 +3,7 @@ import json
|
|||
|
||||
|
||||
@hook.command(autohelp=False)
|
||||
def mcstatus(inp, say=None):
|
||||
def mcstatus(inp):
|
||||
"""mcstatus -- Checks the status of various Mojang (the creators of Minecraft) servers."""
|
||||
|
||||
try:
|
||||
|
@ -16,13 +16,20 @@ def mcstatus(inp, say=None):
|
|||
|
||||
out = []
|
||||
# use a loop so we don't have to update it if they add more servers
|
||||
yes = []
|
||||
no = ['luke']
|
||||
for server, status in data.items():
|
||||
if status == "green":
|
||||
out.append("{} is \x033\x02online\x02\x0f".format(server))
|
||||
yes.append(server)
|
||||
else:
|
||||
out.append("{} is \x034\x02offline\x02\x0f".format(server))
|
||||
|
||||
return "\x0f" + ", ".join(out) + "."
|
||||
no.append(server)
|
||||
if yes:
|
||||
out = "\x033\x02Online\x02\x0f: " + ", ".join(yes)
|
||||
if no:
|
||||
out += " "
|
||||
if no:
|
||||
out += "\x034\x02Offline\x02\x0f: " + ", ".join(no)
|
||||
return "\x0f" + out.replace(".mojang.com", ".mj").replace(".minecraft.net", ".mc")
|
||||
|
||||
|
||||
@hook.command("haspaid")
|
||||
|
|
|
@ -52,7 +52,8 @@ def getSoundInfo(url, inp, jsondata=False):
|
|||
def portal2(inp):
|
||||
"""portal2 [who - ]<quote> - Look up Portal 2 quote.
|
||||
Example: .portal2 cave johnson - demand to see life's manager,
|
||||
.portal2 i own the place | If - is not included, no 'who' data will be sent."""
|
||||
.portal2 i own the place
|
||||
If - is not included, no 'who' data will be sent."""
|
||||
return getSoundInfo(portal2url, inp)
|
||||
|
||||
|
||||
|
|
Reference in a new issue