?list command
This commit is contained in:
джерело
3c5d7e3378
коміт
f3de4c6916
|
@ -1,33 +0,0 @@
|
|||
use futures::prelude::*;
|
||||
use irc::client::prelude::*;
|
||||
use std::time::Duration;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> irc::error::Result<()> {
|
||||
let config = Config {
|
||||
nickname: Some("wumpscut".to_owned()),
|
||||
server: Some("ircd.chat".to_owned()),
|
||||
channels: vec!["#tcpdirect".to_owned()],
|
||||
port: Some(6697),
|
||||
use_tls: Some(true),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mut client = Client::from_config(config).await?;
|
||||
client.identify()?;
|
||||
|
||||
let mut stream = client.stream()?;
|
||||
let mut interval = tokio::time::interval(Duration::from_secs(10)).fuse();
|
||||
|
||||
loop {
|
||||
futures::select! {
|
||||
m = stream.select_next_some() => {
|
||||
println!("{}", m?);
|
||||
}
|
||||
_ = interval.select_next_some() => {
|
||||
client.send_privmsg("#tcpdirect", ".[d]. ssl+insecure rust bot")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -80,7 +80,7 @@ use crate::{
|
|||
CapSubCommand::{END, LS, REQ},
|
||||
Capability, ChannelMode, Command,
|
||||
Command::{
|
||||
ChannelMODE, AUTHENTICATE, CAP, INVITE, JOIN, KICK, KILL, NICK, NICKSERV, NOTICE, OPER,
|
||||
ChannelMODE, AUTHENTICATE, CAP, INVITE, JOIN, KICK, KILL, LIST, NICK, NICKSERV, NOTICE, OPER,
|
||||
PART, PASS, PONG, PRIVMSG, QUIT, SAMODE, SANICK, TOPIC, USER,
|
||||
},
|
||||
Message, Mode, NegotiationVersion, Response,
|
||||
|
@ -212,6 +212,25 @@ macro_rules! pub_sender_base {
|
|||
self.send(OPER(username.to_string(), password.to_string()))
|
||||
}
|
||||
|
||||
/// decoded wuz here : adding in access to list command
|
||||
/// decoded wuz here : adding in access to list command
|
||||
/// LIST [chanlist :[target]]
|
||||
/// LIST(Option<String>, Option<String>),
|
||||
/// decoded wuz here : adding in access to list command
|
||||
/// decoded wuz here : adding in access to list command
|
||||
|
||||
pub fn send_chanlist<S1, S2>(&self, chanlist: S1, target: S2) -> error::Result<()>
|
||||
where
|
||||
S1: fmt::Display,
|
||||
S2: fmt::Display,
|
||||
{
|
||||
self.send(LIST(Some(chanlist.to_string()), Some(target.to_string())));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// Sends a message to the specified target. If the message contains IRC newlines (`\r\n`), it
|
||||
/// will automatically be split and sent as multiple separate `PRIVMSG`s to the specified
|
||||
/// target. If you absolutely must avoid this behavior, you can do
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -1,7 +1,7 @@
|
|||
use futures::prelude::*;
|
||||
use irc::{client::prelude::*, error};
|
||||
//use std::time::Duration;
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> irc::error::Result<()> {
|
||||
env_logger::init();
|
||||
|
@ -54,10 +54,20 @@ fn process_msg(sender: &Sender, message: Message) -> error::Result<()> {
|
|||
sender.send_privmsg(target, ircmsg)?;
|
||||
if bothelpcmd == &"?list" {
|
||||
sender.send_privmsg(target, "performing list operation")?;
|
||||
sender.send_chanlist("","")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::Response(Response::RPL_LISTSTART, _) => {
|
||||
sender.send_privmsg("#sh0rtbus", "321 start of channel list")?;
|
||||
}
|
||||
Command::Response(Response::RPL_LIST, _) => {
|
||||
sender.send_privmsg("#sh0rtbus", message)?;
|
||||
}
|
||||
Command::Response(Response::RPL_LISTEND, _) => {
|
||||
sender.send_privmsg("#sh0rtbus", "323 end of channel list")?;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
|
Завантаження…
Посилання в новій задачі