def tellcoords( coords ):
    

    for each in coords:
        print(each, each[0], each[1], each[2])

        vanillabean.send("/tellraw @a " + showandtellraw.tojson(serverName + " [Map: _{} {}_|http://{}/map/#/{}/64/{}/-3/{}/0]".format(worlddict[ each[0].lower() ][0], ", ".join([each[1], each[2]]), URL, each[1], each[2], worlddict[ each[0].lower() ][1])))
def sendMaildrops():
    conn = sqlite3.connect(dbfile)
    cur = conn.cursor()

    cur.execute("SELECT * FROM maildrop natural join onlineplayers WHERE inverted = 0 and slots > 0 COLLATE NOCASE")
    maildrop = cur.fetchall()

    cur.execute("SELECT * FROM maildrop natural join onlineplayers WHERE inverted = 1 and slots = 0 COLLATE NOCASE")
    maildropinv = cur.fetchall()

    for mail in maildrop + maildropinv:
        dimcoords, boxname, desc, slots, hidden, inverted = mail
        dim, coords = dimcoords.split(",",1)

        if dim == "e":
            worldnum = "1"
        elif dim == "n":
            worldnum = "2"
        elif dim == "o":
            worldnum = "0"
        
        URLcoords = coords.replace(",", "/")           

        toserver = '/tellraw ' + boxname + ' ' + showandtellraw.tojson(serverName + ' {{Maildrop [_{}_|http://{}/map/#/{}/-1/{}/0]~{} {}}} {}'.format(desc if desc else "{} {}".format(worlddict[dim][0], coords), URL, URLcoords, worldnum, worlddict[dim][0], coords, "has {} items".format(slots) if slots else "is empty") )
        vanillabean.send( toserver )
        print(toserver)

    

    conn.commit()
    conn.close()
def tellcoords( coords ):
    worlddict = { "o" : ["overworld", "0"], "n" : ["nether", "2"], "e" : ["end", "1"] }

    for each in coords:
        print (each, each[0], each[1], each[2])

        vanillabean.send("/tellraw @a " + showandtellraw.tojson(serverFormat.format(servername) + "[Map: _" + worlddict[ each[0].lower() ][0] + " " + each[1] + ', ' + each[2] +  "_|http://" + URL + "/map/#/" + each[1] + "/64/" + each[2] + "/-3/" + worlddict[ each[0].lower() ][1]  + "/0]"))
Beispiel #4
0
def systemmessage( groups ):

    datetime = groups[0]
    name = groups[1]
    message = groups[2]
    finalline = '/tellraw ' + minecraftname + ' {"text":"","extra":[' + twitchmessage( datetime ) + ',' + colorname( name ) + ',{"text":"' + message + '","color":"dark_purple"}]}'


    vanillabean.send( finalline )
Beispiel #5
0
def tellcoords(coords):

    for each in coords:
        print(each, each[0], each[1], each[2])

        vanillabean.send("/tellraw @a " + showandtellraw.tojson(
            serverName +
            " [Map: _{} {}_|http://{}/map/#/{}/64/{}/-3/{}/0]".format(
                worlddict[each[0].lower()][0], ", ".join([each[1], each[2]]),
                URL, each[1], each[2], worlddict[each[0].lower()][1])))
def eventLogged(data):
    print(data)
    name = data[1]
    # print name
    ip = data[2].split(':')[0]
    
    #tweetmessage = urllib.urlencode({"status": name + " " + message})
    #response = json.loads(oauth_req( "https://api.twitter.com/1.1/statuses/update.json?" + tweetmessage, AccessToken, AccessTokenSecret, http_method="POST"))
    #print response
    

    try:
        for each in open( otherdata + "/motd.txt", "r" ).readlines():

            time.sleep(1)
            message = "/tellraw " + name + " " + showandtellraw.tojson( each.strip() )
            vanillabean.send( message )
    except:
        pass


    


    conn = sqlite3.connect(dbfile, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
    cur = conn.cursor()


    cur.execute("SELECT * FROM maildrop WHERE inverted = 0 and slots > 0 and name = ? COLLATE NOCASE", (name,))
    maildrop = cur.fetchall()

    cur.execute("SELECT * FROM maildrop WHERE inverted = 1 and slots = 0 and name = ? COLLATE NOCASE", (name,))
    maildropinv = cur.fetchall()

    for mail in maildrop + maildropinv:
        dimcoords, boxname, desc, slots, hidden, inverted = mail
        dim, coords = dimcoords.split(",",1)

        if dim == "e":
            worldnum = "1"
        elif dim == "n":
            worldnum = "2"
        elif dim == "o":
            worldnum = "0"
        
        URLcoords = coords.replace(",", "/")           

        toserver = '/tellraw ' + boxname + ' ' + showandtellraw.tojson(serverName + ' {{Maildrop [_{}_|http://{}/map/#/{}/-1/{}/0]~{} {}}} {}'.format(desc if desc else "{} {}".format(worlddict[dim][0], coords), URL, URLcoords, worldnum, worlddict[dim][0], coords, "has {} items".format(slots) if slots else "is empty") )
        vanillabean.send( toserver )
        print(toserver)
    q.put(('insert into joins values (?,?,?,?)', (datetime.datetime.now(), name, UUID.get(name, "Unknown"), ip)))
    

    conn.commit()
    conn.close()
Beispiel #7
0
def on_member_update(before, after):

    beforeRoles = [role.name for role in before.roles]
    afterRoles = [role.name for role in after.roles]
    print(beforeRoles, afterRoles)
    player = before.nick if before.nick else before.name
    if "whitelisted" in beforeRoles and "whitelisted" not in afterRoles:
        print("Unwhitelisting")
        vanillabean.send("/whitelist remove {}".format(player))
    elif "whitelisted" not in beforeRoles and "whitelisted" in afterRoles:
        print("Whitelisting")
        vanillabean.send("/whitelist add {}".format(player))
Beispiel #8
0
def chatUpdate():
    global streaming
    global debug
    global createTime
    
    while True:
        time.sleep(5 * 60)
        if streaming or debug:
            logging.debug("Updating chat")

            text = "<aqua^\<><dark_purple^twitch><aqua^\>> {}\/{} started {}".format(viewers, len(followers), pretty_date(time=createTime))
            logging.debug(text)
            vanillabean.send("/tellraw greener_ca " + showandtellraw.tojson(text))
Beispiel #9
0
def eventLogged(data):
    print(data)
    name = data[1]
    # print name
    ip = data[2].split(':')[0]

    #tweetmessage = urllib.urlencode({"status": name + " " + message})
    #response = json.loads(oauth_req( "https://api.twitter.com/1.1/statuses/update.json?" + tweetmessage, AccessToken, AccessTokenSecret, http_method="POST"))
    #print response

    token = ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for _ in range(5))

    try:
        for each in open(otherdata + "/motd.txt", "r").readlines():

            time.sleep(1)
            message = "/tellraw " + name + " " + showandtellraw.tojson(
                each.strip().replace("verifykey", token))
            vanillabean.send(message)
    except:
        pass
    '''
    maildrop = dbQuery(dbfile, 30, ("SELECT * FROM maildrop WHERE inverted = 0 and slots > 0 and name = ? COLLATE NOCASE", (name,)))
    

    maildropinv = dbQuery(dbfile, 30, ("SELECT * FROM maildrop WHERE inverted = 1 and slots = 0 and name = ? COLLATE NOCASE", (name,)))

    for mail in maildrop + maildropinv:
        dimcoords, boxname, desc, slots, hidden, inverted = mail
        dim, coords = dimcoords.split(",",1)

        if dim == "e":
            worldnum = "1"
        elif dim == "n":
            worldnum = "2"
        elif dim == "o":
            worldnum = "0"
        
        URLcoords = coords.replace(",", "/")           

        toserver = '/tellraw ' + boxname + ' ' + showandtellraw.tojson(serverName + ' {{Maildrop [_{}_|http://{}/map/#/{}/-1/{}/0]~{} {}}} {}'.format(desc if desc else "{} {}".format(worlddict[dim][0], coords), URL, URLcoords, worldnum, worlddict[dim][0], coords, "has {} items".format(slots) if slots else "is empty") )
        vanillabean.send( toserver )
        print(toserver)
    '''
    q.put(('INSERT INTO joins VALUES (?,?,?,?)',
           (datetime.datetime.now(), name, UUID.get(name, "Unknown"), ip)))
    q.put(('REPLACE INTO discordverify (name, token) VALUES (?, ?)', (name,
                                                                      token)))
def tellcoords(coords):
    worlddict = {
        "o": ["overworld", "0"],
        "n": ["nether", "2"],
        "e": ["end", "1"]
    }

    for each in coords:
        print each, each[0], each[1], each[2]

        vanillabean.send("/tellraw @a " + showandtellraw.tojson(
            "<green^" + servername + "> [Map: _" +
            worlddict[each[0].lower()][0] + " " + each[1] + ', ' + each[2] +
            "_|http://" + URL + "/map/#/" + each[1] + "/64/" + each[2] +
            "/-3/" + worlddict[each[0].lower()][1] + "/0]"))
def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return
    print(message.author.display_name, message.clean_content.encode("utf-8"))

    if message.channel.is_private:
        coordscomma =  re.findall( "^([EONeon]) (-?\d+), ?(-?\d+)", message.content)
        
        if coordscomma:
            
            yield from client.send_message(channelobject, coordsmessage( coordscomma ))
            tellcoords(coordscomma)

    if message.channel.id == discordChannel:
        links = re.findall('(https?://\S+)', message.content)

        display_name = str(message.author.display_name)
        discordName = str(message.author)
        messagetext = str(message.clean_content) 
        # messagetext = messagetext.replace('"', r"\"")
        discordtext =  u'{"text" : "\\u2689 ", "color" : "blue" }'

        print([a.name for a in message.author.roles])
        
        if message.author.bot:
            nameFormat = '<blue^\<>{{<green^{}>~{}}}<blue^\>> '
            mcplayer, mcmessage = messagetext.split(" ", 1)
            messagetext = mcplayer.strip('`') + " " + mcmessage
        elif "patrons" in [a.name for a in message.author.roles]:
            
            nameFormat = '<blue^\<>{{<red^{}>~{}}}<blue^\>> '
        else:
            nameFormat = '<blue^\<>{{<white^{}>~{}}}<blue^\>> '

        #finalline = '/tellraw @a[team=!mute] {{"text" : "", "extra" : [{}, {{"color" : "gold", "text" : "{} "}}, {{"text" : "{}"}}]}}'.format(discordtext, display_name, messagetext)
        tellrawText =  nameFormat.format(display_name.replace("_", "\_").replace("~",""), discordName.replace("_", "\_").replace("@","\@").replace("~",""))
        finalline = '/tellraw @a[team=!mute] ' + showandtellraw.tojson(tellrawText, noparse=messagetext)

        vanillabean.send(finalline)


        if links:
           telllinks( links )

    if message.channel.id == discordPrivChannel and not message.author.bot:
        yield from client.send_message(privchannelobject, vanillabean.send(message.content))
Beispiel #12
0
def publicmessage( groups ):
    time = groups[0]
    name = groups[1]
    message = groups[2]
    command = message.split()[0]

    name = name.strip(" ").strip("@")

    if command == "!makeitrain":
        finalline = "/toggledownfall"
        vanillabean.send( finalline )
    elif command == "!ip":
        sendtotwitch( "The server address is: minecraft.greener.ca" )
    elif command == "!":
        sendtotwitch( "Commands available are: !ip, !xxxxxxxxxx" )
    else:
        finalline  = '/tellraw ' + minecraftname  + ' {"text":"","extra":[' + twitchmessage( time ) + ',' + colorname( name ) + ',{"text":"' + message.replace('"', r'\"') + '","color":"aqua"}]}'
        vanillabean.send( finalline )
Beispiel #13
0
def eventCommand(data):
    time, name, message = data
    command = message.split(" ", 1)[0]
    args = message.split(" ", 1)[1:]
    print(args)
    name = name.replace("?7", "").replace("?r", "")
    if command == "mute":
        if "on" in args:
            print("yup")
            vanillabean.send("/scoreboard teams join mute {}".format(name))
            vanillabean.send("/tell {} Muting Discord".format(name))
        elif "off" in args:
            vanillabean.send("/scoreboard teams leave mute {}".format(name))
            vanillabean.send("/tell {} Un-Muting Discord".format(name))

    if command == "social":

        network, user = args.split(" ", 1)
        print(network, user)

        if network == "twitch":
            q.put(('INSERT OR IGNORE INTO status (twitch, name) VALUES(?, ?)',
                   (user, name)))
            q.put(
                ('UPDATE status SET twitch = ? WHERE name = ?', (user, name)))
        if network == "youtube":
            q.put(('INSERT OR IGNORE INTO status (youtube, name) VALUES(?, ?)',
                   (user, name)))
            q.put(
                ('UPDATE status SET youtube = ? WHERE name = ?', (user, name)))
        if network == "twitter":
            q.put(('INSERT OR IGNORE INTO status (twitter, name) VALUES(?, ?)',
                   (user, name)))
            q.put(
                ('UPDATE status SET twitter = ? WHERE name = ?', (user, name)))
        if network == "reddit":
            q.put(('INSERT OR IGNORE INTO status (reddit, name) VALUES(?, ?)',
                   (user, name)))
            q.put(
                ('UPDATE status SET reddit = ? WHERE name = ?', (user, name)))
        if network == "clear":
            pass

    if command == "status":
        if args:
            status = args[0]
        else:
            status = ""

        q.put(('INSERT OR IGNORE INTO status (status, name) VALUES(?, ?)',
               (status, name)))
        q.put(('UPDATE status SET status = ? WHERE name = ?', (status, name)))
    """
        def maildropPage(page):
            if page:
                cur.execute("SELECT * FROM maildrop WHERE name = ? COLLATE NOCASE limit ?, ?", (name, (page - 1) * 5, 5))
                maildrop = cur.fetchall()

            
                vanillabean.send("/tellraw {} ".format(name) + showandtellraw.tojson("{} <yellow^--- {} maildrop(s) - page {} of {} - \(!maildrop \<page\>\) --->".format(serverName, total, page, totalPages)))
                for mail in maildrop:
                    dimcoords, boxname, desc, slots, hidden, inverted = mail
                    dim, coords = dimcoords.split(",",1)
                
                    URLcoords = coords.replace(",", "/")           
            
                    toserver = '/tellraw ' + boxname + ' ' + showandtellraw.tojson(serverName + ' {{Maildrop [_{}_|http://{}/map/#/{}/-1/{}/0]~{} {}}} {}'.format(desc if desc else "{} {}".format(worlddict[dim][0], coords), URL, URLcoords, worlddict[dim][1], worlddict[dim][0], coords, "has {} items".format(slots) if slots else "is empty") )
                    vanillabean.send( toserver )
                    print(toserver)

            else:
                pass
def process_message(data):
    if "reply_to" not in data and data["channel"] == slackchan:
        yup = []
        words = data["text"].split()
        if words[0][0] == "*" and words[0][-1] == "*":
            words[0] = words[0].strip("*")
        for each in words:
            if each[0] == '<' and each[-1] == '>':
                word = each.strip('<>')
                if word[0] == "@":
                    yup.append(u"§6" + members[word.lstrip("@")] + u"§r")
                elif word[0] == "!":
                    yup.append(u"§6everyone§r")
                elif word[0] == "#":
                    yup.append(u"channel")
                else:
                    yup.append(word)
            else:
                yup.append(each)

        message = " ".join(yup)

        sendtext = formattext(u"@" + members[data["user"]], message)
        print repr(sendtext)
        vanillabean.send(html.unescape(sendtext))

        coordscomma = re.findall("^([OENoen]) (-?\d+), (-?\d+)", data["text"])
        if coordscomma:
            print coordscomma
            tellcoords(coordscomma)
            outputs.append([slackchan, coordsmessage(coordscomma)])

        links = re.findall('<(https?://\S+)>', data["text"])
        print links
        if links:
            telllinks(links)

    elif data["channel"] in slackadminchans and data["user"] in slackadminusers:
        outputs.append(
            [data["channel"],
             vanillabean.send(data["text"].strip("."))])
Beispiel #16
0
def updateStreaming(bool):
    global streaming
    
    if bool == streaming:
        pass
    elif bool == True:
        streaming = True
        vanillabean.send( "/scoreboard teams join Twitch greener_ca" )
        jsontext = showandtellraw.tojson("<aqua^\<><dark_purple^twitch><aqua^\>> you are streaming")
        vanillabean.send("/tellraw greener_ca " + jsontext)
        logging.debug("Started streaming")
    else:
        streaming = False
        vanillabean.send( "/scoreboard teams leave Twitch greener_ca" )
        jsontext = showandtellraw.tojson("<aqua^\<><dark_purple^twitch><aqua^\>> you are NOT  streaming")
        vanillabean.send("/tellraw greener_ca " + jsontext)
        logging.debug("Stopped streaming")
Beispiel #17
0
def shownewfollowers():
    global newfollowers

    while True:

        for yay in newfollowers:
            logging.debug( "New follower: " + yay )
            sendreset = '/title greener_ca reset'
            finalline1 = '/title greener_ca subtitle {"text":"new follower!","color":"aqua"}'
            finalline2 = '/title greener_ca title {"text":"' + yay + '","color":"green"}'
            vanillabean.send( sendreset )
            vanillabean.send( finalline1)
            vanillabean.send( finalline2)
            systemmessage( [ time.asctime(),  yay, "is a new follower!" ] )
            newfollowers.remove( yay )
            time.sleep( 10 )

        time.sleep( 5 )
Beispiel #18
0
def check_sheet():
    scope = ['https://spreadsheets.google.com/feeds']

    credentials = ServiceAccountCredentials.from_json_keyfile_name('/minecraft/host/config/My Project-66fa66082aaa.json', scope)


    
    global channelobject

    yield from client.wait_until_ready()
    while not client.is_closed:
        gc = gspread.authorize(credentials)
        wks = gc.open("Barlynaland application (Responses)")
        rows = wks.get_worksheet(0).get_all_values()

        newapplications = [row for row in enumerate(rows) if row[1][0] and not row[1][6]]
        oldapplications = [row for row in enumerate(rows) if row[1][6] and not row[1][7]]

        for application in newapplications:
            app = application[1]
            appmessage = yield from create_application(app[3], app[4], app[5], app[1])
            print(application[0])
            wks.get_worksheet(0).update_cell(application[0] + 1, 7, appmessage.id)

        for application in oldapplications:
            app = application[1]
            message = yield from client.get_message(channelobject, app[6])
            voteCount = 4
            upVotes = [react.count for react in message.reactions if react.emoji == u"\U0001f44d"][0]
            downVotes = [react.count for react in message.reactions if react.emoji == u"\U0001f44e"][0]
            ign = app[1]
            playeremail = app[2]

            if upVotes >= voteCount:
                print("Accepted")
                wks.get_worksheet(0).update_cell(application[0] + 1, 8, "Accepted")
                new_content = message.content.splitlines()
                new_content[-1] = "*Status:* `Accepted`"
                new_content = "\n".join(new_content)
                yield from client.edit_message(message, new_content)
                yield from client.unpin_message(message)

                fromaddr = "*****@*****.**"
                toaddr = playeremail
                msg = MIMEMultipart()
                msg['From'] = fromaddr
                msg['To'] = toaddr
                msg['Subject'] = "Tesseract Minecraft Network"

                body = """Welcome to the network, you've been whitelisted.

    This will give you access to Barlynaland, Blackbrane and Barbarus.

    Be sure to read the server message on Barlynaland when you log in, the underlined text is clickable!

    glhf

    greener_ca

    :)
    """
                msg.attach(MIMEText(body, 'plain'))


                server = smtplib.SMTP('smtp.gmail.com', 587)
                server.starttls()
                server.login(email, emailpass)

                text = msg.as_string()
                server.sendmail(fromaddr, toaddr, text)
                server.quit()
                print(playeremail)
                vanillabean.send("/whitelist add {}".format(ign))
            elif downVotes >= voteCount:
                print("Denied")
                new_content = message.content.splitlines()
                new_content[-1] = "*Status:* `Denied`"
                new_content = "\n".join(new_content)
                yield from client.edit_message(message, new_content)
                yield from client.unpin_message(message)
                wks.get_worksheet(0).update_cell(application[0] + 1, 8, "Denied")
                            
        yield from asyncio.sleep(1800)
def telllinks(links):
    for each in links:
        print each
        vanillabean.send("/tellraw @a " +
                         showandtellraw.tojson("<green^" + servername +
                                               "> [_Link_|" + each + "]"))

with open('/minecraft/host/config/server.yaml', 'r') as configfile:
    config = yaml.load(configfile)


mcfolder = config['mcdata']

sourceFile = sys.argv[1]


whitelistSource = {each["uuid"]: each["name"] for each in json.load(open(sourceFile))}
whitelistDest = {each["uuid"]: each["name"] for each in json.load(open(mcfolder + "/whitelist.json"))}


add = set(whitelistSource.values()) - set(whitelistDest.values())

remove = set(whitelistDest.values()) - set(whitelistSource.values())




for each in add:
    vanillabean.send("/whitelist add {}".format(each))
    print("/whitelist add {}".format(each))


for each in remove:
    vanillabean.send("/whitelist remove {}".format(each))
    print("/whitelist remove {}".format(each))
def eventCommand(data):
    time, name, message = data
    command = message.split(" ",1)[0]
    args = message.split(" ",1)[1:]
    print(args)
    name = name.replace("?7","").replace("?r","")
    if command == "mute":
        if "on" in args:
            print("yup")
            vanillabean.send("/scoreboard teams join mute {}".format(name))
            vanillabean.send("/tell {} Muting Discord".format(name))
        elif "off" in args:
            vanillabean.send("/scoreboard teams leave mute {}".format(name))
            vanillabean.send("/tell {} Un-Muting Discord".format(name))
    
    conn = sqlite3.connect(dbfile)
    cur = conn.cursor()
    
    if command == "social":    


        network, user = args.split(" ",1)       
        print(network, user)

        if network == "twitch":
            q.put(('INSERT OR IGNORE INTO status (twitch, name) VALUES(?, ?)', (user, name)))
            q.put(('UPDATE status SET twitch = ? WHERE name = ?', (user, name)))
        if network == "youtube":
            q.put(('INSERT OR IGNORE INTO status (youtube, name) VALUES(?, ?)', (user, name)))
            q.put(('UPDATE status SET youtube = ? WHERE name = ?', (user, name)))
        if network == "twitter":
            q.put(('INSERT OR IGNORE INTO status (twitter, name) VALUES(?, ?)', (user, name)))
            q.put(('UPDATE status SET twitter = ? WHERE name = ?', (user, name)))
        if network == "reddit":
            q.put(('INSERT OR IGNORE INTO status (reddit, name) VALUES(?, ?)', (user, name)))
            q.put(('UPDATE status SET reddit = ? WHERE name = ?', (user, name)))
        if network == "clear":
            pass

    if command == "status":
        if args:
            status = args[0]
        else:
            status = ""

        q.put(('INSERT OR IGNORE INTO status (status, name) VALUES(?, ?)', (status, name)))
        q.put(('UPDATE status SET status = ? WHERE name = ?', (status, name)))


    if command == "maildrop":

        def maildropPage(page):
            if page:
                cur.execute("SELECT * FROM maildrop WHERE name = ? COLLATE NOCASE limit ?, ?", (name, (page - 1) * 5, 5))
                maildrop = cur.fetchall()

            
                vanillabean.send("/tellraw {} ".format(name) + showandtellraw.tojson("{} <yellow^--- {} maildrop(s) - page {} of {} - \(!maildrop \<page\>\) --->".format(serverName, total, page, totalPages)))
                for mail in maildrop:
                    dimcoords, boxname, desc, slots, hidden, inverted = mail
                    dim, coords = dimcoords.split(",",1)
                
                    URLcoords = coords.replace(",", "/")           
            
                    toserver = '/tellraw ' + boxname + ' ' + showandtellraw.tojson(serverName + ' {{Maildrop [_{}_|http://{}/map/#/{}/-1/{}/0]~{} {}}} {}'.format(desc if desc else "{} {}".format(worlddict[dim][0], coords), URL, URLcoords, worlddict[dim][1], worlddict[dim][0], coords, "has {} items".format(slots) if slots else "is empty") )
                    vanillabean.send( toserver )
                    print(toserver)

            else:
                pass





        cur.execute('SELECT count(coords) FROM maildrop WHERE name = ? COLLATE NOCASE', (name,))
        total = cur.fetchall()[0][0]
        pageDiv = divmod(total, 5)
        totalPages = pageDiv[0] + bool(pageDiv[1])
        
        if args:
            try:
                page = int(args[0])
                if page <= totalPages:
                    maildropPage(page)
            except:

                pass
        else:
            page = 1
            maildropPage(page)
    

    conn.commit()
    conn.close()
Beispiel #22
0
            print("Locked")
            fail = True


threadDBWriter = threading.Thread(target=writeToDB)
threadDBWriter.setDaemon(True)
threadDBWriter.start()

delete = False

if len(sys.argv) > 1:
    delete = True if sys.argv[1] == "delete" else False

for name in expired:
    if delete:
        vanillabean.send("/whitelist remove " + name)
    else:
        print(name)

conn = sqlite3.connect(dbfile)
cur = conn.cursor()

cur.execute("DELETE FROM whitelist")

conn.commit()
conn.close()

whitelist = {
    each["uuid"]: each["name"]
    for each in json.load(open(mcfolder + "/whitelist.json"))
}
def telllinks( links ):
    for each in links:
        print( each)
        vanillabean.send("/tellraw @a " + showandtellraw.tojson((serverFormat + " [_Link_|{}]").format(servername, each)))
Beispiel #24
0
def telllinks(links):
    for each in links:
        print(each)
        vanillabean.send("/tellraw @a " +
                         showandtellraw.tojson(serverName +
                                               " [_Link_|{}]".format(each)))
Beispiel #25
0
import vanillabean
import sys

with open('/minecraft/host/config/server.yaml', 'r') as configfile:
    config = yaml.load(configfile)

mcfolder = config['mcdata']

sourceFile = sys.argv[1]

whitelistSource = {
    each["uuid"]: each["name"]
    for each in json.load(open(sourceFile))
}
whitelistDest = {
    each["uuid"]: each["name"]
    for each in json.load(open(mcfolder + "/whitelist.json"))
}

add = set(whitelistSource.values()) - set(whitelistDest.values())

remove = set(whitelistDest.values()) - set(whitelistSource.values())

for each in add:
    vanillabean.send("/whitelist add {}".format(each))
    print("/whitelist add {}".format(each))

for each in remove:
    vanillabean.send("/whitelist remove {}".format(each))
    print("/whitelist remove {}".format(each))
Beispiel #26
0
def startEpisode():
    global title
    showtitle = title.split("|")[0].strip()
    episodetitle = title.split("|")[1].strip()
    for sec in range(300, -1, -1):
        if sec == 10:
            bookcommand = tweetbook()
            logging.debug(bookcommand)
            vanillabean.send(bookcommand)

        timerText = "{} min {} sec".format(*divmod(sec, 60))
        vanillabean.send('/title greener_ca title {{"text": "{}"}}'.format(timerText))
        time.sleep(1)


    time.sleep(8)

    vanillabean.send('/title greener_ca subtitle {{"text": "{1}", "color": "gold"}}\n/title greener_ca title {{"text": "{0}", "color": "gold"}}'.format(showtitle, episodetitle))

    time.sleep(15 * 60)
    
    vanillabean.send('/title greener_ca title {"text": "tweets", "color": "gold"}')
    time.sleep(60 * 4)

    vanillabean.send('/title greener_ca title {"text": "wrap it up", "color": "gold"}')
    
    time.sleep(60)

    vanillabean.send('/title greener_ca subtitle {{"text": "{1}", "color": "gold"}}\n/title greener_ca title {{"text": "{0}", "color": "gold"}}'.format(showtitle, 'see you next time!'))

    time.sleep(11)

    vanillabean.send('/title greener_ca title {{"text": "{}"}}'.format("done"))
Beispiel #27
0
def on_message(message):
    worlddict = { "o" : ["overworld", "0"], "n" : ["nether", "2"], "e" : ["end", "1"] }
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return
    # print(message.author.display_name, message.clean_content.encode("utf-8"), message.attachments)

    if client.user in message.mentions:
        print("mentioned")
        reCoords =  re.findall( "(-?\d+,) ?(\d+,)? ?(-?\d+)", message.content)
        
        print(reCoords)
        if reCoords:
            reDim = re.findall("nether|end|over| o | e | n ", message.content)
            print(reDim)
            if reDim:
    
                if reDim[0] in ["over", " o "]:
                    dim = "o"
                elif reDim[0] in ["nether", " n "]:
                    dim = "n"
                elif reDim[0] in ["end", " e "]:
                    dim = "e"
            else:
                dim = "o"

                
            yield from client.send_message(message.channel, coordsmessage( reCoords, dim ))
            tellcoords(reCoords, dim)



    
    if message.channel.is_private:

        if message.content.startswith("/"):
            command = message.content[1:].split(" ", 1)[0]
            args = message.content[1:].split(" ", 1)[1:]
            print(command, args)
            name = dbQuery(dbfile, 100, ('SELECT name FROM players WHERE discordID = ?', (message.author.id,)))
            if name:
                name = name[0][0]
                print(name, command, args)



            if command == "link":
                ign = args[0]
                server =  client.get_server("140194383118073856")
                member = server.get_member(message.author.id)
                yield from client.send_message(message.channel, "You have 10 seconds to connect to the server with  {}. If you are already connected, please disconnect and reconnect. You will receive a message when you are successful".format(ign))            
                dbQuery(dbfile, 100, ('INSERT INTO verify (name, discordID) VALUES (?, ?)', (ign, message.author.id)))



            if command == "mute":
                
                if "on" in args:
                    print("yup")
                    vanillabean.send("/scoreboard teams join mute {}".format(name))
                    vanillabean.send("/tell {} Muting Discord".format(name))
                elif "off" in args:
                    vanillabean.send("/scoreboard teams leave mute {}".format(name))
                    vanillabean.send("/tell {} Un-Muting Discord".format(name))





            if command == "maildrop":
                print("Printing maildrops")
                maildrop = dbQuery(dbfile, 30, ("SELECT coords, name, desc, slots, hidden, inverted FROM maildrop WHERE name = ? COLLATE NOCASE", (name,)))
                print(maildrop)

                if maildrop:
                    toplayer = "Showing maildrops for {}\n".format(name)
                    for mail in maildrop:
                        dimcoords, boxname, desc, slots, hidden, inverted = mail
                        dim, coords = dimcoords.split(",", 1)

                        URLcoords = coords.replace(",", "/")           

                        toplayer += ':package: {} {} http://{}/map/#/{}/-1/{}/0\n'.format(desc if desc else "{} {}".format(worlddict[dim][0], coords), "has {} items".format(slots) if slots else "is empty", URL, URLcoords, worlddict[dim][1])
                    yield from client.send_message(message.channel, toplayer)            




    if message.channel.id == discordChannel:
        links = re.findall('(https?://\S+)', message.content)

        display_name = str(message.author.display_name)
        discordName = str(message.author)
        messagetext = str(message.clean_content) 
        # messagetext = messagetext.replace('"', r"\"")
        discordtext =  u'{"text" : "\u2689 ", "color" : "blue" }'

        print([a.name for a in message.author.roles])
        
        if message.author.bot:
            nameFormat = '<blue^\<>{{<green^{}>~{}}}<blue^\>> '
            mcplayer, mcmessage = messagetext.split(" ", 1)
            messagetext = mcplayer.strip('`') + " " + mcmessage
        elif "patrons" in [a.name for a in message.author.roles]:
            
            nameFormat = '<blue^\<>{{<red^{}>~{}}}<blue^\>> '
        else:
            nameFormat = '<blue^\<>{{<white^{}>~{}}}<blue^\>> '

        #finalline = '/tellraw @a[team=!mute] {{"text" : "", "extra" : [{}, {{"color" : "gold", "text" : "{} "}}, {{"text" : "{}"}}]}}'.format(discordtext, display_name, messagetext)
        tellrawText =  nameFormat.format(display_name.replace("_", "\_").replace("~",""), discordName.replace("_", "\_").replace("@","\@").replace("~",""))
        finalline = '/tellraw @a[team=!mute] ' + showandtellraw.tojson(tellrawText, noparse=messagetext)

        vanillabean.send(finalline)


        if links:
           telllinks( links )

    if message.channel.id == discordPrivChannel and not message.author.bot:
        yield from client.send_message(privchannelobject, vanillabean.send(message.content))
twoWeeksOnList = [each[1] for each in cur.fetchall()]

didntlogin = [each for each in twoWeeksOnList if each not in active]


expired = [each[1] for each in list(whitelist.items()) if each[0] in old or each[0] in didntlogin]


print(expired)

delete = False

if len(sys.argv) > 1:
    delete = True if sys.argv[1] == "delete" else False

for name in expired:
    if delete:
        vanillabean.send("/whitelist remove " + name)
    else:
        print(name)


cur.execute("DELETE FROM whitelist")

for each in list(whitelist.items()):

    q.put(("INSERT OR IGNORE INTO whitelist (name, UUID) VALUES (?,?)", (each[1], each[0])))

conn.commit()
conn.close()
Beispiel #29
0
def tellcoords( reCoords, reDim ):
    worlddict = { "o" : ["overworld", "0"], "n" : ["nether", "2"], "e" : ["end", "1"] }
    for each in reCoords:
        
        vanillabean.send("/tellraw @a " + showandtellraw.tojson(serverFormat.format(servername) + "[Map: _{} {}{}{}_|http://{}/map/#/{}/{}/{}/-3/{}/0]".format(worlddict[reDim][0], each[0], each[1], each[2], URL, each[0].strip(','), each[1].strip(',') if each[1] else "64" , each[2], worlddict[reDim][1])))