def __init__(self, num_layers, num_nodes, direction="unidirectional", batch_size=None, input_dim=None, input_depth=None, act='linear', keep_prob=1.0, var=False, lengths=None, weights_init=tf.truncated_normal_initializer(stddev=0.01), bias_init=tf.constant_initializer(0.0), training=True, name="lstm"): self.name = name Module.__init__(self) self.batch_size = batch_size self.input_dim = input_dim self.input_depth = input_depth self.num_layers = num_layers self.num_nodes = num_nodes self.direction = direction self.act = act self.dropout = 1.0 - keep_prob self.var = var self.lengths = lengths self.weights_init = weights_init self.bias_init = bias_init self.training = training
def __init__(self, domain: Domain = None, subgraph: dict = None, logger : DiasysLogger = DiasysLogger()): Module.__init__(self, domain, subgraph, logger = logger) self.initial_turn = True self.description = '' init_gui() self.dialogs = 0
def handle(self, content): Module.handle(self, content) sended = json.loads(session.get(self._sended_news_key, "[]")) to_send = None attempts = 0 while not to_send: try: new = self._get_new() except Exception: pass if new: to_send_hash = hashlib.md5(new["link"].encode()).hexdigest() if to_send_hash not in sended: to_send = new sended.append(to_send_hash) attempts = attempts + 1 if attempts >= self._max_attempts: break if to_send: session[self._sended_news_key] = json.dumps(sended) self._enqueue_response(to_send["title"]) self._enqueue_response(to_send["link"]) else: self._enqueue_response(self._content["not_found"]) self._enqueue_response(self._content["exit"]) self._send()
def __init__(self, output_dim, batch_size=None, input_dim=None, act='linear', batch_norm=False, batch_norm_params={ 'momentum': 0.9, 'epsilon': 1e-5, 'training': False, 'name': 'bn' }, keep_prob=tf.constant(1.0), weights_init=tf.truncated_normal_initializer(stddev=0.01), bias_init=tf.constant_initializer(0.0), name="linear"): self.name = name Module.__init__(self) self.input_dim = input_dim self.output_dim = output_dim self.batch_size = batch_size self.act = act self.batch_norm = batch_norm self.batch_norm_params = batch_norm_params self.keep_prob = keep_prob self.weights_init = weights_init self.bias_init = bias_init
def __init__(self, client): Module.__init__(self, client) reddit = self.reddit = praw.Reddit( client_id=assert_type( Config.get_module_setting('reddit', 'client_id'), str), client_secret=assert_type( Config.get_module_setting('reddit', 'client_secret'), str), user_agent=assert_type(Config.get_module_setting('reddit', 'ua'), str), username=assert_type( Config.get_module_setting('reddit', 'username'), str), password=assert_type( Config.get_module_setting('reddit', 'password'), str)) self.subreddit_name = assert_type( Config.get_module_setting('reddit', 'subreddit'), str) self.subreddit = reddit.subreddit(self.subreddit_name) self.post_stream = None self.comment_stream = None self.live_stream = None self.live = None self.ready_to_stop = False self.post_announcer, self.comment_announcer, self.live_announcer = self.create_announcers( NewPostAnnouncer, NewCommentAnnouncer, NewUpdateAnnouncer)
def handle(self, content): Module.handle(self, content) if content == self._content["exit"]["text"]: session.clear() self._enqueue_response(self._content["exit"]["response"]) self._send()
def __init__(self, output_depth, batch_size = None, input_dim = None, input_depth=None, kernel_size=5, stride_size=1, act = 'linear', keep_prob=1.0, pad = 'SAME', weights_init= tf.truncated_normal_initializer(stddev=0.05), bias_init= tf.constant_initializer(0.05), name="conv2d", param_dir=None, init_DH=False): self.name = name #self.input_tensor = input_tensor Module.__init__(self) #comment (it's done in fwd pass) self.batch_size = batch_size self.input_dim = input_dim self.input_depth = input_depth self.output_depth = output_depth self.kernel_size = kernel_size self.stride_size = stride_size self.act = act self.keep_prob = keep_prob self.pad = pad self.weights_init = weights_init self.bias_init = bias_init #path to stored weights and biases self.param_dir = param_dir self.init_DH = init_DH
def handle_messages(number, content): sender = Sender(number) MENU = Module.get_contents()[menu_cookie_key] if content in [ i["text"] for i in Module.get_contents()["modules"]["Command"].values() ]: # A command was received. module = Command(sender, number) module.handle(content) return if menu_cookie_key in session: # The user was on a feature. if content != exit_menu_message: option = session[menu_cookie_key] run_module(sender, MENU, option, number, content) return course = Course(sender, number) course.clear() session.pop(menu_cookie_key) # The user wasn't in any feature. module = Welcome(sender, number) has_option = module.handle(content, MENU) if has_option: run_module(sender, MENU, content, number, None)
def __init__(self): Module.__init__(self) self.module_name = "Module: Aura" self.box_name = "In box: History" self.box_content = "Not found" self.aura_says = "Did you call me?" self.user_hint = "" self.commands_list = { "add": "add <question> = <answer 1> = <answer 2> ...", "del": "del - delete last answer", "say": "say <message for dubbing>", } self._true_box = [] self._num_box = dict(enumerate(self._true_box)) self._casper_main = j.j_move(name="CASPER") self._casper = self._casper_main.copy() self._history = [""] #self._history = [""] + ["123"]*22 # lengh test self._last_question = None self.last_add = None self.treads = []
def __init__(self, client): Module.__init__(self, client) self.users = Users(self) self.invites = None self.track_messages = Config.get_module_setting('usertracking', 'track_messages', True) self.tracking_exceptions = Config.get_module_setting('usertracking', 'tracking_exceptions', []) self.module_time_start = time.time() self.member_status_time_start = {} self.track_statuses = Config.get_module_setting('usertracking', 'track_statuses', True) self.audit_log_entries = {} self.level_cooldowns = {} self.level_cooldown = assert_type(Config.get_module_setting('usertracking', 'level_cooldown'), int, otherwise=5) self.level_cap = assert_type(Config.get_module_setting('usertracking', 'level_cap'), int, otherwise=-1) self.leveling_exceptions = Config.get_module_setting('usertracking', 'leveling_exceptions', []) self.allow_user_leveling = Config.get_module_setting('usertracking', 'allow_user_leveling', True) self.allow_user_rewards = Config.get_module_setting('usertracking', 'allow_user_rewards', True) self.allow_bot_leveling = Config.get_module_setting('usertracking', 'allow_bot_leveling', False) self.allow_bot_rewards = Config.get_module_setting('usertracking', 'allow_bot_rewards', False) self.allow_mod_leveling = Config.get_module_setting('usertracking', 'allow_mod_leveling', True) self.allow_mod_rewards = Config.get_module_setting('usertracking', 'allow_mod_rewards', False) self.regular_role = discord.utils.get(client.focused_guild.roles, id=Config.get_module_setting('usertracking', 'regular_role_id')) self.spam_channel = Config.get_module_setting('usertracking', 'spam_channel') self.log_channel = Config.get_module_setting('usertracking', 'log_channel')
def __init__(self, output_dim, batch_size=None, input_dim=None, act='linear', keep_prob=tf.constant(1.0), weights_init=tf.truncated_normal_initializer(stddev=0.05), bias_init=tf.constant_initializer(0.05), name="linear", param_dir=None, use_dropout=False, init_DH=False): self.name = name #Se crea un objeto Module de module.py, el que lleva el conteo de las capas presentes #y un preset a las variables usadas por LRP en cada capa Module.__init__(self) self.input_dim = input_dim self.output_dim = output_dim self.batch_size = batch_size self.act = act self.keep_prob = keep_prob self.use_dropout = use_dropout self.weights_init = weights_init self.bias_init = bias_init #path to stored weights and biases self.param_dir = param_dir self.init_DH = init_DH
def __init__(self): Module.__init__(self) self.module_name = "Module: Main" self.box_name = "In box: Commands" self.box_content = "Not found" self.aura_says = "Welcome to Aura Terminal!" self.user_hint = "" self.theme_list = j.j_move(name="CONFIG") self.theme_active = "{0}\\{1}.png".format(j.path["IMAGES"], self.theme_list["theme"]) self.commands_list = { "aura": "aura - conversation module", # other module "path": "path - shortcut access module", # other module "note": "note - module for notes", # other module "slk": "slk - file manager", # other module "tool": "tool - module useful scripts", # other module "game": "game - pseudographic games", # other module "open": "open <name item in aura scope>", "play": "play <selekt name>", "assistant": "assistant - voice assistant", # other module #"voice off":"voice off - turn off voice input", # other module "view": "view - program statistics", "manual": "manual - open full manual about program", "theme": "theme - switch theme", } self._true_box = self.commands_list.keys() self.set_box() self.box_content = """Modules:
def __init__(self, client): Module.__init__(self, client) self.interaction = Config.get_module_setting('notifyMe', 'interaction') self.available_roles = {} self.refresh_available_roles()
def __init__(self, domain: Domain = None, subgraph: dict = None, logger: DiasysLogger = DiasysLogger(), language: Language = None): Module.__init__(self, domain, subgraph, logger=logger) # independent of the domain self.language = language
def __init__(self, client): Module.__init__(self, 'GameTracker', client) # mongo setup self.dbclient = pymongo.MongoClient('localhost', 27017) self.db = self.dbclient['botdooder'] self.sessions = self.db['sessions'] self.game_states = defaultdict(lambda: {'game': None, 'time': None})
def __init__(self, pool_size=2, pool_stride=None, pad = 'SAME',name='avgpool'): self.name = name Module.__init__(self) self.pool_size = pool_size self.pool_kernel = [1]+[self.pool_size, self.pool_size]+[1] self.pool_stride = pool_stride if self.pool_stride is None: self.stride_size=self.pool_size self.pool_stride=[1, self.stride_size, self.stride_size, 1] self.pad = pad
def __init__(self, modules): ''' Constructor Parameters ---------- modules : list, tuple, etc. enumerable. an enumerable collection of instances of class Module ''' Module.__init__(self) self.modules = modules
def handle(self, content): Module.handle(self, content) if not content: self._enqueue_response(self._content["introduction"]) self._enqueue_response_media( self._get_static_file(self._content["image"], self.NAME)) for content in self._content["contents"]: self._enqueue_response(content) self._enqueue_response(self._content["exit"]) self._send()
def __init__(self, client): Module.__init__(self, client) self.contest_name = 'Emoji Contest' self.uploads = database.create_section( self, 'julcontest2019', { 'user': [database.INT, database.PRIMARY_KEY], 'uploads': database.INT, }) self.channel = Config.get_module_setting('contest', 'channel') self.channel_name = None self.p1 = discord.utils.get(client.focused_guild.emojis, name='p1')
def __init__(self, client): Module.__init__(self, client) self.contest_name = 'House Contest' self.uploads = database.create_section( self, 'deccontest2018', { 'user': [database.INT, database.PRIMARY_KEY], 'uploads': database.INT, 'reaction_end_time': database.INT, 'reaction_message_id': database.INT }) self.channel = Config.get_module_setting('contest', 'channel') self.scheduled_reactions = [] self.p1 = discord.utils.get(client.focused_guild.emojis, name='moo')
def __init__(self, rotation_num = 4, batch_size = None, input_dim = None, input_depth=None, name="rotation", param_dir=None, epsilon = 1e-3, decay = 0.5): self.name = name #self.input_tensor = input_tensor Module.__init__(self) #comment (it's done in fwd pass) self.batch_size = batch_size self.input_dim = input_dim self.input_depth = input_depth self.rotation_num = rotation_num
def __init__(self): Module.__init__(self) self.module_name = "Module: Conductor" self.box_name = "In box: Links" self.box_content = "Not found" self.aura_says = "Conductor connected, commands available." self.user_hint = "" self.commands_list = { "add": "add [name] <path/to/file>", "del": "del <name> or <number>" } self._conductor = j.j_move(name="CONDUCTOR") self.set_box(list(self._conductor)) self.set_box_string()
def handle(self, content): Module.handle(self, content) current_module = session.get(self._current_module_key, None) if not current_module: if content is None: self._welcome() elif content not in ["1", "2"]: self._enqueue_generic(self._content["menu"]) else: self._run_module(content, current_module) else: self._run_module(content, current_module) self._send()
def __init__(self): Module.__init__(self) self.module_name = "Module: Notebook" self.box_name = "In box: Lists" self.box_content = "Not found" self.aura_says = "Did you call me?" self.user_hint = "" self.commands_list = { "add": "add <note name>", "del": "del <note name> or <number>", "print": "print is not released", "archive": "archive is not released" } self.set_box(listdir(j.path["NOTEBOOK"])) self.NOTEBOOK = j.path["NOTEBOOK"]
def __init__(self, client): Module.__init__(self, client) reddit = self.reddit = praw.Reddit( client_id=Config.getModuleSetting('reddit', 'clientID'), client_secret=Config.getModuleSetting('reddit', 'clientSecret'), user_agent=Config.getModuleSetting('reddit', 'ua'), username=Config.getModuleSetting('reddit', 'username'), password=Config.getModuleSetting('reddit', 'password') ) self.subredditName = Config.getModuleSetting('reddit', 'subreddit') self.focused_guild = reddit.subreddit(self.subredditName) self.toonfestStream = threading.Thread(target=self.streamPosts, name='ToonfestStream-Thread').start() self.readyToStop = False
def extract_module_data(product_data, module_data, selected_leds): for module in module_data: model = module["Model"] seller = "Samsung" model_index = module["ModelIndex"] led = module["InstalledLed"] if led not in selected_leds: continue parallel_count = int(float(module["ParallelNumber"])) series_count = int(float(module["seriesNumber"])) dimensions = extract_dimensions(module["Size"]) versions = [] yield Module(model, seller, led, parallel_count, series_count, dimensions, versions) for product in product_data: if product["ModelIndex"] != model_index: continue product_code = product["ProductCode"] cct = int(float(product["CCT"])) cri = int(float(product["CRI"])) versions.append( Version(product_code, cct, cri))
def __init__(self): Module.__init__(self) self.module_name = 'Module: Selektor' self.box_name = 'In box: Directories' self.box_content = 'Not found' self.aura_says = 'Selektor connected, commands available.' self.commands_list_bot = { 'add': 'add [name] <path/to/dir>', 'del': 'del <name> or <number>', 'dir': 'dir <name selekt> - to open dirrectory', 'ignore': 'ignore - show ignore list' } self.commands_list_middle = { "tg": "tg <search tag 1 > <search tag 2> ...", "nm": "nm <part of the name>", "add": "add <tag 1> <tag 2> ...", "del": "del <tag 1> <tag 2> ...", "tags": "tags - show tags for this selekt", "new": "new - show raw files", "r": "r - open random file", } self.commands_list_ignore = { "add": "add <ignor word>", "del": "del <ignore word> or <number>" } self.commands_list = self.commands_list_bot self._selektor = j.j_move(name='SELEKTOR') self._tags = j.j_move(name='TAGS') self._ignorelist = j.j_move(name='IGNORE') self._taglist = set() self.set_box(list(self._selektor)) self.set_box_string() self._scene = 'bot' self._files = [] self._dirs = {} self._names = {} self._selekt_name = None self._active_file = None self._active_file_name = None self._last_message = None
def __init__(self, rotation_num=4, batch_size=None, input_dim=None, input_depth=None, name="cyclic_avgPool"): self.name = name #self.input_tensor = input_tensor Module.__init__(self) #comment (it's done in fwd pass) self.batch_size = batch_size self.input_dim = input_dim self.input_depth = input_depth self.rotation_num = rotation_num
def __init__(self, client): Module.__init__(self, client) discord_emojis = Config.get_module_setting('suggest', 'discord_emojis', otherwise=[]) custom_emojis = [ discord.utils.get(client.focused_guild.emojis, name=e) for e in Config.get_module_setting('suggest', 'custom_emojis', otherwise=[]) ] self.emojis = discord_emojis + custom_emojis if self.emojis.count(None): print( '{} custom emoji(s) used for suggestions could not be found on the server.' ).format(self.emojis.count(None)) self.interaction_channel = Config.get_module_setting( 'suggest', 'interaction')
def handle(self, content): Module.handle(self, content) index = session.get(self._last_message_key, 0) index = index + 1 messages = self._content["messages"] m = messages[index % len(messages)] self._enqueue_response(m["text"]) self._enqueue_response_media( self._get_static_file(m["image"], self.NAME)) self._enqueue_response(self._content["source"]) session[self._last_message_key] = index self._enqueue_response(self._content["exit"]) self._send()
def handle(self, content, menu): Module.handle(self, content) if self._cookie_key in session: for item in menu: if item["option"] == content: return True self._enqueue_response(self._content["ask_again"]) else: self._enqueue_response(self._content["welcome_message"]) session[self._cookie_key] = True menu_text = "\n".join( [f'{item["option"]} - {item["text"]}' for item in menu]) self._enqueue_response(menu_text) self._enqueue_response(self._content["how_to_response"]) self._send() return False
def __init__(self, client): Module.__init__(self, 'PredictGame', client) # set the api key using the config api.set_api_key(config['steamApi']) # initialize the predictions field self.predictions = defaultdict(lambda: {'predictions': {}, 'info': None}) # cached league names self.league_cache = {} # mongo setup self.dbclient = pymongo.MongoClient('localhost', 27017) self.db = self.dbclient['botdooder'] self.fredpoints = self.db['fredpoints'] # default channel self.default_channel = None # start the 60 second status check loop self.client.loop.create_task(self.check_game_status())
def __init__(self, client): Module.__init__(self, 'DiceRoller', client)
def _init_module(self): """ Initialize module class when it's needed by pymem. """ self.module = Module()
class Pymem(object): """Provides class instance methods for general process and memory manipulations. """ def __init__(self): """ Initialize pymem objects """ self.process = None self.memory = None self.module = None self.pid = None # refractor self.process32 = None # refractor self.process_handle = None def _init_process(self): """ Initialize process class when it's needed by pymem. """ self.process = Process() def _init_memory(self): """ Initialize memory class when it's needed by pymem. """ self.memory = Memory() def _init_module(self): """ Initialize module class when it's needed by pymem. """ self.module = Module() @is_init('process') def open_process(self, process_id, debug=True): """ Opens a process for interaction. """ if debug: if self.process.open_debug(process_id): self.process_handle = self.process.h_process self.pid = process_id self.process32 = self.process.process32 return True return False return self.process.open(process_id) @is_init('process') def open_process_from_name(self, process_name, debug=True, number=0): """ Opens a process from its name for interaction. """ processes = process_from_name(process_name) if processes is not None: if len(processes) - 1 == number: process = processes[len(processes) - 1] return self.open_process(process.th32ProcessID, debug) return False @is_init('memory') def read_offset(self, address, selected_type): """ Read memory from a process. If the type <T> is supported, this method will provide the required call in order to read, from the process. If either the type <T> is not supported or process is not Open, the method will raise an Exception. Supported types : float, int, uint, long, ulong, int64, uint64, byte """ if self.process.is_process_open: if self.memory.is_process_set == False: self.memory.set_process(self.process.h_process) return self.memory.read_offset(address, selected_type) return False @is_init('module') def list_module32(self): """ Return module (MODULEENTRY32) loaded by current process. """ if self.process32 is not None: if self.module.is_process_set == False: self.module.set_process32(self.process32) return self.module.list_module32() return [] @is_init('module') def has_module32(self, module): """ Return True if current process has loaded given module (dll) """ if self.process32 is not None: if self.module.is_process_set == False: self.module.set_process32(self.process32) return self.module.has_module32(module) return False