新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
制作QQ机器人步骤如下:
莒县网站建设公司创新互联公司,莒县网站设计制作,有大型网站制作公司丰富经验。已为莒县千余家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的莒县做网站的公司定做!
1、百度搜索“第十代QQ机器人”。见下图:
2、解压“第十代QQ机器人”。见下图:
3、之后双击“dsdqqjqr”,登录自己QQ小号,这个小号就是你的QQ机器人。见下图:
4、之后弹出设置页面,进行相关设置后,大号把小号拉进QQ群即可。见下图:
improt java.util.Scanner;
public class chatRobit() {
Scanner scan = new Scanner(System.in);
boolean flag = true;
public static void main(String[] args) {
while(flag){
String str = scan.nextLine();
if(str.equlas("你好")) {
System.out.println("你好");
} else if(str.equlas("再见")) {
System.out.println("再见");
this.flag = false;
} else {
System.out.println("对不起,我不知道你在说什么");
}
}
System.exit(0);
}
}
Server.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
public class Server {
private ListServerThread serverThreads;
private ServerSocket serverSocket;
public Server() throws IOException {
serverSocket = new ServerSocket(8025);
serverThreads = new ArrayListServerThread();
}
public ListServerThread getServerThreads() {
return serverThreads;
}
public void setServerThreads(ListServerThread serverThreads) {
this.serverThreads = serverThreads;
}
public ServerSocket getServerSocket() {
return serverSocket;
}
public void setServerSocket(ServerSocket serverSocket) {
this.serverSocket = serverSocket;
}
public static void main(String[] args) {
Server server = null;
try {
server = new Server();
} catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
try {
Socket socket;
Thread t;
while (true) {
socket = server.getServerSocket().accept();
ServerThread serverThread = new ServerThread(server, socket);
server.getServerThreads().add(serverThread);
t = new Thread(serverThread);
t.start();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void sendMessage(String message, Socket socket) {
for (ServerThread serverThread : serverThreads) {
try {
serverThread.getDos().writeUTF(message);
} catch (IOException e) {
// e.printStackTrace();
System.out.println("推送消息给" + serverThread.getSocket().getRemoteSocketAddress() + "过程中发生了错误.");
}
}
}
}
class ServerThread implements Runnable {
private Server server;
private Socket socket;
private DataInputStream dis;
private DataOutputStream dos;
public ServerThread(Server server, Socket socket) throws IOException {
this.server = server;
this.socket = socket;
dis = new DataInputStream(socket.getInputStream());
dos = new DataOutputStream(socket.getOutputStream());
}
public Server getServer() {
return server;
}
public void setServer(Server server) {
this.server = server;
}
public Socket getSocket() {
return socket;
}
public void setSocket(Socket socket) {
this.socket = socket;
}
public DataInputStream getDis() {
return dis;
}
public void setDis(DataInputStream dis) {
this.dis = dis;
}
public DataOutputStream getDos() {
return dos;
}
public void setDos(DataOutputStream dos) {
this.dos = dos;
}
public void run() {
String message = "";
while (!message.equals("logout")) {
try {
message = socket.getRemoteSocketAddress() + " say: " + dis.readUTF();
// System.out.println(message);
server.sendMessage(message, socket);
} catch (IOException e) {
//e.printStackTrace();
break;
}
}
server.getServerThreads().remove(this);
try {
dis.close();
dos.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Client.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
public class Client {
private Socket socket;
private DataOutputStream dos;
private DataInputStream dis;
public Client() throws UnknownHostException, IOException {
socket = new Socket("127.0.0.1", 8025);
dis = new DataInputStream(socket.getInputStream());
dos = new DataOutputStream(socket.getOutputStream());
new Thread(new ClientThread(this)).start();
}
public Socket getSocket() {
return socket;
}
public void setSocket(Socket socket) {
this.socket = socket;
}
public DataOutputStream getDos() {
return dos;
}
public void setDos(DataOutputStream dos) {
this.dos = dos;
}
public DataInputStream getDis() {
return dis;
}
public void setDis(DataInputStream dis) {
this.dis = dis;
}
public void close() {
try {
dis.close();
dos.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void sendMessage(String message) {
try {
dos.writeUTF(message);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Client client = null;
try {
client = new Client();
System.out.println(client.getSocket().getLocalPort());
} catch (IOException e) {
System.out.println("BUG");
e.printStackTrace();
System.exit(-1);
}
String message = "";
Scanner scanner = new Scanner(System.in);
while (!message.equals("logout")) {
message = scanner.nextLine();
// System.out.println(message);
client.sendMessage(message);
}
scanner.close();
client.close();
}
}
class ClientThread implements Runnable {
private Client client;
public ClientThread(Client client) {
super();
this.client = client;
}
@Override
public void run() {
try {
while (true) {
System.out.println(client.getDis().readUTF());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
OICQ机器人转Java:
1. 下载OICQ SDK并安装:从OICQ官网上下载SDK并安装到你的电脑上。
2. 创建一个新的Java工程:使用Eclipse或者其他IDE来创建一个新的Java工程。
3. 导入OICQ SDK库文件:将SDK中的库文件添加到你的工程中。
4. 生成OICQ机器人代码:根据你想要实现的功能生成相应的代码。
5. 生成可执行文件并测试机器人代码:将生成的代码生成可执行文件并测试机器人代码是否正常工作。