def prepare_data(result): jj = json.loads(result) last_update = int(time.time()) for i in jj["items"]: values = dict() values["question_id"] = i["question_id"] values["title"] = i["title"] values["owner_name"] = i["owner"]["display_name"] values["score"] = i["score"] values["creation_date"] = i["creation_date"] values["link"] = i["link"] values["is_answered"] = i["is_answered"] values["last_update"] = last_update data.create(values)
def follow(username, message, privileges): if message == "!follow": user = data.get_element(username, main_users) if user is not None: user_privileges = int(user[eUser.privileges]) else: user_privileges = 0 if user_privileges >= privileges: if not data.has(main_channel_list, "#"+username): try: os.mkdir(config.PATH+"channel/"+"#"+username) os.mkdir(config.PATH+"channel/"+"#"+username+"/bank") files = [ {"file_name" : "quotes.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""}, {"file_name" : "guards.csv", "file_path" : config.PATH+"channel/#"+username+"/bank/", "file_data" : "Karl;20\nMark;50\nLisa;40\n"}, {"file_name" : "whitelist.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : "bot_omb\nnightbot\ntipeeebot\nwizebot\nmikuia\nmoobot\n"}, {"file_name" : "commands.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""}, {"file_name" : "announcements.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""}, {"file_name" : "greetings.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""}, {"file_name" : "settings.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : "language_chat;english\nwarning_url;False\nwarning_caps;False\nwarning_long_text;False\ngreetings;False\ngreetings_interval;60\ncommand_mode;True\nbet_mode;True\nfollow_mode;True\nannounce_mode;True\nsmm_mode;True\npoll_mode;True\nrank_mode;True\nbank_mode;True\nwhitelist_mode;True\nwatchtime_mode;False\nquote_mode;False\nhelp;0\ncoins;0\ncommand_add;99\ncommand_remove;99\ncommand_show;99\nprivileges;99\nsetting;99\nsetting_show;99\nurl;99\nbet;0\nbet_start;99\nbet_stop;99\nbet_reset;99\nfollow;0\nfollow_member;0\nfollow_member_other;99\nunfollow;0\ninfo;0\nannounce_add;99\nannounce_remove;99\nannounce_show;99\nsmm_level_submit;99\nsmm_level_submit_other;99\nsmm_level_show;99\nsmm_level_next;99\npoll_start;99\npoll_vote;99\npoll_result;99\nlanguage;99\nupsince;0\nrank_add;99\nrank_remove;99\nrank_show;99\nrank_show_me;0\nbank_robbery;99\nbank_spy;99\nbank_robbery_flee;99\nbank_guard_add;99\nbank_guard_remove;99\nbank_guard_show;99\nwhitelist_add;99\nwhitelist_remove;99\nwhitelist_show;99\nclam_ask;99\nroulette;99\nwatchtime_me;99\nhug_random;99\nhug_other;99\nquote_add;99\nquote_remove;99\nquote_show;99\n"}, {"file_name" : "users.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : username+";100;100;False;0;0;0\n"}, {"file_name" : "ranks.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""} ] data.create(files) main_channel_list.append(["#"+username]) data.save(config.PATH+"channel/channel.csv", main_channel_list) except OSError: main_whisper.whisper(username, "Something went wrong. Please contact a Bot_Omb developer!") new_bot_thread = Bot_Omb(["#"+username]) new_bot_thread.setName("#"+username) new_bot_thread.setDaemon(True) bot_threads.append(new_bot_thread) new_bot_thread.start() main_whisper.whisper(username, "I joined your stream! If you want to use my full power, you just need to make me a Mod. Otherwise the auto moderation function will not work.") else: main_whisper.whisper(username, "I already joined your Chat!") else: main_whisper.whisper(username, "Your privileges level is not high enough to perform this command! You need at least a level of {0}.".format(privileges))
def load(this, store=['subject', 'channels', 'units', 'sampling'], **data): find = default(data) tell = find(True, 'verbose') if this.hasnt('start'): this.open(verbose=tell) if this.has('start', 'sampling', 'time', 'channels'): start = find(this.time[0], 'start', 'at') end = find(this.time[1], 'end') gap = find(None, 'time', 'span') use = find(float32, 'type') if type(start) is time: start = this.time[0] + start init = start - this.time[0] if gap and type(gap) is time: end = start + gap if end > this.time[1]: end = this.time[1] gap = end - start init = int(init.seconds * this.sampling) + this.start[1] ticks = int(gap.seconds * this.sampling) channels = len(this.channels) with open(this.file, 'r') as file: if tell: print 'seeking record start...', this._seek(file, init) if tell: print 'done\nreading lines...', lines = [[0] * channels] last = lines[-1] while ticks: line = file.readline() if line == '': break line = array([t for t in line.split('\t') if t != 'OFF'][2:-1]) if len(line) == channels: line[line == 'SHORT'] = nan line[line == 'AMPSAT'] = nan if nan in line: to = correct = line.tolist() while nan in correct: position = to.index(nan) correct[position] = last[position] line = array(correct) lines.append(line.astype(use)) last = lines[-1] ticks -= 1 if tell: print 'done' data = create(record(lines[1:]).T, template=this, start=start, end=end, gap=ticks / this.sampling) data.clear(*list(this.sets - set(store))) return data elif tell: print 'invalid source!'
def run(): count = 0 datas = [] stack = [ltn.search.by_keyword(topic)] file_name = data.create(topic, headers) while stack: print('進行中!!!!') result = stack.pop() for row in result.rows: report = ltn.content.get_report(row.link) datas.append([report.title, report.description, report.date, row.link]) if result.has_next(): stack.append(result.next()) if len(datas) > 10: data.store(file_name, datas) datas = [] count+=1 print('本頁完成! 已完成: {}頁, 下頁即將開始...'.format(count)) time.sleep(3) print('任務完成!!!')
def config(): """ The main driver for a configuration session. Prompts the user for all information required to send e-mail through whatever smtp service they choose to use. """ user_data = data.create() print 11 * '-' print "Email Setup" print 11 * '-' user_data.username = raw_input("Please enter your email username: "******"SMTP Server address: ") user_data.smtp_port = get_smtp_port() user_data.tls = get_y_n("Use TLS? (Y/N): ") user_data.ssl = get_y_n("Use SSL? (Y/N): ") logging.info("Saving user data.") try: data.save(user_data) except IOError: logging.error("Could not save data to file.") print "Could not save data to file. Please make sure your storage device is working and try again."
upload = bottle.request.files.get('scan') name, ext = os.path.splitext(upload.filename) if ext != '.xml': return "Please upload an XML nmap scan" else: path = "scans" if not os.path.exists(path): os.makedirs(path) file_path = "{path}/{file}".format(path=path, file='scan' + str(scancount) + '.xml') upload.save(file_path) scancount += 1 scan.scan(file_path, {'target': False, 'scan': True}) if "--h" in sys.argv: out = """Bullwark is a cybersecurity collaboration tool developed by Sean "brad" Manly for the UB NetDef Club and personal use. Options: --c > Create a new table (use for first time startup and for clearing the targets) --h > Display help""" print(out) sys.exit() if "--c" in sys.argv: data.create() bottle.run(host='0.0.0.0', port=8080, debug=True)
async def on_ready(): data.create() await client.change_presence(activity=discord.Game(name=f"P!help | Serving pizza in {len(client.guilds)} servers"), status=discord.Status.online) print("Bot Ready")