Question

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.

Was it helpful?

Solution 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()

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top