Twitch PRIVMSG未被发送到其他渠道

时间:2017-10-19 00:23:02

标签: c# bots streamwriter irc twitch

IMG

Conosle.WriteLine(“它工作了!”)它正在所有Twitch.tv/channels上执行

但是......

PRIVMSG #Twitch.tv / channel仅适用于我自己的频道twitch.tv/traps_are_not_gay_baka

我的意思是我可以从我放入频道字符串的任何频道中读取消息,但是PRIVMSG只能使用我自己的频道,当我将其切换为类似Twitch.tv/bakoni的东西时,我发现这是随机频道,用于测试PRIVMSGs只是不要到。

为什么?

编辑:(代码)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text;
using System.Net.Sockets;
using System.IO;
namespace chatrig
{
    class chatrig
    {
        static String ip = "irc.twitch.tv";
        static Int32 port = 6667;

        static String username = "traps_are_not_gay_baka";
        static String password = "oauth:hokzuz***********ebkv5gnb";

        static String clientID = "2lubvv5***********3f2m8orz24c";

        static String channel = "bakoni";

        static TcpClient tcpClient = new TcpClient(ip, port);

        static StreamReader reader = new StreamReader(tcpClient.GetStream());
        static StreamWriter writer = new StreamWriter(tcpClient.GetStream());

        static void Main(string[] args)
        {

            writer.WriteLine("PASS " + password);

            writer.Flush();

            writer.WriteLine("NICK " + username);

            writer.Flush();

            writer.WriteLine("USER " + username + " 8 * :" + username);

            writer.Flush();

            writer.WriteLine("JOIN #" + channel);

            writer.Flush();

            while (true)
            {
                var message = reader.ReadLine();
                Console.WriteLine(message);

                if (message.Contains("yandYo"))
                {
                    writer.WriteLine("PRIVMSG #" + channel + " :" + "w" + "\r\n");

                    writer.Flush();

                    Console.WriteLine("It worked!");
                }
            }
        }

    }

}

1 个答案:

答案 0 :(得分:0)

除了不等待来自IRC服务器的正确响应之外,传出消息的格式是

writer.WriteLine( string.Format( ":{0}!{0}@{0}.tmi.twitch.tv PRIVMSG #{1} :{2}", username, channel, message ) );