大一统 - 完全微米黑美化方案
时间:2010-08-22
来源:互联网
无聊了做的


响应10楼,先吧代码贴出来,供大家研究
irc的主程序
写的有些乱,如果链接成功,这时断网的话,就会死循环

# coding=utf-8
# FileName: irc.py
import socket
import time
import re
roomname= '#ubuntu-cn'
network = 'irc.ubuntu.com'
botname= 'XXCscomputer'
logpath= '/home/xxc/.conky/irclog.txt'
msgfile= '/tmp/my_irc_bot_sendto.txt'
port = 6667
try:
sendmsgfile=open('/tmp/my_irc_bot_sendto.txt')
sendmsgb=sendmsgfile.readline()
sendmsgfile.close()
except:
print '初始文件为空'
while True:
ircsloop=True
while ircsloop:
try:
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect (( network, port))
irc.send ( 'NICK '+botname+'\r\n' )
irc.send ( 'USER XXC@_@ XXC@_@ XXC@_@ :XXCbot1.0beta\r\n' )
irc.send ( ('JOIN '+roomname +'\r\n') )
# irc.send ( 'PRIVMSG #ubuntu-cn XXC\'s傻傻的电脑来了~~~~~~我悄悄的注视着你们.....囧....\r\n' )
ircsloop=False
except:
print '链接失败,10秒后重练'
time.sleep(10)
irc.close()
ircsloop=True
#=======
ircsloop=True
while ircsloop: #登录后循环
data=''
sendmsg=''
ircloop=0
while data=='':
irc.settimeout(2)
print '读取远程数据'
try:
data = irc.recv ( 4096 )
ircloop=0
except:
ircloop=ircloop+1
#发送消息
try:
sendmsgfile=open('/tmp/my_irc_bot_sendto.txt')
sendmsg=sendmsgfile.readline()
sendmsgfile.close()
if len(sendmsg)>0:
if sendmsg!=sendmsgb:
print '发送消息:'+sendmsg
sendmsgb=sendmsg
irc.send('PRIVMSG '+roomname+' :'+sendmsg+'\r\n')
logfile=open(logpath,'a')
logfile.write('I>:'+sendmsg)
logfile.close()
sendmsg=''
except:
print '获取文件数据失败'
if ircloop>100:
print '接受数据超时,尝试重播'
irc.close()
ircsloop=False
print '关闭socket'
break
if ircsloop == False:
break #跳出登录循环,重新登录
try:
utfdata=(data).encode("UTF-8")
except:
utfdata=data
lines = data.split('\r\n')
#=========================响应服务器
for line in lines:
word_list = line.split()
if line.find ( 'PING' ) != -1:
irc.send ( 'PONG ' + word_list[1] + '\r\n' )
print '主机轮询: irc.send ( \'PONG '+word_list[1]+'\r\n'
#========================
# print 'info',utfdata
if utfdata.find('PRIVMSG') >= 0:
# print '收到数据,开始分析'
if utfdata.find(roomname) >= 0:
get_msg_from_irc=utfdata.split(roomname)[1]
msg_send_user=utfdata.split('!')[0]
elif utfdata.find(botname) >= 0:
get_msg_from_irc=utfdata.split(botname)[1]
msg_send_user=utfdata.split('!')[0]
else:
get_msg_from_irc=utfdata.split('PRIVMSG')[1]
msg_send_user=utfdata.split('!')[0]
#================bot
if msg_send_user.split(':')[1].find('xxc')>=0:
if get_msg_from_irc.find('bot out')>=0:
irc.send('PRIVMSG '+roomname+' :死bot:轻轻地\"抱\"走了....正如\"宝\"轻轻的来....囧....\r\n')
irc.send('QUIT\r\n')
irc.close()
quit()
else:
if get_msg_from_irc.find('bot')>=0:
if get_msg_from_irc.find('bot out'):
irc.send('PRIVMSG '+roomname+' :'+msg_send_user+'你好狠心啊~~想让我走...呜呜..臭男人..\r\n')
irc.send('PRIVMSG '+roomname+'看到bot,出来毛个泡\r\n')
elif get_msg_from_irc.find('XXCscomputer')>=0:
irc.send('PRIVMSG '+roomname+'其实这只是一只死bot\r\n')
elif get_msg_from_irc.find('有人吗')>=0:
irc.send('PRIVMSG '+roomname+'有\r\n')
elif get_msg_from_irc.find('在吗')>=0:
irc.send('PRIVMSG '+roomname+'死bot给您请安了~~~\r\n')
#===============记录
try:
logfile=open(logpath,'a')
logfile.write(msg_send_user.split(':')[1]+get_msg_from_irc)
logfile.close()
print "写入:"+msg_send_user.split(':')[1]+get_msg_from_irc
except:
print '出错了'
消息发送sh脚本:
msg=`zenity --entry --width=800 --timeout=200 --text='向聊天室发送消息' --title='IRC bot @_@' --name='IRC bot send MSG'`
if [ -n msg ]
then
echo "${msg}" >/tmp/my_irc_bot_sendto.txt
fi
作者: x007007007 发布时间: 2010-08-22

作者: peteryeh64 发布时间: 2010-08-22
作者: jxhow 发布时间: 2010-08-22
作者: snowtown86 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


作者: x007007007 发布时间: 2010-08-22
输入可以用快捷键调出个 zenity 窗口,然后在里面输入。
作者: xiooli 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


靠,咱俩想到一块去了。。。
作者: xiooli 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


靠,咱俩想到一块去了。。。
就是哦~~还发到一快了

作者: x007007007 发布时间: 2010-08-22

作者: adagio 发布时间: 2010-08-22
作者: adagio 发布时间: 2010-08-22
开销,比开一个irssi,估计都大。
作者: eexpress 发布时间: 2010-08-22
无聊了做的


响应10楼,先吧代码贴出来,供大家研究
irc的主程序
写的有些乱,如果链接成功,这时断网的话,就会死循环

# coding=utf-8
# FileName: irc.py
import socket
import time
import re
roomname= '#ubuntu-cn'
network = 'irc.ubuntu.com'
botname= 'XXCscomputer'
logpath= '/home/xxc/.conky/irclog.txt'
msgfile= '/tmp/my_irc_bot_sendto.txt'
port = 6667
try:
sendmsgfile=open('/tmp/my_irc_bot_sendto.txt')
sendmsgb=sendmsgfile.readline()
sendmsgfile.close()
except:
print '初始文件为空'
while True:
ircsloop=True
while ircsloop:
try:
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect (( network, port))
irc.send ( 'NICK '+botname+'\r\n' )
irc.send ( 'USER XXC@_@ XXC@_@ XXC@_@ :XXCbot1.0beta\r\n' )
irc.send ( ('JOIN '+roomname +'\r\n') )
# irc.send ( 'PRIVMSG #ubuntu-cn XXC\'s傻傻的电脑来了~~~~~~我悄悄的注视着你们.....囧....\r\n' )
ircsloop=False
except:
print '链接失败,10秒后重练'
time.sleep(10)
irc.close()
ircsloop=True
#=======
ircsloop=True
while ircsloop: #登录后循环
data=''
sendmsg=''
ircloop=0
while data=='':
irc.settimeout(2)
print '读取远程数据'
try:
data = irc.recv ( 4096 )
ircloop=0
except:
ircloop=ircloop+1
#发送消息
try:
sendmsgfile=open('/tmp/my_irc_bot_sendto.txt')
sendmsg=sendmsgfile.readline()
sendmsgfile.close()
if len(sendmsg)>0:
if sendmsg!=sendmsgb:
print '发送消息:'+sendmsg
sendmsgb=sendmsg
irc.send('PRIVMSG '+roomname+' :'+sendmsg+'\r\n')
logfile=open(logpath,'a')
logfile.write('I>:'+sendmsg)
logfile.close()
sendmsg=''
except:
print '获取文件数据失败'
if ircloop>100:
print '接受数据超时,尝试重播'
irc.close()
ircsloop=False
print '关闭socket'
break
if ircsloop == False:
break #跳出登录循环,重新登录
try:
utfdata=(data).encode("UTF-8")
except:
utfdata=data
lines = data.split('\r\n')
#=========================响应服务器
for line in lines:
word_list = line.split()
if line.find ( 'PING' ) != -1:
irc.send ( 'PONG ' + word_list[1] + '\r\n' )
print '主机轮询: irc.send ( \'PONG '+word_list[1]+'\r\n'
#========================
# print 'info',utfdata
if utfdata.find('PRIVMSG') >= 0:
# print '收到数据,开始分析'
if utfdata.find(roomname) >= 0:
get_msg_from_irc=utfdata.split(roomname)[1]
msg_send_user=utfdata.split('!')[0]
elif utfdata.find(botname) >= 0:
get_msg_from_irc=utfdata.split(botname)[1]
msg_send_user=utfdata.split('!')[0]
else:
get_msg_from_irc=utfdata.split('PRIVMSG')[1]
msg_send_user=utfdata.split('!')[0]
#================bot
if msg_send_user.split(':')[1].find('xxc')>=0:
if get_msg_from_irc.find('bot out')>=0:
irc.send('PRIVMSG '+roomname+' :死bot:轻轻地\"抱\"走了....正如\"宝\"轻轻的来....囧....\r\n')
irc.send('QUIT\r\n')
irc.close()
quit()
else:
if get_msg_from_irc.find('bot')>=0:
if get_msg_from_irc.find('bot out'):
irc.send('PRIVMSG '+roomname+' :'+msg_send_user+'你好狠心啊~~想让我走...呜呜..臭男人..\r\n')
irc.send('PRIVMSG '+roomname+'看到bot,出来毛个泡\r\n')
elif get_msg_from_irc.find('XXCscomputer')>=0:
irc.send('PRIVMSG '+roomname+'其实这只是一只死bot\r\n')
elif get_msg_from_irc.find('有人吗')>=0:
irc.send('PRIVMSG '+roomname+'有\r\n')
elif get_msg_from_irc.find('在吗')>=0:
irc.send('PRIVMSG '+roomname+'死bot给您请安了~~~\r\n')
#===============记录
try:
logfile=open(logpath,'a')
logfile.write(msg_send_user.split(':')[1]+get_msg_from_irc)
logfile.close()
print "写入:"+msg_send_user.split(':')[1]+get_msg_from_irc
except:
print '出错了'
消息发送sh脚本:
msg=`zenity --entry --width=800 --timeout=200 --text='向聊天室发送消息' --title='IRC bot @_@' --name='IRC bot send MSG'`
if [ -n msg ]
then
echo "${msg}" >/tmp/my_irc_bot_sendto.txt
fi
作者: x007007007 发布时间: 2010-08-22

作者: peteryeh64 发布时间: 2010-08-22
作者: jxhow 发布时间: 2010-08-22
作者: snowtown86 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


作者: x007007007 发布时间: 2010-08-22
输入可以用快捷键调出个 zenity 窗口,然后在里面输入。
作者: xiooli 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


靠,咱俩想到一块去了。。。
作者: xiooli 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


靠,咱俩想到一块去了。。。
就是哦~~还发到一快了

作者: x007007007 发布时间: 2010-08-22

作者: adagio 发布时间: 2010-08-22
作者: adagio 发布时间: 2010-08-22
开销,比开一个irssi,估计都大。
作者: eexpress 发布时间: 2010-08-22
无聊了做的



Screenshot.png [ 1.41 MiB | 被浏览 66 次 ]
响应10楼,先吧代码贴出来,供大家研究
irc的主程序
写的有些乱,如果链接成功,这时断网的话,就会死循环

# coding=utf-8
# FileName: irc.py
import socket
import time
import re
roomname= '#ubuntu-cn'
network = 'irc.ubuntu.com'
botname= 'XXCscomputer'
logpath= '/home/xxc/.conky/irclog.txt'
msgfile= '/tmp/my_irc_bot_sendto.txt'
port = 6667
try:
sendmsgfile=open('/tmp/my_irc_bot_sendto.txt')
sendmsgb=sendmsgfile.readline()
sendmsgfile.close()
except:
print '初始文件为空'
while True:
ircsloop=True
while ircsloop:
try:
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect (( network, port))
irc.send ( 'NICK '+botname+'\r\n' )
irc.send ( 'USER XXC@_@ XXC@_@ XXC@_@ :XXCbot1.0beta\r\n' )
irc.send ( ('JOIN '+roomname +'\r\n') )
# irc.send ( 'PRIVMSG #ubuntu-cn XXC\'s傻傻的电脑来了~~~~~~我悄悄的注视着你们.....囧....\r\n' )
ircsloop=False
except:
print '链接失败,10秒后重练'
time.sleep(10)
irc.close()
ircsloop=True
#=======
ircsloop=True
while ircsloop: #登录后循环
data=''
sendmsg=''
ircloop=0
while data=='':
irc.settimeout(2)
print '读取远程数据'
try:
data = irc.recv ( 4096 )
ircloop=0
except:
ircloop=ircloop+1
#发送消息
try:
sendmsgfile=open('/tmp/my_irc_bot_sendto.txt')
sendmsg=sendmsgfile.readline()
sendmsgfile.close()
if len(sendmsg)>0:
if sendmsg!=sendmsgb:
print '发送消息:'+sendmsg
sendmsgb=sendmsg
irc.send('PRIVMSG '+roomname+' :'+sendmsg+'\r\n')
logfile=open(logpath,'a')
logfile.write('I>:'+sendmsg)
logfile.close()
sendmsg=''
except:
print '获取文件数据失败'
if ircloop>100:
print '接受数据超时,尝试重播'
irc.close()
ircsloop=False
print '关闭socket'
break
if ircsloop == False:
break #跳出登录循环,重新登录
try:
utfdata=(data).encode("UTF-8")
except:
utfdata=data
lines = data.split('\r\n')
#=========================响应服务器
for line in lines:
word_list = line.split()
if line.find ( 'PING' ) != -1:
irc.send ( 'PONG ' + word_list[1] + '\r\n' )
print '主机轮询: irc.send ( \'PONG '+word_list[1]+'\r\n'
#========================
# print 'info',utfdata
if utfdata.find('PRIVMSG') >= 0:
# print '收到数据,开始分析'
if utfdata.find(roomname) >= 0:
get_msg_from_irc=utfdata.split(roomname)[1]
msg_send_user=utfdata.split('!')[0]
elif utfdata.find(botname) >= 0:
get_msg_from_irc=utfdata.split(botname)[1]
msg_send_user=utfdata.split('!')[0]
else:
get_msg_from_irc=utfdata.split('PRIVMSG')[1]
msg_send_user=utfdata.split('!')[0]
#================bot
if msg_send_user.split(':')[1].find('xxc')>=0:
if get_msg_from_irc.find('bot out')>=0:
irc.send('PRIVMSG '+roomname+' :死bot:轻轻地\"抱\"走了....正如\"宝\"轻轻的来....囧....\r\n')
irc.send('QUIT\r\n')
irc.close()
quit()
else:
if get_msg_from_irc.find('bot')>=0:
if get_msg_from_irc.find('bot out'):
irc.send('PRIVMSG '+roomname+' :'+msg_send_user+'你好狠心啊~~想让我走...呜呜..臭男人..\r\n')
irc.send('PRIVMSG '+roomname+'看到bot,出来毛个泡\r\n')
elif get_msg_from_irc.find('XXCscomputer')>=0:
irc.send('PRIVMSG '+roomname+'其实这只是一只死bot\r\n')
elif get_msg_from_irc.find('有人吗')>=0:
irc.send('PRIVMSG '+roomname+'有\r\n')
elif get_msg_from_irc.find('在吗')>=0:
irc.send('PRIVMSG '+roomname+'死bot给您请安了~~~\r\n')
#===============记录
try:
logfile=open(logpath,'a')
logfile.write(msg_send_user.split(':')[1]+get_msg_from_irc)
logfile.close()
print "写入:"+msg_send_user.split(':')[1]+get_msg_from_irc
except:
print '出错了'
消息发送sh脚本:
msg=`zenity --entry --width=800 --timeout=200 --text='向聊天室发送消息' --title='IRC bot @_@' --name='IRC bot send MSG'`
if [ -n msg ]
then
echo "${msg}" >/tmp/my_irc_bot_sendto.txt
fi
作者: x007007007 发布时间: 2010-08-22

作者: peteryeh64 发布时间: 2010-08-22
作者: jxhow 发布时间: 2010-08-22
作者: snowtown86 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


作者: x007007007 发布时间: 2010-08-22
输入可以用快捷键调出个 zenity 窗口,然后在里面输入。
作者: xiooli 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


靠,咱俩想到一块去了。。。
作者: xiooli 发布时间: 2010-08-22
可以通过快捷键调运一个zenity对话框,快速回复


靠,咱俩想到一块去了。。。
就是哦~~还发到一快了

作者: x007007007 发布时间: 2010-08-22

作者: adagio 发布时间: 2010-08-22
作者: adagio 发布时间: 2010-08-22
开销,比开一个irssi,估计都大。
作者: eexpress 发布时间: 2010-08-22
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28