private void TwitchUserDetailForm_Load(object sender, EventArgs e) { var ids = TwitchApiTools.GetUserIds(new List <string>() { channelName, targetName }); var datas = TwitchApiTools.GetTwitchChannel(ids.Values); channel = datas[channelName]; target = datas[targetName]; Text = target.SimpleDescription + " @ " + channel.SimpleDescription; UserNameLabel.Text = $"대상 유저: {target.SimpleDescription}"; }
public static FollowCache GetFollowData(string channel, string id) { if (!FollowData.ContainsKey(channel)) { FollowData[channel] = new Dictionary <string, FollowCache>(); } var dict = FollowData[channel]; if (dict.ContainsKey(id)) { return(dict[id]); } var follow = new FollowCache(TwitchApiTools.GetFollowLong(channel, id)); dict[id] = follow; return(follow); }
private void OnChannelJoin(ChannelJoinArgs argument) { //Check if this event was fired on twitch, if not this plugin should //never touch it so fires an early return. if (!IsTwitchServer(argument.Channel.Server)) { return; } var server = argument.Channel.Server; var channelName = argument.Channel.Name; var userName = argument.Channel.Name.TrimStart('#'); string topicData; //Check if this event fired on the client joining the channel or //someone else joining, we only need to set the topic of a channel //when we join a channel. if (argument.User.Nick != argument.Channel.Server.Nick) { return; } //TwitchApiTools connects to the web, disk or web IO is unreliable //so handle it in a try / catch block try { topicData = TwitchApiTools.GetSimpleChannelInformationByName(userName); } catch (Exception) { topicData = $"Twitch@AdiIRC: Could not find channel topic data for {userName}."; } //Finally set the topic title through a raw IRC message. var topicMessage = $":[email protected] TOPIC {channelName} :{topicData}"; server.SendFakeRaw(topicMessage); }
private void TopicUpdate() { //Find any twitch server connections in the serverlist. there might be //more than one and there might be none so storing it statically is impractical foreach (IServer server in _host.GetServers) { if (IsTwitchServer(server)) { var channels = server.GetChannels; //Iterate over all channels, updating the topic. foreach (IChannel channel in channels) { string topicData; var userName = channel.Name.TrimStart('#'); //TwitchApiTools connects to the web, disk or web IO is unreliable //so handle it in a try / catch block try { topicData = TwitchApiTools.GetSimpleChannelInformationByName(userName); } catch (Exception) { topicData = $"Twitch@AdiIRC: Could not find channel topic data for {userName}."; } //AdiIRC will let you set a topic to the same thing, this avoids repetitive topic updates. if (channel.Topic != topicData) { var topicMessage = $":[email protected] TOPIC #{userName} :{topicData}"; server.SendFakeRaw(topicMessage); } } } } }
public void TestMethod1() { var how = TwitchApiTools.GetFollowLong("lilac_unicorn_", "leekcake"); Assert.AreEqual(127, how); }