本文整理匯總了TypeScript中slate-irc類的典型用法代碼示例。如果您正苦於以下問題:TypeScript slate-irc類的具體用法?TypeScript slate-irc怎麽用?TypeScript slate-irc使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了slate-irc類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: SlateIRC
/// <reference path="slate-irc.d.ts" />
import * as net from "net";
import * as SlateIRC from "slate-irc";
let socket: net.Socket;
const client = SlateIRC(socket);
client.on("welcome", (name) => {
console.log(client.me);
});
client.on("motd", (event) => {
console.log(event.motd);
});
client.on("join", (event) => {
console.log(`${event.nick} has joined ${event.channel}`);
});
client.on("part", (event) => {
console.log(`${event.nick} has parted ${event.channels.join(", ")}`);
});
client.on("nick", (event) => {
console.log(`${event.nick} is now known as ${event.new}`);
});
client.on("quit", (event) => {
console.log(`${event.nick} has quit (${event.message}).`);
});
示例2: connect
function connect() {
if (socket != null) return;
statusChatTab.addInfo(`Connecting to ${ircNetwork.host}:${ircNetwork.port}...`);
for (const name in channelChatTabs) channelChatTabs[name].addInfo("Connecting...");
for (const name in privateChatTabs) privateChatTabs[name].addInfo("Connecting...");
socket = tls.connect({ host: ircNetwork.host, port: ircNetwork.port, rejectUnauthorized: false }) as any as net.Socket;
socket.on("error", onSocketError);
irc = SlateIRC(socket);
irc.on("welcome", onWelcome);
irc.on("motd", onMOTD);
irc.on("join", onJoin);
irc.on("part", onPart);
irc.on("nick", onNick);
irc.on("away", onAway);
irc.on("quit", onQuit);
irc.on("data", onData);
irc.on("message", onMessage);
irc.on("notice", onNotice);
irc.on("disconnect", onDisconnect);
irc.nick(settings.nickname);
irc.user(settings.nickname, settings.nickname);
}