예제 #1
0
 def pardonip(target):
     try:
         with MCRcon(config['serverIP'], config['rconPASS']) as mcr:
             response = mcr.command("pardon-ip " + target)
             btext.info(response)
     except:
         btext.error(
             "Something fucky happened while trying to use {}".format(
                 inspect.stack()[0][3]))
예제 #2
0
 def ban(target, reason):
     try:
         with MCRcon(config['serverIP'], config['rconPASS']) as mcr:
             response = mcr.command("ban " + target + " " + reason)
             btext.info(response)
     except:
         btext.error(
             "Something fucky happened while trying to use {}".format(
                 inspect.stack()[0][3]))
예제 #3
0
def send(message, me=None):
    if me is None:
        construct = "PRIVMSG #" + config["twitch"][
            "channel"] + " :" + message + "\r\n"
        s.send(construct.encode())
        btext.info("BOT: " + message)
        sleep(.5)
    else:
        construct = "PRIVMSG #" + config["twitch"][
            "channel"] + " :/me " + message + "\r\n"
        s.send(construct.encode())
        btext.info("/me BOT: " + message)
        sleep(.5)
예제 #4
0
 def datapack(*args):
     try:
         with MCRcon(config['serverIP'], config['rconPASS']) as mcr:
             if len(args) == 1:
                 response = mcr.command("datapack " + args[0])
                 btext.debug(args)
                 btext.debug("1")
                 btext.info(response)
             elif len(args) == 2:
                 response = mcr.command("datapack " + args[0] + ' "' +
                                        args[1] + '"')
                 btext.debug(args)
                 btext.debug("2")
                 btext.info(response)
             elif len(args) == 3:
                 response = mcr.command("datapack " + args[0] + ' "' +
                                        args[1] + '" ' + args[2])
                 btext.debug(args)
                 btext.debug("3")
                 btext.info(response)
             elif len(args) == 4:
                 response = mcr.command("datapack " + args[0] + ' "' +
                                        args[1] + '" ' + args[2] + ' "' +
                                        args[3] + '"')
                 btext.debug(args)
                 btext.debug("4")
                 btext.info(response)
     except Exception as e:
         btext.debug(e)
         btext.error(
             "Something fucky happened while trying to use {}".format(
                 inspect.stack()[0][3]))
예제 #5
0
def drawMainMenu():
    clear()
    btext.info('    Please choose your action')
    btext.info('1   set interface and wtf directorys')
    btext.info('2   set interface 1 active')
    btext.info('3   set interface 2 active')
    btext.info('4   restore backup')
    btext.info('5   quit')
    time.sleep(1)
    choice = input('choose a number: ')

    if choice == '1':
        clear()
        btext.info('please enter the path to your interface directory!')
        btext.info('0 to not change the current directory.')
        with open('./InterfaceSwitcher/dir.txt', 'r') as dirs:
            dirs = dirs.readlines()
        dirData = [dirs[0], dirs[1]]
        btext.info('the current directorys are: ')
        btext.info('interface: ' + dirs[0])
        btext.info('wtf: ' + dirs[1])

        interfaceDir = input('path to interface: ')
        if interfaceDir == '0':
            pass
        elif os.path.exists(interfaceDir):
            btext.success('input accepted!')
            dirData[0] = (interfaceDir + '\n')
        else:
            btext.warning('your input seems to be invalid, please try again')

        wtfDir = input('path to wtf: ')
        if wtfDir == '0':
            pass
        elif os.path.exists(wtfDir):
            btext.success('input accepted!')
            btext.info('returning to main menu...')
            dirData[1] = (wtfDir)
            time.sleep(3)
        else:
            btext.warning('your input seems to be invalid, please try again')
            btext.info('returning to main menu...')
            time.sleep(3)

        with open('./InterfaceSwitcher/dir.txt', 'w') as file:
            file.writelines(dirData)

        drawMainMenu()

    elif choice == '2':
        clear()
        btext.info('are you sure you want to set interface 1 as active?')

        if input('y/n: ') == 'y':
            clear()
            btext.info('deleting current interface...')
            time.sleep(1)
            with open('./InterfaceSwitcher/dir.txt', 'r') as dirs:
                dirs = dirs.readlines()

            try:
                os.rmdir(dirs[0][:-1])
                os.rmdir(dirs[1])
                btext.success('interface deleted!')
            except os.error as e:
                btext.debug('Directory not deleted. Error: %s' % e)
                btext.warning('failed to delete interface')
                btext.warning('please try again!')
                time.sleep(1)
                drawMainMenu()

            btext.info('copying interface 1...')
            time.sleep(3)

            try:
                shutil.copytree('./InterfaceSwitcher/interface_1/interface',
                                dirs[0][:-1])
                shutil.copytree('./InterfaceSwitcher/interface_1/wtf', dirs[1])
                btext.success('interface copied!')
                time.sleep(1)
            except shutil.Error as e:
                btext.debug('Directory not copied. Error: %s' % e)
                btext.warning('failed to copy interface')
                btext.warning('please try again!')
                time.sleep(1)
                drawMainMenu()

            btext.success('new interface copied!')
            btext.info('returning to main menu...')
            time.sleep(1)

        drawMainMenu()

    elif choice == '3':
        clear()
        btext.info('are you sure you want to set interface 2 as active?')

        if input('y/n: ') == 'y':
            clear()
            btext.info('deleting current interface...')
            time.sleep(1)
            with open('./InterfaceSwitcher/dir.txt', 'r') as dirs:
                dirs = dirs.readlines()

            try:
                os.rmdir(dirs[0][:-1])
                os.rmdir(dirs[1])
                btext.success('interface deleted!')
            except os.error as e:
                btext.debug('Directory not deleted. Error: %s' % e)
                btext.warning('failed to delete interface')
                btext.warning('please try again!')
                time.sleep(1)
                drawMainMenu()

            btext.info('copying interface 1...')
            time.sleep(3)

            try:
                shutil.copytree('./InterfaceSwitcher/interface_2/interface',
                                dirs[0][:-1])
                shutil.copytree('./InterfaceSwitcher/interface_2/wtf', dirs[1])
                btext.success('interface copied!')
                time.sleep(1)
            except shutil.Error as e:
                btext.debug('Directory not copied. Error: %s' % e)
                btext.warning('failed to copy interface')
                btext.warning('please try again!')
                time.sleep(1)
                drawMainMenu()

            btext.success('new interface copied!')
            btext.info('returning to main menu...')
            time.sleep(1)

        drawMainMenu()
예제 #6
0
                time.sleep(1)
            except shutil.Error as e:
                btext.debug('Directory not copied. Error: %s' % e)
                btext.warning('failed to copy interface')
                btext.warning('please try again!')
                time.sleep(1)
                drawMainMenu()

            btext.success('new interface copied!')
            btext.info('returning to main menu...')
            time.sleep(1)

        drawMainMenu()


btext.info('Welcome to InterfaceSwitcher!')
btext.info('checking for IS directory...')
ISdir = './InterfaceSwitcher'

if os.path.exists(ISdir):
    btext.success('directorys found!')
    time.sleep(1)
    drawMainMenu()
else:
    btext.info('no directorys found, creating...')
    try:
        os.makedirs('./InterfaceSwitcher')
        os.makedirs('./InterfaceSwitcher/interface_1')
        os.makedirs('./InterfaceSwitcher/interface_1/interface')
        os.makedirs('./InterfaceSwitcher/interface_1/WTF')
        os.makedirs('./InterfaceSwitcher/interface_2')
예제 #7
0
async def on_ready():
    btext.info('Logged in as')
    btext.info('Name: ' + Fore.GREEN + bot.user.name)
    btext.info("ID: " + Fore.GREEN + bot.user.id)
    btext.info('________________________')
    btext.info(sys.platform)
    if sys.platform != "win32":
        await bot.change_presence(game=discord.Game(
            name='.info', url="https://twitch.tv/TheBloodyScreen", type=1))
        btext.success("game set successfully")
    else:
        await bot.change_presence(
            game=discord.Game(name='.info - indev',
                              url="https://twitch.tv/TheBloodyScreen",
                              type=1))
        btext.success("game set successfully")
    btext.success("connected successfully")
    btext.info('________________________')
예제 #8
0
def chat(joinMessage="true"):
    con = connect()
    game = 'not set yet'

    if joinMessage is None:
        btext.info("> No join message specified.")
    else:
        btext.info("> Join message: " + joinMessage)
        send("is here and ready to work!", True)

    while True:
        message = con.recv(1024).decode().split(" ")
        username = "******"
        chatmsg = "twitch"

        if message[0] == "PING":
            pong()
            btext.info("Pong!")
        elif message[0] != ":tmi.twitch.tv":
            try:
                username = message[0][1:int(message[0].index("!"))]
                message[3] = message[3].replace(":", "")
                chatmsg = " ".join(message[3:])
                logging.info((username + ": " + chatmsg.rstrip()))
            except:
                exit()

        if chatmsg.startswith("!social"):
            send("You can find me on the following social media sites:")
            send("Player.me: https://thebloodyscreen.com/player.me")
            send("Twitter: https://thebloodyscreen.com/twitter")
            send("Discord: https://thebloodyscreen.com/discord")

        elif chatmsg.startswith("!link"):
            send("You should checkout this wonderful person:")
            send("http://twitch.tv/" + chatmsg[6:])

        elif chatmsg.startswith('!timeout'):
            if check_mod(username) is True:
                if chatmsg[1]:
                    send(".timeout " + chatmsg.split(" ")[1] +
                         chatmsg.split(" ")[2])
                else:
                    send(
                        "There seems to be something wrong with your command. SYNTAX: !timeout username amount"
                    )
            elif check_mod(username) is False:
                send("You do not have access to this command!")

        elif chatmsg.lower().startswith("am i important?"):
            if check_mod(username) is True:
                send("Well you're a mod, I'll let you be the judge!")
            elif check_mod(username) is False:
                send("Every viewer is important!")

        elif chatmsg.startswith('!setgame'):
            game = chatmsg[8:]

        elif chatmsg.startswith('!game'):
            send(game)

        elif chatmsg.startswith('!humble'):
            send('I am lucky enough to call myself a Humble Partner.')
            send(
                'If you want to support me please consider using my humble link for buying games:'
            )
            send('https://www.thebloodyscreen.com/humble')

        elif chatmsg.startswith('!monthly'):
            send('You can always find the current Humble Monthly at:')
            send('https://www.thebloodyscreen.com/monthly')

        elif chatmsg.startswith('!bundle'):
            send('Here you can find the current humble bundle:')
            send(config['twitch']['currentBundle'])

        elif chatmsg.startswith('!test'):
            s_nouns = [
                "A dude", "My mom", "The king", "Some guy",
                "A cat with rabies", "A sloth", "Your homie",
                "This cool guy my gardener met yesterday", "Superman"
            ]
            p_nouns = [
                "These dudes", "Both of my moms", "All the kings of the world",
                "Some guys", "All of a cattery's cats",
                "The multitude of sloths living under your bed", "Your homies",
                "Like, these, like, all these people", "Supermen"
            ]
            s_verbs = [
                "eats", "kicks", "gives", "treats", "meets with", "creates",
                "hacks", "configures", "spies on", "retards", "meows on",
                "flees from", "tries to automate", "explodes"
            ]
            p_verbs = [
                "eat", "kick", "give", "treat", "meet with", "create", "hack",
                "configure", "spy on", "retard", "meow on", "flee from",
                "try to automate", "explode"
            ]
            infinitives = [
                "to make a pie.", "for no apparent reason.",
                "because the sky is green.", "for a disease.",
                "to be able to make toast explode.",
                "to know more about archeology."
            ]
            while True:
                message = (random.choice(s_nouns) + ' ' +
                           (random.choice(s_verbs) + ' ' +
                            random.choice(s_nouns).lower())
                           or (random.choice(p_verbs) + ' ' +
                               random.choice(p_nouns).lower()) + ' ' +
                           random.choice(infinitives))
                send(message)
예제 #9
0
def pong():
    construct = "PONG :tmi.twitch.tv\r\n"
    s.send(construct.encode())
    btext.info("PONG!")
예제 #10
0
import yaml
import yaml.scanner
from bloodyterminal import btext

config = dict()

try:
    with open("config/config.yml", "r") as f:
        try:
            btext.info('Loading config.yml')
            config = yaml.safe_load(f) or {}
            btext.success('config.yml loaded successfully!')

        except yaml.scanner.ScannerError as e:
            raise Exception(
                "Configuration file at 'config/config.yml' contains invalid YAML..."
            )

        except Exception as e:
            print(type(e))

except FileNotFoundError as e:
    raise Exception("Configuration file not found at: 'config/config.yml'...")