Answer the question
In order to leave comments, you need to log in
Python, Twisted. Connecting to another server after reactor.run() and receiving data from the main
There is one game. I'm trying to make a bot for it.
After connecting to the main server (hereinafter referred to as main), the client sends some data, after which it receives the ip and port of another server (hereinafter referred to as bulle), they have the same protocol. We need to create a second client for the bulle server and put some data from bulle into the Factory so that it can be used in both clients.
I do not know English very well, I tried to google - I did not find anything.
#coding: utf-8
from bytearray import ByteArray
from fingerprint import fingerprint
from Protocole import *
from twisted.internet import reactor, protocol
def _(text):
print "[DEBUG] " + text
class TransformiceBotFactory(protocol.ClientFactory):
def __init__(self):
self.oop = 0
def clientConnectionFailed(self, connector, reason):
_("Connection failed!")
#reactor.stop()
def clientConnectionLost(self, connector, reason):
_("Connection lost!")
#reactor.stop()
#main()
class TransformiceBotMainServeurClient(TFMClientProtocol):
def connectionMade(self):
_("Connected to main server.")
self.factory.oop += 1
print self.factory.oop
self.sendInitialPacket()
def connectionLost(self, reason):
_("connection lost")
def sendInitialPacket(self):
bulleClient = TransformiceBotFactory()
bulleClient.protocol = TransformiceBotBulleServeurClient
reactor.connectTCP("bulleip", 44440, bulleClient)
class TransformiceBotBulleServeurClient(TFMClientProtocol):
def connectionMade(self):
_("Connected to bulle server.")
_(str(self.factory.oop))
self.sendInitialPacket()
def connectionLost(self, reason):
_("connection lost")
def sendInitialPacket(self):return
def main():
_("Transformice bot is reloaded!")
#from twisted.python import log
#import sys
#log.startLogging(sys.stdout)
mainClient = TransformiceBotFactory()
mainClient.protocol = TransformiceBotMainServeurClient
reactor.connectTCP("mainip", 44440, mainClient)
reactor.run()
if __name__ == "__main__":
# running not as imported module
main()
Answer the question
In order to leave comments, you need to log in
So what's stopping you from just adding an attribute to the Factory object?
In the sense that take out mainClient in a more global scope and do mainClient.somedata = blablabla
Aren't transformays banned for bots?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question