本文整理汇总了TypeScript中irc.Client类的典型用法代码示例。如果您正苦于以下问题:TypeScript Client类的具体用法?TypeScript Client怎么用?TypeScript Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(server:string, name:string, options?:IClientOpts, ...plugins: PluginConstructor[]) {
this.client = new Client(server, name, options);
this.plugins = new Array<Plugin>();
this.commands = new Map<string, ICommandHandler>();
this.client.addListener("message", (from:string, to:string, text:string, message:string) => {
for(let p of this.plugins) {
if(Helpers.isMessageHandler(p)) {
p.handleMessage(this.client, from, to, text);
}
}
let parts = text.split(" ");
if(parts.length > 0) {
let cmd = parts[0];
if(this.commands.has(cmd)) {
let handler = this.commands.get(cmd);
if(handler) {
parts.splice(0, 1);
handler.handleCommand(this.client, from, to, cmd, parts.join(" "));
}
}
}
});
this.client.addListener("join", (channel:string, nick:string, messsage:string) => {
});
this.client.addListener("error", (message:string) => {
console.log('error: ', message);
});
for(let p of plugins) {
this.loadPlugin(p);
}
}
开发者ID:AdditionalPylons,项目名称:KawaiiBot,代码行数:32,代码来源:bot.ts
示例2: init
init(): IrcClient {
this.isRunning = false;
this.plugins = getPlugins();
const hooks: HookCollection = new HookCollection(this.plugins);
this.client.addListener('join', (channel: string, nick: string, message: IMessage) => {
const args: api.IrcJoin = { user: nick };
const context: IrcContext<api.IrcJoin> = new IrcContext<api.IrcJoin>(this.name, this.client, args);
hooks.getJoinHooks().forEach((hook: api.PluginHook<api.IrcJoin>) => hook(context));
});
this.client.addListener('message', (nick: string, to: string, text: string, message: IMessage) => {
const args: api.IrcMessage = { user: nick, text: text };
const context: IrcContext<api.IrcMessage> = new IrcContext<api.IrcMessage>(this.name, this.client, args);
hooks.getMessageHooks().forEach((hook: api.PluginHook<api.IrcMessage>) => hook(context));
});
this.client.addListener('names', (channel: string, nicks: string[]) => {
const args: api.IrcNames = { users: nicks };
const context: IrcContext<api.IrcNames> = new IrcContext<api.IrcNames>(this.name, this.client, args);
hooks.getNamesHooks().forEach((hook: api.PluginHook<api.IrcNames>) => hook(context));
});
this.client.addListener('part', (channel: string, nick: string, reason: string, message: IMessage) => {
const args: api.IrcPart = { user: nick };
const context: IrcContext<api.IrcPart> = new IrcContext<api.IrcPart>(this.name, this.client, args);
hooks.getPartHooks().forEach((hook: api.PluginHook<api.IrcPart>) => hook(context));
});
this.client.addListener('error', (message: IMessage) => {
const error: string = JSON.stringify(message);
debugIrc(`${this.name} error: ${error}`);
});
return this;
}
开发者ID:jbuerkel,项目名称:twitchr,代码行数:37,代码来源:ircClient.ts
示例3: debugIrc
this.client.connect(() => {
this.client.send('CAP', 'REQ', 'twitch.tv/membership');
this.client.join(channel, () => {
this.client.say(channel, 'Chat moderation is started');
this.isRunning = true;
debugIrc(`${this.name} started successfully`);
typeof done === 'function' && done();
});
});
开发者ID:jbuerkel,项目名称:twitchr,代码行数:11,代码来源:ircClient.ts
示例4: stop
stop(done?: () => void): void {
if (!this.getIsRunning()) {
typeof done === 'function' && done();
return;
}
const channel: string = '#' + this.name;
this.client.say(channel, 'Chat moderation is stopped');
this.client.part(channel, () => {
this.client.disconnect(() => {
this.isRunning = false;
debugIrc(`${this.name} stopped successfully`);
typeof done === 'function' && done();
});
});
}
开发者ID:jbuerkel,项目名称:twitchr,代码行数:18,代码来源:ircClient.ts
示例5: start
start(done?: () => void): void {
if (this.getIsRunning()) {
typeof done === 'function' && done();
return;
}
const channel: string = '#' + this.name;
this.client.connect(() => {
this.client.send('CAP', 'REQ', 'twitch.tv/membership');
this.client.join(channel, () => {
this.client.say(channel, 'Chat moderation is started');
this.isRunning = true;
debugIrc(`${this.name} started successfully`);
typeof done === 'function' && done();
});
});
}
开发者ID:jbuerkel,项目名称:twitchr,代码行数:20,代码来源:ircClient.ts
示例6: unban
unban(user: string): void {
this.client.say(this.channel, `/unban ${user}`);
}
开发者ID:jbuerkel,项目名称:twitchr,代码行数:3,代码来源:ircContext.ts
示例7: emoteonlyoff
emoteonlyoff(): void {
this.client.say(this.channel, `/emoteonlyoff`);
}
开发者ID:jbuerkel,项目名称:twitchr,代码行数:3,代码来源:ircContext.ts
示例8:
r9kbetaoff(): void {
this.client.say(this.channel, `/r9kbetaoff`);
}
开发者ID:jbuerkel,项目名称:twitchr,代码行数:3,代码来源:ircContext.ts
注:本文中的irc.Client类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论