我不能让我的简单机器人转发私人信息。 例如 - 我的机器人收到消息“明天我需要好好睡觉”然后我的机器人需要在特定频道转发消息。
我怎样才能做到这一点?
import socket
from random import *
beenShot = False
count = randint(0, 5)
network = 'irc.p2p-network.net'
channel = "#channel"
nick = 'nick'
password = 'pass'
nickserv = 'NickServ'
System = 'System'
channel2 = "#chan2"
port = 6667
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
irc.connect((network, port))
irc.send('NICK ' + nick + '\r\n')
irc.send('USER ' + nick + ' ' + nick + ' ' + nick + ' ' + ':YoByMe\r\n')
irc.send('JOIN ' + channel + '\r\n')
irc.send('PRIVMSG ' + nickserv + ' :identify pass\r\n')
while True:
data = irc.recv(128)
if data.find('PING') != -1:
irc.send('PONG ' + data.split()[1] + '\r\n')
if data.find('KICK') != -1:
irc.send('JOIN ' + channel + '\r\n')
if data.find('!!!bot quit') != -1:
irc.send('PRIVMSG ' + channel + ' :Alright, I\'ll quit then...\r\n')
irc.send('QUIT\r\n')
if data.find('!!!hello' or '!hi') != -1:
irc.send('PRIVMSG ' + channel + ' :Hello\r\n')
if data.find('!!!help') != -1:
irc.send('PRIVMSG ' + channel + ' :All commands begin with ! and are as follows: '
'hi / hello, slap, 8ball / 8b, and russianRoulette / rr\r\n')
def ask():
ask_responses = ["Yes", "No"]
#Prints to the IRC chat
irc.send('PRIVMSG ' + channel + ' :' + choice(ask_responses) + '\r\n')
def eightBall():
ball_responses = ......
irc.send('PRIVMSG ' + channel + ' :' + choice(ball_responses) + '\r\n')
def russianRoulette():
global count
global beenShot
gun_responces = ['*Click*', '*Click*', '*Click*', '*Click*', '*Click*', '*BANG*']
if beenShot:
irc.send('PRIVMSG ' + channel + ' *Reloading*\r\n')
count = randint(0, 5)
beenShot = False
irc.send('PRIVMSG ' + channel + ' :' + gun_responces[count] + '\r\n')
if count == 5:
beenShot = True
else:
count += 1
if data.find('!!!slap') != -1:
irc.send('PRIVMSG ' + channel + ' :Come on man, why you got to be like that?\r\n')
if data.find('!!!ask' or '!a') != -1:
ask()
if data.find(',!!!8b' or ',!8ball') != -1:
eightBall()
if data.find('!!!rr' or '!russianRoulette') != -1:
russianRoulette()
if data.find('please choose a different nick') != -1:
irc.send('PRIVMSG ' + nickserv + ' :identify pass\r\n')
if data.find('INVITE nick') != -1:
irc.send('JOIN ' + channel2 + '\r\n')
if data.find('nick :show') != -1:
irc.send('PRIVMSG ' + System + ' :show\r\n')