2018-10-07 18:06:29 +02:00
|
|
|
extern crate irc;
|
|
|
|
|
2019-08-27 15:05:51 +02:00
|
|
|
use futures::prelude::*;
|
2018-10-07 18:06:29 +02:00
|
|
|
use irc::client::prelude::*;
|
|
|
|
use std::default::Default;
|
|
|
|
use std::env;
|
|
|
|
|
2019-08-27 15:05:51 +02:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> irc::error::Result<()> {
|
2018-10-07 18:06:29 +02:00
|
|
|
let repository_slug = env::var("TRAVIS_REPO_SLUG").unwrap();
|
|
|
|
let branch = env::var("TRAVIS_BRANCH").unwrap();
|
|
|
|
let commit = env::var("TRAVIS_COMMIT").unwrap();
|
|
|
|
let commit_message = env::var("TRAVIS_COMMIT_MESSAGE").unwrap();
|
2020-01-29 23:07:22 +01:00
|
|
|
let features = env::var("FEATURES").unwrap();
|
2018-10-07 18:06:29 +02:00
|
|
|
|
|
|
|
let config = Config {
|
|
|
|
nickname: Some("irc-crate-ci".to_owned()),
|
2020-07-23 19:40:10 +02:00
|
|
|
server: Some("chat.freenode.net".to_owned()),
|
2020-01-29 23:07:22 +01:00
|
|
|
alt_nicks: vec!["[irc-crate-ci]".to_owned()],
|
2018-10-07 18:06:29 +02:00
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
|
2019-08-27 15:05:51 +02:00
|
|
|
let mut client = Client::from_config(config).await?;
|
2018-10-07 18:06:29 +02:00
|
|
|
|
2019-08-27 15:05:51 +02:00
|
|
|
client.identify()?;
|
|
|
|
|
|
|
|
let mut stream = client.stream()?;
|
|
|
|
|
|
|
|
while let Some(message) = stream.next().await.transpose()? {
|
2018-10-07 18:06:29 +02:00
|
|
|
match message.command {
|
2020-01-31 01:12:44 +01:00
|
|
|
Command::Response(Response::RPL_ISUPPORT, _) => {
|
2018-10-07 18:06:29 +02:00
|
|
|
client.send_privmsg(
|
|
|
|
"#commits",
|
|
|
|
format!(
|
2020-01-29 23:07:22 +01:00
|
|
|
"[{}/{}] ({}) {} [{}]",
|
2018-10-13 00:11:02 +02:00
|
|
|
repository_slug,
|
|
|
|
branch,
|
|
|
|
&commit[..7],
|
2020-01-29 23:07:22 +01:00
|
|
|
commit_message,
|
|
|
|
features,
|
2018-10-07 18:06:29 +02:00
|
|
|
),
|
|
|
|
)?;
|
2019-08-27 15:05:51 +02:00
|
|
|
|
2018-10-07 18:06:29 +02:00
|
|
|
client.send_quit("QUIT")?;
|
|
|
|
}
|
|
|
|
_ => (),
|
2019-08-27 15:05:51 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-07 18:06:29 +02:00
|
|
|
|
2019-08-27 15:05:51 +02:00
|
|
|
Ok(())
|
2018-10-07 18:06:29 +02:00
|
|
|
}
|