def gather(name): """Return data about the users on a Minecraft game server.""" users = { 'count': 0, 'names': [] } server = mcserver.gather(name) state = server.get('state') if state is None or state != 'running': return users # get IP address of the game server for login address = server.get('publicIpAddress') if address is None or address == '': logger.error('could not find public IP address for %s', name) return users # get mcrcon from parameter store ssm = boto3.client('ssm') mcrcon_pw_param = ssm.get_parameter( Name='/minecraft/mcrcon/password', WithDecryption=True ) mcrcon_pw = mcrcon_pw_param.get('Parameter').get('Value') # get users from the game server with mcrcon.MCRcon(address, mcrcon_pw) as mcr: resp = mcr.command('list') logger.debug('mcrcon "list" command returned = "%s"', resp) users = parse_mcrcon_list(resp) return users
def chat(bot, update): text = ' '.join(update.message.text.split()[1:]) if text: rcon = mcrcon.MCRcon() rcon.connect(config['RCON']['server_ip'], int(config['RCON']['server_port']), config['RCON']['server_password']) response = rcon.command("say [" + update.message.from_user.first_name + "]" + " " + text) logger.info("[" + str(update.message.from_user.id) + " | " + update.message.from_user.first_name + "]" + " " + text) update.message.reply_text("메시지를 보냈습니다.\n" "Your message has been sent.") rcon.disconnect() else: update.message.reply_text( "위 커맨드는 서버에 메시지를 보낼 수 있습니다.\n" "사용법 : !chat [내용]\n" "\n" "The above command can send a message to the server.\n" "Usage : !chat [Text]")
def main(): global rcon host = str(input("服务器地址:")) port = int(input("Rcon端口:")) pw = str(input("Rcon管理密码:")) rcon = mcrcon.MCRcon() rcon.connect(host, port, pw) msg = "§4§l弹幕机已连接!" sendmsg(msg) roomid = getroomid(int(input("输入直播间号:"))) logger.info("真实房间号:" + str(roomid)) try: global s s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('livecmt-1.bilibili.com', 788)) s.setblocking(False) timer = threading.Timer(1, heart) #首次启动 timer.start() clientid = "146284628274713" strr = '{"roomid":' + str( roomid ) + ',"uid":' + clientid + ',"protover": 1,"platform": "web","clientver": "1.4.0"}' logger.debug(strr) senddatapack(7, strr) except Exception as e: logger.error(e)
def main(host, port, password): k = khan_api.KhanSession(server_url='https://www.khanacademy.org', consumer_key=CONSUMER_KEY, consumer_secret=CONSUMER_SECRET, username=USERNAME, password=PASSWORD, callback_address='127.0.0.2:0') rcon = mcrcon.MCRcon() rcon.connect(host, port, password) mc_username = input('Minecraft username: '******'Khan Academy email: ') points = k.get_user(email=khan_email)['points'] print('\nUser %s has %d points.' % (khan_email, points)) REWARD = input("\nReward item name (e. g. minecraft:diamond): ") print('\nExchange:\nX points = 1 reward item.') exchange_rate = int(input('\nX = ')) n = points // exchange_rate response = rcon.command('give %s %s %d' % (mc_username, REWARD, n)) if response: print(" %s" % response) rcon.disconnect() return 0
def rcon(bot, update, isAdmin): text = ' '.join(update.message.text.split()[1:]) command = ' '.join(text.split()[0:]) if isAdmin: if text: rcon = mcrcon.MCRcon() rcon.connect(config['RCON']['server_ip'], int(config['RCON']['server_port']), config['RCON']['server_password']) update.message.reply_text("해당 명령어를 실행중입니다...\n" "Running this command...") response = rcon.command(command) update.message.reply_text("성공적으로 실행되었습니다.\n" "Successfully executed.") rcon.disconnect() else: update.message.reply_text( "위 커맨드는 RCON 에서 명령어를 실행하는 명령어입니다.\n" "사용법 : !rcon [내용]\n" "\n" "The above command is a command to execute command on RCON.\n" "Usage : !rcon [Text]") else: update.message.reply_text( "죄송합니다. 해당 명령어는 관리자만 수행할 수 있습니다.\n" "Sorry. This command can only be executed by the administrator.")
def connect_rcon(self, new=False): if self.rcon == None or new == False: server_data = str(self.ui.comboBox.currentText()).split(':') if len(server_data) < 3: self.error_modal('Проверьте правильность настроек сервера.', 'Не хватает данных') return try: self.rcon = mcrcon.MCRcon(server_data[0], int(server_data[1]), server_data[2]) self.ui.plainTextEdit.appendPlainText( '[' + strftime("%Y-%m-%d %H:%M:%S", gmtime()) + ']Подключено к ' + server_data[0]) self.ip_server = server_data[0] self.init_players() self.enable_features() t1.start() except Exception as err: self.ui.plainTextEdit.appendPlainText( '[' + strftime("%Y-%m-%d %H:%M:%S", gmtime()) + ']Ошибка подключения к ' + server_data[0]) self.error_modal('Ошибка подключения', 'Ошибка') return else: self.init_players()
def main(): global r try: addr = sys.argv[1] port = int(sys.argv[2]) except: print('Missing args') return (1) r = mcrcon.MCRcon() try: passfile = sys.argv[3] fd = open(passfile, 'r') password = fd.read().rstrip('\n') fd.close() except Exception as e: print(e) try: password = getpass.getpass('Password (ctrl+D for none): ') except EOFError: password = '' r.connect(addr, port, password) prompt = '{}:{}> '.format(addr, port) while True: try: cmd = input(prompt) print(r.command(cmd)) except EOFError: print('') return (0) except Exception as e: print(e)
def command(self, cmd, args=[], block=False): """Send a command to the server. Required arguments: cmd -- The command name. Optional arguments: args -- A list of arguments passed to the command. block -- If True and the server is not running, tries to wait until the server is running to send the command. Defaults to False. Raises: MinecraftServerNotRunningError -- If the world is not running and block is set to False. socket.error -- If the world is running but the RCON connection failed. """ while not self.status(): if block: time.sleep(1) else: raise MinecraftServerNotRunningError('') cmd += (' ' + ' '.join(str(arg) for arg in args)) if len(args) else '' rcon = mcrcon.MCRcon() rcon.connect('localhost', self.config['rconPort'], self.config['rconPassword']) return rcon.command(cmd)
def execute_rcon(cmd, ip): # send response rcon = mcrcon.MCRcon(ip, PASSWORD) rcon.connect() response = rcon.command(cmd) rcon.disconnect() return response
def get_rcon(): if 'rcon' not in g: g.rcon = mcrcon.MCRcon() g.rcon.connect( current_app.config.get('RCON_HOST'), current_app.config.get('RCON_PORT'), current_app.config.get('RCON_PASSWORD'), ) return g.rcon
def user_list(): rcon = mcrcon.MCRcon() rcon.connect('localhost', 27014, '271271') data = rcon.command('/list') user_string = data.split(':')[1] users = [] if user_string != '': users = sorted(x.strip() for x in user_string.split(',')) return jsonify({"users": users})
def ban_player(): if request.method == 'POST': if request.form['password'] == 'kWb1QY8d': rcon = mcrcon.MCRcon() rcon.connect('localhost', 27014, '271271') data = rcon.command('/ban ' + request.form['nick']) else: data = 'Ошибка авторизации' return jsonify({"result": data})
def reconnect(servers): rcons = [] for server in servers: host, port, password = server r = mcrcon.MCRcon() print("# connecting to %s:%i..." % (host, port)) r.connect(host, port, password) r.command("/gamerule sendCommandFeedback false") rcons.append(r) return rcons
def command(comando): #rcon command rutine try: rcon = mcrcon.MCRcon() rcon.connect("localhost", 25575, "passss") #RCON PARAMETERS out = rcon.command(comando) rcon.disconnect() except: out="ServerConnectionError" print(out) return out
def server_restart(): if request.method == 'POST': if request.form['password'] == 'kWb1QY8d': rcon = mcrcon.MCRcon() rcon.connect('localhost', 27014, '271271') data = rcon.command('/stop') else: data = 'Ошибка авторизации' else: data = 'Ошибка запроса' return jsonify({"result": data})
def rcon(command, server_details): server_ip, port = server_details.get("server", {}).get("server_ip", "127.0.0.1:25575").split(":") password = server_details.get("server", {}).get("rcon_password", None) rcon = mcrcon.MCRcon(server_ip, password, ADMIN_PORT) rcon.connect() result = rcon.command(command) rcon.disconnect() return result
def __init__(self, filename, xmpp_settings): self.logger = logging.getLogger('bot') self.xmpp_settings = xmpp_settings # create parser self.logger.info("Attach to %s" % filename) self.parser = LogParser(filename, self.parse) self.users = {} self.patterns = [ (re.compile("^(.*) joined the game"), self.event_join), (re.compile("^(.*) left the game"), self.event_leave), (re.compile("^<(.*)> (.*)$"), self.event_chat) ] self.rcon = mcrcon.MCRcon()
def main(host, port, password): rcon = mcrcon.MCRcon() print("# connecting to %s:%i..." % (host, port)) rcon.connect(host, port, password) print("# ready") try: while True: response = rcon.command(input('> ')) if response: print(" %s" % response) except KeyboardInterrupt: print("\n# disconnecting...") rcon.disconnect()
def broadcast(bot, update, isAdmin): text = ' '.join(update.message.text.split()[1:]) if isAdmin: rcon = mcrcon.MCRcon() rcon.connect(config['RCON']['server_ip'], int(config['RCON']['server_port']), config['RCON']['server_password']) update.message.reply_text("해당 명령어를 실행중입니다...\n" "Running this command...") response = rcon.command("broadcast " + text) update.message.reply_text("성공적으로 실행되었습니다.\n" "Successfully executed.") rcon.disconnect() else: update.message.reply_text( "죄송합니다. 해당 명령어는 관리자만 수행할 수 있습니다.\n" "Sorry. This command can only be executed by the administrator.")
def restart(bot, update, isAdmin): if isAdmin: rcon = mcrcon.MCRcon() rcon.connect(config['RCON']['server_ip'], int(config['RCON']['server_port']), config['RCON']['server_password']) update.message.reply_text("해당 명령어를 실행중입니다...\n" "Running this command...") response = rcon.command("restart") while True: if response: update.message.reply_text("성공적으로 실행되었습니다.\n" "Successfully executed.") break rcon.disconnect() else: update.message.reply_text( "죄송합니다. 해당 명령어는 관리자만 수행할 수 있습니다.\n" "Sorry. This command can only be executed by the administrator.")
import mcrcon import config import sys import math from PIL import Image command_fill = "fill {x1} {y1} {z1} {x2} {y2} {z2} {block_name} replace" command_setblock = "setblock {x} {y} {z} {block_name} replace" rcon = mcrcon.MCRcon() def piramyd(args): if len(args) < 5: print( "usage: piramyd smallest x, smallest y, smallest z, baseSize, blockName" ) return height = math.floor(int(args[3]) / 2) size = int(args[3]) x = int(args[0]) y = int(args[1]) z = int(args[2]) yDelta = 1 if len(args) > 5: yDelta = int(args[5]) for i in range(height): response = rcon.command( command_fill.format(x1=x, y1=y,
def on_message(message): if message.author.id == client.user.id: return global mut_mut for element in mut_mut: if message.author.id == element: yield from client.delete_message(message) yield from client.send_message(message.author, 'Nope') return if message.content.startswith('prune'): if message.server.name == 'FTW': print ('FTW exept') return pruneday = message.content.replace('prune ','') perms = message.channel.permissions_for(message.author) for permi in perms: if str(permi) == ("('administrator', True)") : print ('pruning by : ', message.author) yield from client.send_message(message.channel, 'Pruning...') pruned = yield from client.prune_members(message.server,days=int(pruneday)) yield from client.send_message(message.channel, 'Pruned : '+str(pruned)) if message.content.startswith('chan Off'): yield from client.send_typing(message.channel) Banchan.append(message.channel.id) yield from client.send_message(message.channel, "Reponse perso desactivée sur"+message.channel.id) if message.content.startswith('chan On'): yield from client.send_typing(message.channel) Banchan.remove(message.channel.id) yield from client.send_message(message.channel, "Reponse perso réeactivée sur : "+message.channel.id) if message.content.startswith('persoff'): Stopit = 'pls' if message.content.startswith('person'): Stopit = 'UUUUIIIII' if message.content.startswith('ftp'): global ftp yield from client.delete_message(message) host = message.content.replace('ftp ','') ftp = FTPV(host) if message.content.startswith('ftpco'): global ftp yield from client.delete_message(message) login = message.content.replace('ftpco ','') mdp = login.split()[1] ftp.connect(login,mdp) if message.content.startswith('ftpl'): global ftp lake = "" for lik in ftp.FileList(): lake= "| "+lik yield from client.start_private_message(message.author) yield from client.delete_message(message) yield from client.send_message(message.author, lake) #musik Yeah if message.content.startswith('reco'): global player global porazika global Zika yield from client.delete_message(message) if lunched == 'yep': playnext = [] player.stop() porazika = 'ui' yield from voice.disconnect() yield from asyncio.sleep(0.5) voice = yield from client.join_voice_channel(message.author.voice.voice_channel) Zika = 'on' porazika = 'noup' if message.content.startswith('join'): voice = yield from client.join_voice_channel(message.author.voice.voice_channel) yield from client.delete_message(message) Zika = 'on' if message.content.startswith('listZik'): p=Playlist() loul = p.getAllLien() for mUzi in loul: yield from client.send_message(message.channel, mUzi) return if message.content.startswith('vol'): global vol vol = message.content.replace('vol ','') print(vol,'%') player.volume = int(vol)/100 if message.content.startswith('autoZik'): global voice global porazika global Zika global lunched global musikal global autozik global playnext global vol yield from client.delete_message(message) if autozik == 'on': print ('conflit') return autozik = 'on' if Zika == 'off': voice = yield from client.join_voice_channel(message.author.voice.voice_channel) print ('connected') Zika = 'on' if lunched == 'yep': playnext = [] player.stop() p=Playlist() loul = p.getAllLien() while True: if Zika == 'off': return yield from client.send_typing(message.channel) player = yield from voice.create_ytdl_player(random.choice(loul)) player.volume = int(vol)/100 player.start() if not True: return print ('playing : ', player.title) yield from client.change_presence(game=discord.Game(name=player.title)) hard = discord.Object(id="178882236324642816") yield from client.send_message(hard, player.title) while player.is_playing(): if porazika == 'ui': autozik = 'nop' print ('ended') player.stop() return yield from asyncio.sleep(0.3) print ('next song') if message.content.startswith('addik'): global voice global Zika global lunched global musikal global playnext p = Playlist() lip = message.content.replace('addik ','') p.addSong(lip) hard = discord.Object(id="178882236324642816") yield from client.send_message(hard, "added a Zik") if message.content.startswith('infoZik'): yield from client.send_typing(message.channel) dure = str(player.duration) likes = str(player.likes) dislikes = str(player.dislikes) vues = str(player.views) yield from client.send_message(message.channel, "Nom : "+player.title+"\nURL : "+player.url+"\n Description : \n"+player.description+"\n \n Durée : "+dure+"s"+"\n Likes/Dislikes : "+likes+"/"+dislikes+"\n Vues : "+vues) if message.content.startswith('Zik'): global voice global Zika global lunched global musikal global playnext global porazika global vol porazika = 'ui' yield from asyncio.sleep(0.5) if Zika == 'off': voice = yield from client.join_voice_channel(message.author.voice.voice_channel) Zika = 'on' musikal = message.content.replace('Zik ','') if lunched == 'yep': playnext.append(musikal) playnext.append(musikal) print('added song') yield from client.send_message(message.channel, "added to playlist :)") return playnext.append(musikal) for lipo in playnext: playnext.remove(lipo) tobirater = yield from client.send_message(message.channel, "Wait for it...") yield from client.send_typing(message.channel) player = yield from voice.create_ytdl_player(lipo) player.volume = int(vol)/100 player.start() print ('playing : ', player.title) yield from client.change_presence(game=discord.Game(name=player.title)) hard = discord.Object(id="178882236324642816") yield from client.send_message(hard, player.title) yield from client.edit_message(tobirater,':notes: :notes: :notes: :notes: :notes: ') lunched = 'yep' while player.is_playing(): yield from asyncio.sleep(0.5) lunched = 'Nope' playnext = [] porazika = 'noup' autozik = 'nop' yield from client.change_presence(game=discord.Game(name=random.choice(["dibou","rtichau","Broutter","la claire fontaine","bricot"]))) if message.content.startswith('TTS'): global voice global Zika global lunched global musikal global playnext global porazika porazika = 'ui' yield from asyncio.sleep(0.5) if Zika == 'off': voice = yield from client.join_voice_channel(message.author.voice.voice_channel) Zika = 'on' TTS = message.content.replace('TTS ','') if lunched == 'yep': yield from client.send_message(message.channel, "Attendez la fin de la lecture en cour") return tts = gTTS(text=TTS, lang='fr') tts.save("TTS.mp3") player = voice.create_ffmpeg_player('TTS.mp3') player.start() lunched = 'yep' while not player.is_done(): yield from asyncio.sleep(1) lunched = 'Nope' playnext = [] porazika = 'noup' autozik = 'nop' if message.content.startswith('Pause'): global player yield from client.delete_message(message) player.pause() if message.content.startswith('Resume'): global player yield from client.delete_message(message) player.resume() if message.content.startswith('Stop'): global player yield from client.delete_message(message) player.stop() if message.content.startswith('end'): global player yield from client.delete_message(message) lunched = 'Nope' playnext = [] porazika = 'ui' yield from asyncio.sleep(3) porazika = 'noup' if message.content.startswith('deco'): global player Zika = 'off' yield from client.delete_message(message) yield from voice.disconnect() #change statut + Help + Wikipedia if message.content.startswith('Wolf'): yield from client.send_typing(message.channel) res = wolfclient.query(message.content.replace('Wolf ','')) print('computed!') for pod in res.pods: print('{p.title} : {p.text}'.format(p=pod)) if pod.text: yield from client.send_message(message.channel, '{p.title} : {p.text}'.format(p=pod)) elif pod.img: yield from client.send_message(message.channel, '{p.title} :\n{p.img}'.format(p=pod)) if message.content.startswith('rcon'): print("rcon") rconeri = message.content.replace('rcon ','') rconeri = rconeri.split(",") rcon = mcrcon.MCRcon() yield from client.send_message(message.channel,"connecting...") port = int(rconeri[1]) rcon.connect(rconeri[0],port) rcon.login(rconeri[2]) response = rcon.command(rconeri[3]) if response: yield from client.send_message(message.channel,+(" %s" % response)) rcon.disconnect() if message.content.startswith('Statut'): statou = message.content.replace('Statut ','') server = MinecraftServer.lookup(statou) status = server.status() yield from client.send_message(message.channel,"The server has {0} players and replied in {1} ms".format(status.players.online, status.latency)) if message.content.startswith('Cbot'): print (message.content) yield from client.send_typing(message.channel) yield from asyncio.sleep(0.5) yield from client.send_message(message.channel, cb.ask(message.content.replace('Cbot ',''))) if message.content.startswith('Help'): yield from client.send_typing(message.channel) yield from asyncio.sleep(1) yield from client.send_message(message.channel, ' Commandes : \n \n - persoff / person : désactive / active les réponses perso \n - Zik *lien_youtbe_ou_soundcloud* : joue la musique / l\'ajoute à la queue \n - join : summon le bot dans le channel de l\'auteur du msg \n - Pause : Met la musique en pause \n - Resume : continue la musique \n - Stop : musique suivante / Stop si aucune musique dans la queue \n - deco : déconnecte le bot du chan vocal \n - Cbot *nimortequoi* : permet de parler avec le bot \n - wiki *recherche Wikipédia* : recherche Wikipédia \n - dit *un_truc* : fait dire ce que vous voulez au bot \n - 42 : réponse a tout \n - memo add *votre memo* : ajoute un memo \n - memo show : montre vos memos \n - memo remove *votre memo* : supprime le memo \n - remind *nb de minute* : ajoute un rappel dans un temps définit en minute \n - spam *nb* : spam le chan \n - dance / 2dance : Fait danser le bot \n - p4start : créer un p4 \n - play : lance le p4 précédemment créer \n - pfc *pierre/feuille/ciseaux* : joue a pierre feuille ciseaux \n - random *nb* : donne un nombre en entre 0 est le nb choisit \n - me / me-id : donne votre nom et votre id \n - bot *statut* : change le statut du bot \n - Sheep random : :smiley: ') if message.content.startswith('wiktype'): yield from client.send_typing(message.channel) wik = wikipedia.search(message.content.replace('wikitype ','')) yield from client.send_message(message.channel, wik) if message.content.startswith('wiki'): yield from client.send_typing(message.channel) hard = discord.Object(id="178882236324642816") yield from client.send_message(hard, "Wikipeding ") yield from asyncio.sleep(1) wiki = wikipedia.summary(message.content.replace('wiki ','')) wikia = wiki.split(".") for element in wikia: yield from client.send_message(message.channel, element) # dit 42 if message.content.startswith('dit'): yield from client.send_message(message.channel, message.content.replace('dit','')) if message.content.startswith('42'): yield from client.send_message(message.channel,random.choice(['Oui','Non','Mais oui c''est clair!','Peut étre..','Nope','oui','non','jsp','oui','non','non','oui','oui','non','VTFF','Té...leportation!','Hum tt de facon, personne connais l\'origine','Ceci est un message de Jbdo99'])) #Mute if message.content.startswith('Mute'): Dirlo = 177394669766836224 print ('mute') print (message.author) print (message.content) Viagra = message.content.replace('Mute ','') Viagra = int(Viagra) if Viagra == Dirlo: print ('Nope') yield from client.send_message(message.channel, 'Nope Biatch') return mut_mut.append(Viagra) yield from client.send_message(message.channel, 'Ok') hard = discord.Object(id="178882236324642816") yield from client.send_message(hard, "Muting : "+Viagra) if message.content.startswith('de-Mute'): print ('de-mute') print (message.author) print (message.content) mut_mut.remove(message.content.replace('de-Mute ','')) yield from client.send_message(message.channel, 'pffff, dommage') hard = discord.Object(id="178882236324642816") yield from client.send_message(hard, "De-muted") #memo + remind if message.content.startswith('memo'): lasuite = message.content.replace('memo ','') if lasuite.startswith('add'): memo.append(message.author.id + lasuite.replace('add ','')) yield from client.send_message(message.channel, 'added') print('added') return if lasuite.startswith('show'): yield from client.send_message(message.channel, 'trucs a faire :') for Memor in memo: if Memor.startswith(message.author.id): yield from client.send_message(message.channel, Memor.replace(message.author.id,'')) print ('Memo') return if lasuite.startswith('remove'): memo.remove(message.author.id + message.content.replace('memo remove ','')) yield from client.send_message(message.channel, 'removed') print('removed') return if message.content == 'memo': yield from client.send_message(message.channel, 'commandes : add, remove, show') if message.content.startswith('remind'): aho = message.content.replace('remind ','') aho,yp = aho.split(".") Sec = int(aho) Sec = Sec*60 print('dring?') yield from asyncio.sleep(Sec) print('dring') yield from client.send_message(message.channel, 'DRIIIIIINNNGGG!!! : '+yp) # PENSER A MODIFIER!!!! if message.content.startswith('spam'): rt = message.content.replace('spam ','') rt = int(rt) bz = 0 print ('spam',message.author) if rt > 20: yield from client.send_message(message.channel, 'Nope, pas plus de 20!!') print (message.channel) return if message.channel.name == 'general': yield from client.send_message(message.channel, 'Nope, pas ici!!!') print (message.channel) return hard = discord.Object(id="178882236324642816") yield from client.send_message(hard, "Spamming") while bz < rt : yield from client.send_message(message.channel, random.choice(["SPAM!!!","spam","Hello","yo","Hey!!","I love spamming","spam!!!","spam","SPAAAAMMM","sssssssSSSSSSSSSSSSPPPPPPPPPAAAAAAAAMMMMMMM","SPAM!!","¤SPAM¤","§SPAM§","SPAM","/o/","\o\\","\o/","SPARTA","^^",":robot:",":space_invader:", ":poop:", ":snake:", ":8ball:", ":skull:", ":trophy:", ":rainbow:", ":iphone:", ":computer:", ":keyboard:", ":mouse_three_button:", ":joystick:", ":moneybag:", ":dollar:", ":euro:", ":money_with_wings:", ":skull_crossbones:", ":shield:", ":electric_plug:", ":exclamation:", ":warning:", ":mega:", ":ram:", ":grinning:", ":scream:", ":spy:",":sheep:"]) + random.choice(["SPAM!!!","spam","Hello","yo","Hey!!","I love spamming","spam!!!","spam","SPAAAAMMM","sssssssSSSSSSSSSSSSPPPPPPPPPAAAAAAAAMMMMMMM","SPAM!!","¤SPAM¤","§SPAM§","SPAM","/o/","\o\\","\o/","SPARTA","^^",":robot:",":space_invader:", ":poop:", ":snake:", ":8ball:", ":skull:", ":trophy:", ":rainbow:", ":iphone:", ":computer:", ":keyboard:", ":mouse_three_button:", ":joystick:", ":moneybag:", ":dollar:", ":euro:", ":money_with_wings:", ":skull_crossbones:", ":shield:", ":electric_plug:", ":exclamation:", ":warning:", ":mega:", ":ram:", ":grinning:", ":scream:", ":spy:",":sheep:"]) + random.choice(["SPAM!!!","spam","Hello","yo","Hey!!","I love spamming","spam!!!","spam","SPAAAAMMM","sssssssSSSSSSSSSSSSPPPPPPPPPAAAAAAAAMMMMMMM","SPAM!!","¤SPAM¤","§SPAM§","SPAM","/o/","\o\\","\o/","SPARTA","^^",":robot:",":space_invader:", ":poop:", ":snake:", ":8ball:", ":skull:", ":trophy:", ":rainbow:", ":iphone:", ":computer:", ":keyboard:", ":mouse_three_button:", ":joystick:", ":moneybag:", ":dollar:", ":euro:", ":money_with_wings:", ":skull_crossbones:", ":shield:", ":electric_plug:", ":exclamation:", ":warning:", ":mega:", ":ram:", ":grinning:", ":scream:", ":spy:",":sheep:"]) + random.choice(["SPAM!!!","spam","Hello","yo","Hey!!","I love spamming","spam!!!","spam","SPAAAAMMM","sssssssSSSSSSSSSSSSPPPPPPPPPAAAAAAAAMMMMMMM","SPAM!!","¤SPAM¤","§SPAM§","SPAM","/o/","\o\\","\o/","SPARTA","^^",":robot:",":space_invader:", ":poop:", ":snake:", ":8ball:", ":skull:", ":trophy:", ":rainbow:", ":iphone:", ":computer:", ":keyboard:", ":mouse_three_button:", ":joystick:", ":moneybag:", ":dollar:", ":euro:", ":money_with_wings:", ":skull_crossbones:", ":shield:", ":electric_plug:", ":exclamation:", ":warning:", ":mega:", ":ram:", ":grinning:", ":scream:", ":spy:",":sheep:"]) + random.choice(["SPAM!!!","spam","Hello","yo","Hey!!","I love spamming","spam!!!","spam","SPAAAAMMM","sssssssSSSSSSSSSSSSPPPPPPPPPAAAAAAAAMMMMMMM","SPAM!!","¤SPAM¤","§SPAM§","SPAM","/o/","\o\\","\o/","SPARTA","^^",":robot:",":space_invader:", ":poop:", ":snake:", ":8ball:", ":skull:", ":trophy:", ":rainbow:", ":iphone:", ":computer:", ":keyboard:", ":mouse_three_button:", ":joystick:", ":moneybag:", ":dollar:", ":euro:", ":money_with_wings:", ":skull_crossbones:", ":shield:", ":electric_plug:", ":exclamation:", ":warning:", ":mega:", ":ram:", ":grinning:", ":scream:", ":spy:",":sheep:"]) + random.choice(["SPAM!!!","spam","Hello","yo","Hey!!","I love spamming","spam!!!","spam","SPAAAAMMM","sssssssSSSSSSSSSSSSPPPPPPPPPAAAAAAAAMMMMMMM","SPAM!!","¤SPAM¤","§SPAM§","SPAM","/o/","\o\\","\o/","SPARTA","^^",":robot:",":space_invader:", ":poop:", ":snake:", ":8ball:", ":skull:", ":trophy:", ":rainbow:", ":iphone:", ":computer:", ":keyboard:", ":mouse_three_button:", ":joystick:", ":moneybag:", ":dollar:", ":euro:", ":money_with_wings:", ":skull_crossbones:", ":shield:", ":electric_plug:", ":exclamation:", ":warning:", ":mega:", ":ram:", ":grinning:", ":scream:", ":spy:",":sheep:"]) + random.choice(["SPAM!!!","spam","Hello","yo","Hey!!","I love spamming","spam!!!","spam","SPAAAAMMM",'MESAGE SUBLIMINAL',"sssssssSSSSSSSSSSSSPPPPPPPPPAAAAAAAAMMMMMMM","SPAM!!","¤SPAM¤","§SPAM§","SPAM","/o/","\o\\","\o/","SPARTA","^^",":robot:",":space_invader:", ":poop:", ":snake:", ":8ball:", ":skull:", ":trophy:", ":rainbow:", ":iphone:", ":computer:", ":keyboard:", ":mouse_three_button:", ":joystick:", ":moneybag:", ":dollar:", ":euro:", ":money_with_wings:", ":skull_crossbones:", ":shield:", ":electric_plug:", ":exclamation:", ":warning:", ":mega:", ":ram:", ":grinning:", ":scream:", ":spy:",":sheep:"])) bz = bz + 1 print (bz) # Time to dance \o/ if message.content.startswith('dance'): dan = 0 mlg = yield from client.send_message(message.channel,'\o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ ') while dan < 10: yield from client.edit_message(mlg,'/o/ /o/ /o/ /o/ /o/ /o/ /o/ /o/ /o/') yield from asyncio.sleep(1) yield from client.edit_message(mlg, '\o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ ') yield from asyncio.sleep(1) dan = dan + 1 if message.content.startswith('2dance'): dan = 0 mlg = yield from client.send_message(message.channel,'Lets Danceee') while dan < 8: yield from client.edit_message(mlg,'_o\\ _o\\ _o\\ _o\\ _o\\ _o\\ _o\\ _o\\ _o\\ ') yield from asyncio.sleep(0.6) yield from client.edit_message(mlg,'\o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ \o\\ ') yield from asyncio.sleep(0.6) yield from client.edit_message(mlg, '|o| |o| |o| |o| |o| |o| |o| |o| |o|') yield from asyncio.sleep(0.6) yield from client.edit_message(mlg, '/o/ /o/ /o/ /o/ /o/ /o/ /o/ /o/ /o/') yield from asyncio.sleep(0.6) yield from client.edit_message(mlg, '/o\_ /o\_ /o\_ /o\_ /o\_ /o\_ /o\_ /o\_ /o\_') yield from asyncio.sleep(0.6) dan = dan + 1 yield from client.edit_message(mlg,' \'__\'') if message.content.startswith('bg'): dan = 0 mlg = yield from client.send_message(message.channel,'clement') while dan < 8: yield from client.edit_message(mlg,'Clement') yield from asyncio.sleep(0.21) yield from client.edit_message(mlg,'cLement') yield from asyncio.sleep(0.21) yield from client.edit_message(mlg, 'clEment') yield from asyncio.sleep(0.21) yield from client.edit_message(mlg, 'cleMent') yield from asyncio.sleep(0.21) yield from client.edit_message(mlg, 'clemEnt') yield from asyncio.sleep(0.21) yield from client.edit_message(mlg, 'clemeNt') yield from asyncio.sleep(0.21) yield from client.edit_message(mlg, 'clemenT') yield from asyncio.sleep(0.21) dan = dan + 1 yield from client.edit_message(mlg,'clément!') #P4, on message if message.content.startswith('change p1'): cp1 = message.content.replace('change p1 ','') if message.content.startswith('change p2'): cp2 = message.content.replace('change p2 ','') if message.content.startswith('p4start'): global p1 global p2 global cp1 global cp2 global tourplay yield from client.send_message(message.channel, "La parti de puissance 4 va commencer. Merci de vous trouver dans le channel dédié a cet usage !") if(p1 == ""): yield from client.send_message(message.channel, "Merci de choisir le joueur 1 avec la commande p1") if (p2 == ""): yield from client.send_message(message.channel, "Merci de choisir le joueur 2 avec la commande p2") else: if (p1 == p2): yield from client.send_message(message.channel, "Vous ne pouvez pas jouer avec vous meme ! Tapez p4restart") else: Jeu = Board(p1=cp1,p2=cp2) yield from client.change_presence(game=discord.Game(name="Puissance 4")) tourplay = "p1" yield from client.send_message(message.channel, "Au tour de P1 !") if message.content.startswith('p4restart'): global p1 global p2 global cp1 global cp2 global tourplay yield from client.send_message(message.channel, "Remise a zero des joueurs et du jeu...") p1 = "" p2 = "" cp1 = "X" cp2 = "O" touplay = "" if (message.content.startswith('play')): global p1 global p2 global cp1 global cp2 global trend global tourplay global Jeu if (str(message.author) == p1 and tourplay =="p1"): collone = int(message.content.replace('play ','')) dernierJeton = Jeu.add(int(collone), cp1) trump=[] trend="" if (len(cp1)==1 and len(cp2)==1): trump=Jeu.print_l() else: trump=Jeu.print_l(sizel="| ") for toyota in trump: trend = trend + toyota + "\n" yield from client.send_message(message.channel, trend) suiteMax = Jeu.check(dernierJeton) if suiteMax == 4: yield from client.send_message(message.channel, "P1 a gagné ! Pour relancer, tapez p4restart") tourplay = "p2" if (str(message.author) == p2 and tourplay =="p2"): collone = int(message.content.replace('play ','')) dernierJeton = Jeu.add(int(collone), cp2) trump=[] trend="" if (len(cp1)==1 and len(cp2)==1): trump=Jeu.print_l() else: trump=Jeu.print_l(sizel="| ") for toyota in trump: trend = trend + toyota + "\n" yield from client.send_message(message.channel, trend) suiteMax = Jeu.check(dernierJeton) if suiteMax == 4: yield from client.send_message(message.channel, "P2 a gagné ! Pour relancer, tapez p4restart") tourplay = "p1" else: print("ERREUR") if message.content.startswith('p1'): global p1 if (p1 == ""): namem = message.author xyb = "Le joueur 1 est : "+str(namem) p1 = str(message.author) print (p1) print (xyb) yield from client.send_message(message.channel, xyb) else: yield from client.send_message(message.channel, "P1 deja choisi ! Pour relancer, tapez p4restart") if message.content.startswith('p2'): global p1 global p2 global cp1 global cp2 if (p2 == ""): namem = message.author xyz = "Le joueur 2 est : "+str(namem) p2 = str(message.author) yield from client.send_message(message.channel, xyz) else: yield from client.send_message(message.channel, "P2 deja choisi ! Pour relancer, tapez p4restart") #P4 on message end #THIS IS NOT THE END #hashtag # le beau code opti :) # WORMS: J'ai des doutes sur cela # pierre feuille ciseaux if message.content.startswith('pfc'): rep = random.choice(["pierre","feuille","ciseaux"]) yield from client.send_message(message.channel, rep) messa = message.content.replace('pfc ','') print ('pfc') if rep == "pierre": if messa == "feuille": yield from client.send_message(message.channel, "ta gagné :)") if messa == "pierre": yield from client.send_message(message.channel, "egalité!") if messa == "ciseaux": yield from client.send_message(message.channel, "Perdue !!!!") print ('pierre') if rep == "feuille": if messa == "feuille": yield from client.send_message(message.channel, "egalité") if messa == "pierre": yield from client.send_message(message.channel, "Perdue !!!!!") if messa == "ciseaux": yield from client.send_message(message.channel, "ta gagné :)") print ('feuille') if rep == "ciseaux": if messa == "feuille": yield from client.send_message(message.channel, "Perdue!!!!!") if messa == "pierre": yield from client.send_message(message.channel, "ta gagné!!") if messa == "ciseaux": yield from client.send_message(message.channel, "égalité!!!") print ('ciseaux') #OSEF if message.content.startswith('random'): Rand = message.content.replace('random ','') Rand = int(Rand) yield from client.send_message(message.channel, randint(0,Rand)) print ('random',message.author) if message.content.startswith('Me-id'): yield from client.send_message(message.channel, message.author.id) print ('id',message.author) #test if message.content.startswith('Msg'): yield from client.send_typing(message.channel) yield from asyncio.sleep(3) sentmsg = yield from client.send_message(message.channel,'Hi') yield from asyncio.sleep(3) yield from client.delete_message(sentmsg) # change statut, Off et Hey bot(prgm test)! if message.content.startswith('bot'): yield from client.change_presence(game=discord.Game(name=message.content.replace('bot ',''))) yield from client.delete_message(message) print (message.content) return if message.content.startswith('Reboot'): yield from client.send_typing(message.channel) yield from asyncio.sleep(0.5) yield from client.send_message(message.channel, 'Rebooooottt.....') print ('Off by',message.author) hard = discord.Object(id="178882236324642816") yield from client.send_message(hard, "Off by "+message.author.name) yield from client.close() if message.content.startswith('Hey bot'): print (message.author) yield from client.start_private_message(message.author) yield from client.delete_message(message) yield from client.send_message(message.author, 'Hello!') #Useless #Sheep Gif :) if message.content.startswith('Sheep random'): yield from client.send_message(message.channel,random.choice(["http://i.giphy.com/cS8ljLbg3NFPq.gif","http://i.giphy.com/SmsPkjwylhpPW.gif","http://i.giphy.com/3o7WTFsxglCE1NxnEc.gif","http://i.giphy.com/xThuW0HsMlHu90FNQc.gif","http://i.giphy.com/xThuWpV1xwmzLYWQTe.gif","http://i.giphy.com/l2R07IjgM202WpXmE.gif","https://media.giphy.com/media/fUMhF7Vp5iLVm/giphy.gif","http://i.giphy.com/l3971JV3FaExDZbe8.gif","http://i.giphy.com/l396KzSQ2emojNHG0.gif","http://i.giphy.com/l2R04xY6r2nPf8Lhm.gif","http://i.giphy.com/l2QZYUOALzAW7U6wU.gif","http://i.giphy.com/3osxYpa03BAZ0sSUAo.gif","http://i.giphy.com/3osxYcpnc18ZATBX4k.gif","http://i.giphy.com/STZH9QHOS5q7K.gif","http://i.giphy.com/JR1gFcWnidhGU.gif","http://i.giphy.com/pD4mUFQR0ovmg.gif","http://i.giphy.com/oUVZQaOyjWJ6U.gif","http://i.giphy.com/zDoEG6ZxKUcPS.gif"])) if message.content.startswith('Sheep money'): yield from client.send_message(message.channel, 'http://i.giphy.com/l3971JV3FaExDZbe8.gif') if message.content.startswith('Sheep eat'): yield from client.send_message(message.channel, 'http://i.giphy.com/l0D7owZkScVOuGbhC.gif') if message.content.startswith('Sheep school'): yield from client.send_message(message.channel, 'http://i.giphy.com/l396KzSQ2emojNHG0.gif') if message.content.startswith('Sheep search'): yield from client.send_message(message.channel, 'http://i.giphy.com/l3V0C9CT3UFAQ49Jm.gif') if message.content.startswith('Sheep post'): yield from client.send_message(message.channel,random.choice(["http://i.giphy.com/3o7WTFsxglCE1NxnEc.gif","http://i.giphy.com/xThuW0HsMlHu90FNQc.gif","http://i.giphy.com/xThuWpV1xwmzLYWQTe.gif"])) if message.content.startswith('Sheep crazy'): yield from client.send_message(message.channel, 'http://i.giphy.com/3osxYcpnc18ZATBX4k.gif') if message.content.startswith('Sheep deal'): yield from client.send_message(message.channel, 'http://i.giphy.com/l2R07IjgM202WpXmE.gif') #custom responce global Stopit if Stopit == 'pls': return global Banchan for Bno in Banchan: if Bno == message.channel.id: return if (message.content.split(' ')[0] in var.keys()): yield from client.send_typing(message.channel) yield from asyncio.sleep(0.5) yield from client.send_message(message.channel, var[message.content.split(' ')[0]]) if message.content.startswith('yo'): yield from client.send_message(message.channel,random.choice(["Yop","Hi","Hello","yo","Hey!!"])) if message.content.startswith('salut'): yield from client.send_message(message.channel,random.choice(['Salut!!!','Yo','Yop','Hello']))
import getpass import mcrcon print 'Ctrl-C to exit' host = raw_input('Host: ') port = raw_input('Port (25575): ') if port == '': port = 25575 else: port = int(port) pwd = getpass.getpass('Password: '******'Rcon: ') print r.send(line) except KeyboardInterrupt, e: r.close()
def get_rcon(): rcfg = config['rconServer'] r = mcrcon.MCRcon() r.connect(rcfg['host'], rcfg['port']) r.login(rcfg['password']) return r
}, 'set': { 'day': None, 'night': None, 'noon': None, 'midnight': None } } }) parser = argparse.ArgumentParser(prog="pyrconcli", description="a better terminal interface for minecraft rcon") parser.add_argument('ip', type = str, help = "ip adresss of server") parser.add_argument('password', type = str, help = "password for rcon protocol") parser.add_argument('-P', type= int, help= "rcon port (default is 25575)", default=25575, dest="port") args = parser.parse_args() with mcrcon.MCRcon(args.ip, args.password, args.port) as rcon: session = PromptSession("rcon@{}> ".format(args.ip)) try: print("type 'exit' or press crtl-d to exit") command = session.prompt(completer=completer) while command != "exit": resp = rcon.command(command) resptext = minecraft_colors_to_ansi(resp) print_formatted_text(ANSI(resptext)) command = session.prompt(auto_suggest=AutoSuggestFromHistory(), completer=completer) except KeyboardInterrupt: pass except EOFError: pass
def add(bot, update): text = ' '.join(update.message.text.split()[1:]) if text: rcon = mcrcon.MCRcon() rcon.connect(config['RCON']['server_ip'], int(config['RCON']['server_port']), config['RCON']['server_password']) user_list = [''] response = rcon.command("whitelist list") is_already_register = False while True: if response: response = response.replace('§ePlayers in whitelist.txt: §f', '') response = response.replace('§ePlayers in whitelist.txt: §f', '') user_list = response.split(', ') for val in enumerate(user_list): if str(val) == str(text): logger.info(val) is_already_register = True break break if is_already_register: logger.info("Whitelist failed: " + str(update.message.from_user.id) + " | " + update.message.from_user.first_name + " " + text) update.message.reply_text( "죄송합니다. 이미 등록된 사용자인것같습니다.\n" "혹시나 잘못 등록하셨다면 @CityArtsSupport 로 문의주시면 감사드리겠습니다.\n" "Sorry. It looks like you're already a registered user.\n" "If you have registered incorrectly, please contact us at @CityArtsSupport." ) else: response = rcon.command("whitelist add " + text) logger.info("Whitelist added: " + str(update.message.from_user.id) + " | " + update.message.from_user.first_name + " " + text) update.message.reply_text( "등록되었습니다. CityArts에 오신걸 진심으로 축하드립니다!\n" "혹시나 잘못 등록하셨다면 @CityArtsSupport 로 문의주시면 감사드리겠습니다.\n" "Registered. Congratulations on your visit to CityArts!\n" "If you have registered incorrectly, please contact us at @CityArtsSupport." ) rcon.disconnect() else: update.message.reply_text( "다음과 같은 명령어로 서버에 쉽게 등록할 수 있습니다.\n" "사용법 : /add [마인크래프트_닉네임]\n" "\n" "You can easily register to the server with the following command.\n" "Usage : /add [Minecraft_Nickname]")
import mcrcon from readInfo import readCfg ip,port,password=readCfg() mc = mcrcon.MCRcon() mc.connect(ip, int(port), password) print("connection established") def onQQMessage(bot, contact, member, content): if content == '': print("输入无效,无法同步") bot.SendTo(contact, '输入无效,无法同步') return if content == '#hello': bot.SendTo(contact, '我是outlife_debugger,我会把群内聊天记录同步到服务器') bot.SendTo(contact, ('->输入/list查看服务器在线人数\n' '->输入/plugins查看服务器支持插件\n' '->输入/version查看服务器版本\n' '->其它的,欢迎探索哦')) commands = ["/list", "/plugins", "/version", "/restart", "/stop", "/time","/whitelist"] opcommands = ["/restart", "/stop", "/time","/whitelist"] op = ["traceback", "metal", "抽奖和白名单请私聊我"] core = content.split()[0] commander = member.name if content in commands: if (core in opcommands) and (commander in op): print("you are permitted") bot.SendTo(contact,"you are permitted") response = mc.command(content[1:]) bot.SendTo(contact, response) return
def send_rcon(msg): with mcrcon.MCRcon(config["mc_server"], config["rcon_pass"]) as r: return r.command(msg)
def __init__(self, irc): self.__parent = super(Craftoria, self) self.__parent.__init__(irc) self.data_dir = conf.supybot.directories.data self.mc_irc_data_file = '%s/mc_irc_nicks.json' % self.data_dir self.mcnicks_check_data_file() self.irc = irc self.log_read = True # so we can bail out later if necessary self.log4j_read = True # so we can bail out later if necessary self.config = conf.supybot.plugins.Craftoria self.special_actions = self.config.special_actions() self.use_log4j = self.config.use_log4j() if self.use_log4j: self.UDPConnectionHandler.irc = self.irc self.UDPConnectionHandler.log = self.log self.UDPConnectionHandler.handle_message = self.handle_message self.UDPConnectionHandler.config = self.config self.log4j_host = self.config.log4j_host() if self.log4j_host == None: raise "Configuration not complete - Minecraft server 'log4j_host' DNS/IP not set" self.log4j_port = int(self.config.log4j_port()) if self.log4j_port == None: raise "Configuration not complete - Minecraft server 'log4j_port' port number not set" self.log4j_host_accept = self.config.log4j_host_accept() if self.log4j_host_accept == None: raise "Configuration not complete - Minecraft server 'log4j_host_accept' IP not set" else: self.mc_log = self.config.minecraft_server_log() if self.mc_log == None: raise "Configuration not complete - Minecraft server 'minecraft_server_log' path not set" self.rcon_host = self.config.rcon_host() if self.rcon_host == None: raise "Configuration not complete - Minecraft server 'rcon_host' DNS/IP not set" self.rcon_port = int(self.config.rcon_port()) if self.rcon_port == None: raise "Configuration not complete - Minecraft server 'rcon_port' port number not set" self.rcon_pass = self.config.rcon_pass() if self.rcon_pass == None: raise "Configuration not complete - Minecraft server 'rcon_pass' password not set" self.rcon = mcrcon.MCRcon(self.rcon_host, self.rcon_port, self.rcon_pass) if self.rcon: self.log.info('Craftoria: successfully connected to rcon') else: raise "Connection to Minecraft server using rcon impossible" self.log.info('Craftoria: could not connect to rcon') if self.use_log4j: self.server = SocketServer.UDPServer((self.log4j_host, self.log4j_port), self.UDPConnectionHandler) t = threading.Thread( target = self.server.serve_forever, name = "CraftoriaThread" ) t.setDaemon(True) t.start() world.threadsSpawned += 1 else: t = threading.Thread( target = self.read_forever, name = "CraftoriaThread" ) t.setDaemon(True) t.start() world.threadsSpawned += 1