def main(): bot.init() if len(sys.argv) > 1: bot.theBot.dbConnect() commandName = sys.argv[1] input = sys.argv input.pop(0) #cc = commandcenter.CommandCenter() bot.theBot.cc.buildList() ep = commandcenter.EventPackage() ep.body = input ep.room_id = "0" ep.sender = "console" ep.event = {} ep.command = commandName output = bot.theBot.cc.run(ep) if len(output) > 0: print(output) else: print("Command not Found, did you remember to still add the prefix?") else: print("testcommand.py <prefix><command> <command arguments>")
def get_members(id_group): start = datetime.now() count_members = 0 filename = 'members/members[{}][{}].json'.format( id_group, str(datetime.now()).split('.')[0].replace(' ', '_')) bot.init() bot.load_page( 'https://www.facebook.com/groups/{}/members/'.format(id_group)) while bot.scrolling_down_facebook('_60ri'): information = bot.get_elements_class_name('_60ri') for index, element in enumerate(information): data = bot.get_child_tag_name(element, 'a') ajaxify = data.get_attribute('ajaxify') if ajaxify: id = ajaxify.split('&')[1].replace('member_id=', '') member = { 'id': id, 'name': data.text, 'url': 'https://www.facebook.com/{}'.format(id) } save_member(filename, member) count_members += 1 bot.remove_element( element.find_element_by_xpath('./../../../../..')) print("{} Members [{}]".format( count_members, str(datetime.now() - start).split('.')[0])) format_file_json(filename)
def run_bot(bot=bot): rpc = GrapheneAPI(config.wallet_host, config.wallet_port, "", "") if rpc.is_locked(): rpc.unlock(config.wallet_password) print(str(datetime.now()) + "| Starting bot...") bot.init(config) time.sleep(6) print(str(datetime.now()) + "| Running the bot") bot.run()
def login_facebook(username, password): bot.init() initial_url = 'https://www.facebook.com/' login_user_element_xpath = '//*[@id="email"]' login_pass_element_xpath = '//*[@id="pass"]' bot.load_page(initial_url) element_user = bot.get_element_xpath(login_user_element_xpath) element_password = bot.get_element_xpath(login_pass_element_xpath) bot.set_text_input(element_user, username) bot.set_text_input(element_password, password) bot.submit_form(element_password)
def reroute(changepin): bot.init() changePin = int(changepin) if changePin == 1: # motors.turnLeft() bot.left() elif changePin == 2: bot.forward() # motors.forward() elif changePin == 3: bot.right() # motors.turnRight() elif changePin == 4: bot.backward() # motors.backward() elif changePin == 5: gpio.cleanup() else: print("Wrong command") response = make_response(redirect(url_for('index'))) return(response)
if len(my_accounts) is 0: brain_key = rpc.suggest_brain_key() account_registered, account_registration_response = register_account_faucet(config.account, brain_key['pub_key']) if account_registered: rpc.import_key(config.account, brain_key['wif_priv_key']) print("Account: %s succesfully registered" % config.account) print(rpc.list_my_accounts()) print("Brain key: %s" % brain_key['brain_priv_key']) print("Write it down/back it up ^") print("Send funds to %s and start the bot again" % config.account) else: print("Account creation failed") print(brain_key) print(config.faucet + " response: ", account_registration_response) else: print(my_accounts) print(config.account) print(rpc.list_account_balances(config.account)) print("Bot config: " + str(config.bots["MakerRexp"])) bot.init(config) run_bot() # running the bot before the scheduler, otherwise it will run for the first time after config.interval scheduler = BlockingScheduler() scheduler.add_job(run_bot, 'interval', hours=config.interval) scheduler.start()
reg_parser = reqparse.RequestParser() reg_parser.add_argument('sports-type') reg_parser.add_argument('team-name') reg_parser.add_argument('participant') reg_parser.add_argument('no-team') for i in range(8): reg_parser.add_argument(f'participant-{i+1}') aprv_parser = reqparse.RequestParser() aprv_parser.add_argument('token') part_parser = reqparse.RequestParser() part_parser.add_argument('sport') api.add_resource(RegisterTeam, '/api/register_team') api.add_resource(Events, '/api/events') api.add_resource(Participants, '/api/participants') api.add_resource(Approve, '/api/admin/approve_registration') if __name__ == '__main__': flask_thread = threading.Thread(target=app.run, kwargs={ 'debug': False, 'use_reloader': False, 'port': 42069, 'host': '0.0.0.0' }) flask_thread.start() bot.init()
def login(): qr = bot.init() return render_template('login.html', qr=qr)
import socket import json import bot as botter client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) client_socket.bind(('0.0.0.0', 8082)) botter.init() while 1: try: client_socket.listen(2) conn, addr = client_socket.accept() data = conn.recv(4096) data = data.decode('utf8') #print(data) jsonData = json.loads(data[data.index('{'):]) #print(data) print(jsonData['text']) botter.checkReg(jsonData['text'], data) except KeyboardInterrupt: client_socket.shutdown(socket.SHUT_RDWR) client_socket.close() exit(1) except socket.error: pass except ValueError as ex: print(str(ex)) pass
try: import config_test as config except ImportError: pass elif deployment_env in ('prod', 'production'): try: import config except ImportError: pass if config is None: try: import config_base as config except ImportError: pass if config is None: try: import config_dev as config except ImportError: pass if config is None: print('There is no configuration file!', file=sys.stderr) exit(1) bot = bot.init(config) app = bot.asgi if __name__ == '__main__': bot.run()
from bot import init app = init() if __name__ == '__main__': # note the threaded arg which allow # your app to have more than one thread app.run(threaded=True)
account_registered, account_registration_response = register_account_faucet( config.account, brain_key['pub_key']) if account_registered: rpc.import_key(config.account, brain_key['wif_priv_key']) print("Account: %s succesfully registered" % config.account) print(rpc.list_my_accounts()) print("Brain key: %s" % brain_key['brain_priv_key']) print("Write it down/back it up ^") print("Send funds to %s and start the bot again" % config.account) else: print("Account creation failed") print(brain_key) print(config.faucet + " response: ", account_registration_response) else: print(my_accounts) print(config.account) print(rpc.list_account_balances(config.account)) print("Bot config: " + str(config.bots["MakerRexp"])) bot.init(config) run_bot( ) # running the bot before the scheduler, otherwise it will run for the first time after config.interval scheduler = BlockingScheduler() scheduler.add_job(run_bot, 'interval', hours=config.interval) scheduler.start()
def main(): global theBot bot.init() bot.theBot.dbConnect() bot.theBot.go()