Domanda

I'm using the markov chain irc bot based on twisted. Socks proxy may be putty, listening on port 22. Adding the following code to the above client (at the top of the py file) didn't help:

import socks, socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,
    'localhost', 22)
socket.socket = socks.socksocket

Whereas, doing so solved the problem while using SimpleIRCClient from irclib, however irclib doesn't fit other requirements.

Thanks.

È stato utile?

Soluzione 2

Thanks Jean-Paul Calderone. The following code worked for me.

from twisted.internet.endpoints import TCP4ClientEndpoint 
from txsocksx.client import SOCKS5ClientEndpoint

if __name__ == "__main__":
    chan = "django-hotclub"
    chain_length = 5

    myID = sys.argv[1]
    counterpartID = sys.argv[2]

    puttyEndPoint = TCP4ClientEndpoint(reactor, '127.0.0.1', 22)
    ircEndpoint = SOCKS5ClientEndpoint('irc.freenode.net', 6667, puttyEndPoint)
    d = ircEndpoint.connect(MomBotFactory('#' + chan, myID, counterpartID, chain_length, chattiness=0.05))
    reactor.run()

Altri suggerimenti

Use a socks client library - https://github.com/habnabit/txsocksx.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top