當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript slate-irc類代碼示例

本文整理匯總了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}).`);
});
開發者ID:0815fox,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:slate-irc-tests.ts

示例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);
}
開發者ID:AgileJoshua,項目名稱:superpowers-app,代碼行數:26,代碼來源:index.ts


注:本文中的slate-irc類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。