Merge pull request #137 from thenoodle68/develop

Fixing mistakes and mcstatus update.
This commit is contained in:
Luke Rogers 2013-09-04 07:11:35 -07:00
commit fabda30543
5 changed files with 27 additions and 27 deletions

1
.gitignore vendored
View file

@ -11,3 +11,4 @@ gitflow
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
.idea/ .idea/
plugins/data/GeoLiteCity.dat

View file

@ -178,7 +178,7 @@ class IRC(object):
if paramlist[-1].startswith(':'): if paramlist[-1].startswith(':'):
paramlist[-1] = paramlist[-1][1:] paramlist[-1] = paramlist[-1][1:]
lastparam = paramlist[-1] lastparam = paramlist[-1]
# put the parsed message in the response queue # put the parsed message in the response queue
self.out.put([msg, prefix, command, params, nick, user, host, self.out.put([msg, prefix, command, params, nick, user, host,
mask, paramlist, lastparam]) mask, paramlist, lastparam])
# if the server pings us, pong them back # if the server pings us, pong them back

View file

@ -2,11 +2,10 @@
Plugin which (de)cyphers a string Plugin which (de)cyphers a string
Doesn't cypher non-alphanumeric strings yet. Doesn't cypher non-alphanumeric strings yet.
by instanceoftom by instanceoftom
All character cyphering added - TheNoodle
""" """
from util import hook from util import hook
chars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ "
len_chars = len(chars)
@hook.command @hook.command
@ -20,19 +19,15 @@ def cypher(inp):
out = "" out = ""
passwd_index = 0 passwd_index = 0
for character in inp: for character in inp:
try: chr_index = ord(character)
chr_index = chars.index(character) passwd_chr_index = ord(passwd[passwd_index])
passwd_chr_index = chars.index(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_chr = chr[out_chr_index]
out += out_chr out += out_chr
passwd_index = (passwd_index + 1) % len_passwd passwd_index = (passwd_index + 1) % len_passwd
except ValueError:
out += character
continue
return out return out
@ -46,11 +41,7 @@ def decypher(inp):
passwd_index = 0 passwd_index = 0
for character in inp: for character in inp:
try: passwd_index = (passwd_index + 1) % len_passwd
chr_index = chars.index(character)
passwd_index = (passwd_index + 1) % len_passwd
except ValueError:
continue
passwd_index -= 1 passwd_index -= 1
reversed_message = inp[::-1] reversed_message = inp[::-1]
@ -58,10 +49,10 @@ def decypher(inp):
out = "" out = ""
for character in reversed_message: for character in reversed_message:
try: try:
chr_index = chars.index(character) chr_index = ord(character)
passwd_chr_index = chars.index(passwd[passwd_index]) 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_chr = chars[out_chr_index]
out += out_chr out += out_chr

View file

@ -3,7 +3,7 @@ import json
@hook.command(autohelp=False) @hook.command(autohelp=False)
def mcstatus(inp, say=None): def mcstatus(inp):
"""mcstatus -- Checks the status of various Mojang (the creators of Minecraft) servers.""" """mcstatus -- Checks the status of various Mojang (the creators of Minecraft) servers."""
try: try:
@ -16,13 +16,20 @@ def mcstatus(inp, say=None):
out = [] out = []
# use a loop so we don't have to update it if they add more servers # 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(): for server, status in data.items():
if status == "green": if status == "green":
out.append("{} is \x033\x02online\x02\x0f".format(server)) yes.append(server)
else: else:
out.append("{} is \x034\x02offline\x02\x0f".format(server)) no.append(server)
if yes:
return "\x0f" + ", ".join(out) + "." 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") @hook.command("haspaid")

View file

@ -52,7 +52,8 @@ def getSoundInfo(url, inp, jsondata=False):
def portal2(inp): def portal2(inp):
"""portal2 [who - ]<quote> - Look up Portal 2 quote. """portal2 [who - ]<quote> - Look up Portal 2 quote.
Example: .portal2 cave johnson - demand to see life's manager, 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) return getSoundInfo(portal2url, inp)