<commit_before>/*
 * This example imitates the behavior of a friend of mine that often times out on irc.
 * The server often lets you know that he hasn't received any message from the past 5
 * minutes (time out). This program simulates the behavior by not replying to ping
 * messages sent by the server. The server ends up closing the connection since it
 * believes it's dead. The program will reconnect to the server right after disconnecting.
 * The behavior is triggered when you speak to the bot using its nickname.
 */
#![allow(unused_variables)]
#![allow(unused_must_use)]

extern crate hiirc;

use hiirc::*;

struct Fifteen {
    reply_to_ping: bool,
}

static NICKNAME: &'static str = "fifteenistimeout";
static USERNAME: &'static str = "hiirc";
static REALNAME: &'static str = "Fifteen should stop timing out";

impl Listener for Fifteen {

    fn any(&mut self, irc: &Irc, event: &Event) {
        println!("{:?}", event);
    }

    fn channel_msg(&mut self, irc: &Irc, channel: &Channel, user: &ChannelUser, msg: &str) {
        if msg.starts_with(NICKNAME) {
            self.reply_to_ping = false;
        }
    }

    fn ping(&mut self, irc: &Irc, server: &str) {
        if self.reply_to_ping {
            irc.pong(server);
        }
    }<commit_msg>examples/fifteen: Fix FifteenIsTimeout capitalization<commit_after>/*
 * This example imitates the behavior of a friend of mine that often times out on irc.
 * The server often lets you know that he hasn't received any message from the past 5
 * minutes (time out). This program simulates the behavior by not replying to ping
 * messages sent by the server. The server ends up closing the connection since it
 * believes it's dead. The program will reconnect to the server right after disconnecting.
 * The behavior is triggered when you speak to the bot using its nickname.
 */
#![allow(unused_variables)]
#![allow(unused_must_use)]

extern crate hiirc;

use hiirc::*;

struct Fifteen {
    reply_to_ping: bool,
}

static NICKNAME: &'static str = "F<PASSWORD>";
static USERNAME: &'static str = "hiirc";
static REALNAME: &'static str = "Fif<PASSWORD> should stop timing out";

impl Listener for Fifteen {

    fn any(&mut self, irc: &Irc, event: &Event) {
        println!("{:?}", event);
    }

    fn channel_msg(&mut self, irc: &Irc, channel: &Channel, user: &ChannelUser, msg: &str) {
        if msg.starts_with(NICKNAME) {
            self.reply_to_ping = false;
        }
    }

    fn ping(&mut self, irc: &Irc, server: &str) {
        if self.reply_to_ping {
            irc.pong(server);
        }
    }
{'fraction_non_alphanumeric': 0.10375532326751839, 'fraction_numerical': 0.0007742934572202865, 'mean_word_length': 3.3283082077051924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6394692', 'n_tokens_mistral': 821, 'n_tokens_neox': 786, 'n_words': 311}