Log in

View Full Version : An intricate and wonderful machine, the code has been leaked.


Silicate Wielder
January 8th, 2015, 10:59 PM
So I got bored one day and started developing an IRC client in Python, what was first a simple initiation code, turned into a huge complicated ball of words and computer gibberish, that does absolutely nothing but terminate itself and throw out errors if you select invalid options on the menus, I have yet to actually give it a proper purpose.
(I tried GUI programming, but it doesn't seem to like me too well. :P)

My computer also tends to carry over text formatting so this may or may not have the markup from my Python IDE.

EDIT: It appears formatting issues were created when I pasted.

# Main script for PyRC
# Begin importing modules.
import os
import time
import platform
import sys
import fcntl
import termios
import struct
import multiprocessing
# Finish importing modules.
class module_e:
console_active = True
command = 'NAN'
def disableitem(command):
while command in system_var.commands:
system_var.commands.remove(command)

@staticmethod
def __init__():
module_c.clear()
module_a.title()
print module_c.center('Welcome to the developer mode! You can change \
the settings and use hacks here!')
print ''
module_e.console_active = True
def console():
if module_e.console_active is True:
commmand = raw_input('Command: ')
if module_e.command.lower() == 'enable omegle':
system_var.commands.append('092B')
elif module_e.command.lower() == 'disable omegle':
module_e.disableitem('omegle')
elif module_e.command.lower() == 'exit':
console_active = False
console()
elif module_e.console_active is False:
module_c.setstatus(3)

class module_d: # Commands for IRC mode
@staticmethod
def initialize(mode):
if mode == 'irc':
if system_var.port == 'NAN':
print "Prepairing to connect to " + system_var.server
else:
print "Prepairing to connect to " + system_var.server + ' on port ' + system_var.port
multiprocessing.Process(target=mode)
else:
module_c.setstatus(2)

@staticmethod
def setport():
try:
system_var.port = raw_input('Enter port for server, must be an integer: ')
system_var.port = int(system_var.port)
except ValueError:
print 'ERROR: You have not entered an integer, please enter an integer value'
time.sleep(5)
module_c.clear()
module_d.setport()

@staticmethod
def __init__():
module_c.clear()
system_var.server = raw_input('Enter URL of IRC server:')
system_var.temp = raw_input('Would you like to manually specify the port? [Y/N]: ')
if isinstance(system_var.temp, int) is True:
if system_var == 'y' or 'Y':
module_d.setport()
elif system_var.temp.lower() == 'n' or 'N':
module_d.initialize('irc')
module_c.clear()
else:
system_var.temp = False
module_c.setstatus(4)
else:
module_c.setstatus(4)


class module_c:
@staticmethod
def __init__():
print "Module C Initialized!"
@staticmethod
def clear():
if system_var.operating_system == 'Linux':
os.system('clear')
elif system_var.operating_system == 'windows' or 'OSX':
os.system('cls')
else:
module_c.setstatus(1)

@staticmethod
def center(text):
width = module_b.get_terminal_size("width")
return text.center(width, " ")

@staticmethod
def detectos(mode):
if mode.lower() == "name":
return os.name
elif mode.lower() == "type":
return platform.system()
else:
return "INVALID DETECTION MODE"
@staticmethod
def checkossupport():
if system_var.operating_system == "Linux" or "Windows":
return True
else:
return False # Extras
@staticmethod
def setstatus(mode):
if isinstance(mode, int) is True:
try:
# First we check if the entry is available
system_var.exitstatus = system_var.errortypes[mode][0]

'''If the entry is available, and if a red flag is not raised we
test for and check the value of item 2 in the error entry. If it
is True of False we execute accordingly.'''
print 'should I terminate? ' + str(system_var.errortypes[mode][1])
if str(system_var.errortypes[mode][1]) is True:
module_a.terminate(True)
elif str(system_var.errortypes[mode][1]) is False:
module_a.terminate(False)
else:
print system_var.errortypes[mode][1]
print "Despite being aware of the error, we do not know if it is safe to proceed because of an" \
"unkown bug, please send in a bug report."
'''Use a series of two sets of two digits, seperated by a dash starting at '00-00'
systemvar.exitstatus = 'SYSTEM EXITED (Code: 00-00)' # Everything is fine here, nothing went wrong
and the house is still standing.'''
except IndexError:
print 'We cant figure out the error...'
print 'perhaps a fly snuck inside our wonderful machine'
print 'Unknown Error(XX-XX)'
exit()


class module_b:

@staticmethod
def __init__():
print "Console Functions Ready!"
@staticmethod
def get_terminal_size(dimension):
env = os.environ

def ioctl_gwinsz(fd):
try:
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,
'1234'))
except:
return
return cr
cr = ioctl_gwinsz(0) or ioctl_gwinsz(1) or ioctl_gwinsz(2)
if not cr:
try:
fd = os.open(os.ctermid(), os.O_RDONLY)
cr = ioctl_gwinsz(fd)
os.close(fd)
except:
pass
if not cr:
cr = (env.get('LINES', 25), env.get('COLUMNS', 80))

if dimension.lower() == "width":
return int(cr[1])
elif dimension.lower() == "height":
return int(cr[0])
elif dimension.lower() == "both" or "":
return int(cr[1]), int(cr[0])
else:
return 0,0


class module_a:
@staticmethod
def __init__():
print "Module C loaded!"
@staticmethod
def title():
module_c.clear()
print module_c.center(system_var.title)
print ""
@staticmethod
def terminate(mode):
if mode is True or False:
if mode is True:
exit()
else:
print 'Error: A command has reported an un-identifiable Error ID \
value, the program will terminate as a safety precaution\n\
(CODE: 99-99)'
class system_var:
title = 'PyRC'
version = '0.01'
codename = 'Beta'
author = 'Clockwork'
source = '[UNDEFINED]' # to be defined with URL to main site or download when first released
operating_name = 'UNKNOWN'
operating_system = 'UNKNOWN'
blank = ''
exitstatus = 'UNDEFINED'
supported = False

server = 'NAN'
port = 'NAN'
errortypes = [
['SYSTEM EXITED\n(CODE: 00-00)', False],
['SYSTEM ERROR: Operating System is not supported.\n(CODE: 00-01)', False],
['SYSTEM ERROR: Invalid Operating Mode\n(CODE: 00-02)', True],
['SYSTEM ERROR: Admin console mode has malfunctioned\n(CODE: 00-03)', False],
['ERROR: User inputer is not valid, please type either "Y" (Yes) or "N" (No)', False]
]

commands = [
'092A',
'092B'
]


class initialize:

@staticmethod
def __init__():
system_var.operating_name = module_c.detectos('name')
system_var.operating_system = module_c.detectos('type')
print 'Running on ' + system_var.operating_name + ' (' + system_var.operating_system + ')'
system_var.supported = module_c.checkossupport()

if system_var.supported == False:
print "Sorry! it seems I do not know how to handle protocols on this OS, it is not supported."
print "I am sorry about this inconvenience."
sys.exit()
else:
time.sleep(0.1)
module_c.clear()
print module_c.center("Loaded " + system_var.title + system_var.version + ": " + system_var.codename + "...")
time.sleep(1)
module_c.clear()

def selectmode():
module_a.title()
print "Pick a mode:"
print "1.) IRC Client"
modecache = raw_input('#:')

if modecache == '6a4461c' and '092A' in system_var.commands:
initmode = 99091
else:
try:
initmode = int(modecache)
except ValueError:
print "ERROR: Selection is not an integer"
time.sleep(5)
module_c.clear()
initmode = None
selectmode()

if isinstance(initmode, int) is True:
if initmode == 1:
module_d.__init__()
if initmode == 99091:
module_e.__init__()
else:
print "ERROR: Selection not listed or available"
time.sleep(5)
module_c.clear()
selectmode()
selectmode()

module_c.setstatus(0)

#End of Program
initialize.__init__()