IRC checking if channel exists

I was simply wondering, (while I suspect it is not possible), if there’s any way to check whether the channel that someone is trying to connect to exists or not.
I currently have an application where the user can enter a channel name in a text box and hit a start button, this will then start to read chat data, however, i was wondering if I could check whether or not said channel exists and alert the user that they are trying to access a channel that doesn’t exist.

I can think of 2 ways…

1.) While joining a channel via IRC, if the channel exists you will join it and receive these raw notices:

<- :matt_thomas!matt_thomas@matt_thomas.tmi.twitch.tv JOIN #savage
-> tmi.twitch.tv MODE #savage
<- :matt_thomas.tmi.twitch.tv 353 matt_thomas = #savage :matt_thomas
<- :matt_thomas.tmi.twitch.tv 366 matt_thomas #savage :End of /NAMES list

If you try to join a channel that doesn’t exist then you would stop at:

-> tmi.twitch.tv JOIN #derpdddd

Based on that you could have a timer/check for the NAMES or MODE notice within a second or 2, and if it never showed up, notify the use the channel doesn’t exist. This of course requires the user to actually join the channel.

2.) Before executing the JOIN command query the API.

A query to https://api.twitch.tv/kraken/channels/derpddd results in:

{
error: “Not Found”,
status: 404,
message: “Channel ‘derpddd’ does not exist”
}

Whereas a query for an existing channel like https://api.twitch.tv/kraken/channels/savage results in:

{
mature: null,
status: null,
broadcaster_language: null,
display_name: “Savage”,
game: null,
language: “en”,
_id: 11952,
name: “savage”,
created_at: “2007-05-22T10:39:47Z”,
updated_at: “2016-05-11T07:30:24Z”,
delay: null,
logo: null,
banner: null,
video_banner: null,
background: null,
profile_banner: null,
profile_banner_background_color: null,
partner: false,
url: “https://www.twitch.tv/savage”,
views: 874,
followers: 6,
_links: {
self: “https://api.twitch.tv/kraken/channels/savage”,
follows: “https://api.twitch.tv/kraken/channels/savage/follows”,
commercial: “https://api.twitch.tv/kraken/channels/savage/commercial”,
stream_key: “https://api.twitch.tv/kraken/channels/savage/stream_key”,
chat: “https://api.twitch.tv/kraken/chat/savage”,
features: “https://api.twitch.tv/kraken/channels/savage/features”,
subscriptions: “https://api.twitch.tv/kraken/channels/savage/subscriptions”,
editors: “https://api.twitch.tv/kraken/channels/savage/editors”,
teams: “https://api.twitch.tv/kraken/channels/savage/teams”,
videos: “https://api.twitch.tv/kraken/channels/savage/videos
}
}

Depending on your IRC method, an API call should be fairly easy to implement.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.