Skip to content

Instantly share code, notes, and snippets.

@taketin
Created January 17, 2012 03:33
Show Gist options
  • Save taketin/1624453 to your computer and use it in GitHub Desktop.
Save taketin/1624453 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding:utf8 -*-
import socket, ssl
network = '' #host
port = 6668
# 以下変数を編集して使ってください -------------------------------------------#
chan = '#' #チャンネル
nick = 'test-bot' #nick
msg = u'PRIVMSG %(chan)s :\x034\x02(ここに発言内容)\x03\x02 \r\n' % locals()
msg2 = u'PRIVMSG %(chan)s :\x034\x02(ここに発言内容)\x03\x02 \r\n' % locals()
msg = msg.encode('iso-2022-jp')
msg2 = msg2.encode('iso-2022-jp')
#----------------------------------------------------------------------#
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect ((network, port))
irc = ssl.wrap_socket(s) # SSL接続の場合
irc.send ('PASS ********\r\n') #pass
irc.send ('NICK %(nick)s \r\n' % locals())
irc.send ('USER %(nick)s localhost localhost :%(nick)s\r\n' % locals())
irc.send ('JOIN %(chan)s \r\n' % locals())
irc.send ('%(msg)s \r\n' % locals())
irc.send ('%(msg2)s' % locals())
irc.send ('PART %(nick)s\r\n' % locals())
irc.send ('QUIT\r\n')
irc.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment