add custom feed
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
				
			This commit is contained in:
		 Submodule .config/ai/scpt updated: b16ed58552...70595e1951
									
								
							
							
								
								
									
										495
									
								
								src/bot.rs
									
									
									
									
									
								
							
							
						
						
									
										495
									
								
								src/bot.rs
									
									
									
									
									
								
							| @@ -7,6 +7,7 @@ use crate::openai; | ||||
| use crate::refresh; | ||||
| use crate::reply; | ||||
| use crate::reply_link; | ||||
| use crate::feed_get; | ||||
|  | ||||
| use crate::data::c_char; | ||||
| use crate::data::data_scpt; | ||||
| @@ -508,3 +509,497 @@ pub fn c_bot(c: &Context) { | ||||
|     let res = tokio::runtime::Runtime::new().unwrap().block_on(h); | ||||
|     return res; | ||||
| } | ||||
|  | ||||
| pub fn c_bot_feed(c: &Context) { | ||||
|     let h = async { | ||||
|         let mut notify = feed_get::get_request("at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.generator/aaangd4aqzqgu".to_string()).await; | ||||
|         if notify == "err" { | ||||
|             refresh(c); | ||||
|             notify = feed_get::get_request("at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.generator/aaangd4aqzqgu".to_string()).await; | ||||
|         } | ||||
|         let notify: Notify = serde_json::from_str(¬ify).unwrap(); | ||||
|         let host = data_toml(&"host"); | ||||
|         let n = notify.notifications; | ||||
|         let length = &n.len(); | ||||
|         let su = 0..*length; | ||||
|         for i in su { | ||||
|             let reason = &n[i].reason; | ||||
|             let handle = &n[i].author.handle; | ||||
|             let did = &n[i].author.did; | ||||
|             let read = n[i].isRead; | ||||
|             let cid = &n[i].cid; | ||||
|             let uri = &n[i].uri; | ||||
|             let time = &n[i].indexedAt; | ||||
|             let mut cid_root = cid; | ||||
|             let mut uri_root = uri; | ||||
|             let check_cid = w_cid(cid.to_string(), log_file(&"n1"), false); | ||||
|             let check_cid_run = w_cid(cid.to_string(), log_file(&"n2"), false); | ||||
|             // thread | ||||
|             if !n[i].record.reply.is_none() { | ||||
|                 cid_root = &n[i].record.reply.as_ref().unwrap().root.cid; | ||||
|                 uri_root = &n[i].record.reply.as_ref().unwrap().root.uri; | ||||
|             } | ||||
|  | ||||
|             let mut text = ""; | ||||
|             if !n[i].record.text.is_none() { | ||||
|                 text = &n[i].record.text.as_ref().unwrap(); | ||||
|             } | ||||
|             let vec: Vec<&str> = text.split_whitespace().collect(); | ||||
|             let handlev: Vec<&str> = handle.split('.').collect(); | ||||
|             let mut handlev = handlev[0].trim().to_string(); | ||||
|             let mut ten_p = "false"; | ||||
|  | ||||
|             let mut link = "https://card.syui.ai/".to_owned() + &handlev; | ||||
|             let s = 0; | ||||
|             let mut e = link.chars().count(); | ||||
|  | ||||
|             let mut com = "".to_string(); | ||||
|             let mut prompt = "".to_string(); | ||||
|             let mut prompt_sub = "".to_string(); | ||||
|             let mut prompt_chat = "".to_string(); | ||||
|             if reason == "mention" { | ||||
|                 com = vec[1].trim().to_string(); | ||||
|                 prompt = vec[2..].join(" "); | ||||
|                 prompt_chat = vec[1..].join(" "); | ||||
|                 if vec.len() > 2 { | ||||
|                     prompt_sub = vec[3..].join(" "); | ||||
|                 } | ||||
|             } else if reason == "reply" { | ||||
|                 com = vec[0].trim().to_string(); | ||||
|                 prompt = vec[1..].join(" "); | ||||
|                 prompt_chat = vec[0..].join(" "); | ||||
|                 if vec.len() > 1 { | ||||
|                     prompt_sub = vec[2..].join(" "); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if prompt.is_empty() == false || com.is_empty() == false { | ||||
|                 println!("{}", read); | ||||
|                 println!("{}", handle); | ||||
|                 println!( | ||||
|                     "cid:{}\nuri:{}\ncid_root:{}\nuri_root:{}\nhost:{}", | ||||
|                     cid, uri, cid_root, uri_root, host | ||||
|                 ); | ||||
|                 println!("reason:{}\ncom:{}\nprompt:{}", reason, com, prompt); | ||||
|                 println!("prompt_sub:{}", prompt_sub); | ||||
|             } | ||||
|  | ||||
|             let mut admin = "".to_string(); | ||||
|             if c.string_flag("admin").is_ok() { | ||||
|                 admin = c.string_flag("admin").unwrap(); | ||||
|             } | ||||
|  | ||||
|             let mut manga_uri = "".to_string(); | ||||
|             if c.string_flag("manga_uri").is_ok() { | ||||
|                 manga_uri = c.string_flag("manga_uri").unwrap(); | ||||
|             } | ||||
|  | ||||
|             let mut avatar = "".to_string(); | ||||
|             if let Some(v) = &n[i].author.avatar { | ||||
|                 avatar = v.to_string(); | ||||
|             } | ||||
|  | ||||
|             if check_cid == false && { reason == "mention" || reason == "reply" } | ||||
|             || check_cid_run == false && { reason == "mention" || reason == "reply" } | ||||
|             { | ||||
|                 w_cid(cid.to_string(), log_file(&"n2"), true); | ||||
|                 if com == "did" { | ||||
|                     let link = "https://plc.directory/".to_owned() + &did + &"/log"; | ||||
|                     let s = 0; | ||||
|                     let e = link.chars().count(); | ||||
|                     let d = "\n".to_owned() + &did.to_string(); | ||||
|                     let text_limit = c_char(d); | ||||
|                     if text_limit.len() > 3 { | ||||
|                         let str_rep = reply_link::post_request( | ||||
|                             text_limit.to_string(), | ||||
|                             link.to_string(), | ||||
|                             s, | ||||
|                             e.try_into().unwrap(), | ||||
|                             cid.to_string(), | ||||
|                             uri.to_string(), | ||||
|                             cid_root.to_string(), | ||||
|                             uri_root.to_string(), | ||||
|                         ) | ||||
|                             .await; | ||||
|                         w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                         println!("{}", str_rep); | ||||
|                     } | ||||
|                 } else if com == "help" || com == "/help" { | ||||
|                     let link = "https://git.syui.ai/ai/bot/wiki/help".to_string(); | ||||
|                     let s = 0; | ||||
|                     let e = link.chars().count(); | ||||
|                     let str_rep = reply_link::post_request( | ||||
|                         "\n".to_string(), | ||||
|                         link.to_string(), | ||||
|                         s, | ||||
|                         e.try_into().unwrap(), | ||||
|                         cid.to_string(), | ||||
|                         uri.to_string(), | ||||
|                         cid_root.to_string(), | ||||
|                         uri_root.to_string(), | ||||
|                     ) | ||||
|                         .await; | ||||
|                     w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                     println!("{}", str_rep); | ||||
|                 } else if { com == "diffusers"  || com == "/diffusers" } && handle == &admin{ | ||||
|                     let _output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"diffusers") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                 } else if com.contains("占") == true | ||||
|                     || com.contains("うらない") == true | ||||
|                         || com.contains("うらなって") == true | ||||
|                 { | ||||
|                     let _output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"fortune") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                 } else if com == "card" || com == "/card" { | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"card") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let dd = "\n".to_owned() + &d.to_string(); | ||||
|                     let text_limit = c_char(dd); | ||||
|                     if text_limit.len() > 3 { | ||||
|                         //handlev = handle.replace(".", "-").to_string(); | ||||
|                         handlev = d.lines().collect::<Vec<_>>()[0].to_string(); | ||||
|                         link = "https://card.syui.ai/".to_owned() + &handlev; | ||||
|                         e = link.chars().count(); | ||||
|                         let str_rep = reply_link::post_request( | ||||
|                             text_limit.to_string(), | ||||
|                             link.to_string(), | ||||
|                             s, | ||||
|                             e.try_into().unwrap(), | ||||
|                             cid.to_string(), | ||||
|                             uri.to_string(), | ||||
|                             cid_root.to_string(), | ||||
|                             uri_root.to_string(), | ||||
|                         ) | ||||
|                             .await; | ||||
|                         println!("{}", str_rep); | ||||
|                         w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                     } | ||||
|                 } else if com == "fav" || com == "/fav" { | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"fav") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let dd = "\n".to_owned() + &d.to_string(); | ||||
|                     let text_limit = c_char(dd); | ||||
|                     if text_limit.len() > 3 { | ||||
|                         handlev = d.lines().collect::<Vec<_>>()[0].to_string(); | ||||
|                         link = "https://card.syui.ai/".to_owned() + &handlev; | ||||
|                         e = link.chars().count(); | ||||
|                         let str_rep = reply_link::post_request( | ||||
|                             text_limit.to_string(), | ||||
|                             link.to_string(), | ||||
|                             s, | ||||
|                             e.try_into().unwrap(), | ||||
|                             cid.to_string(), | ||||
|                             uri.to_string(), | ||||
|                             cid_root.to_string(), | ||||
|                             uri_root.to_string(), | ||||
|                         ) | ||||
|                             .await; | ||||
|                         println!("{}", str_rep); | ||||
|                         w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                     } | ||||
|                 } else if com == "egg"  || com == "/egg" { | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"egg") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let dd = "\n".to_owned() + &d.to_string(); | ||||
|                     let text_limit = c_char(dd); | ||||
|                     if text_limit.len() > 3 { | ||||
|                         handlev = d.lines().collect::<Vec<_>>()[0].to_string(); | ||||
|                         link = "https://card.syui.ai/".to_owned() + &handlev; | ||||
|                         e = link.chars().count(); | ||||
|                         let str_rep = reply_link::post_request( | ||||
|                             text_limit.to_string(), | ||||
|                             link.to_string(), | ||||
|                             s, | ||||
|                             e.try_into().unwrap(), | ||||
|                             cid.to_string(), | ||||
|                             uri.to_string(), | ||||
|                             cid_root.to_string(), | ||||
|                             uri_root.to_string(), | ||||
|                         ) | ||||
|                             .await; | ||||
|                         println!("{}", str_rep); | ||||
|                         w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                     } | ||||
|                 } else if com == "nyan" || com == "/nyan" { | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"nyan") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let dd = "\n".to_owned() + &d.to_string(); | ||||
|                     let text_limit = c_char(dd); | ||||
|                     println!("{}", text_limit); | ||||
|                     if text_limit.len() > 3 { | ||||
|                         let str_rep = reply::post_request( | ||||
|                             text_limit.to_string(), | ||||
|                             cid.to_string(), | ||||
|                             uri.to_string(), | ||||
|                             cid_root.to_string(), | ||||
|                             uri_root.to_string(), | ||||
|                         ) | ||||
|                             .await; | ||||
|                         println!("{}", str_rep); | ||||
|                         w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                     } | ||||
|                 } else if com == "ten" || com == "/ten" { | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"ten") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let dd = "\n".to_owned() + &d.to_string(); | ||||
|                     let text_limit = c_char(dd); | ||||
|                     handlev = d.lines().collect::<Vec<_>>()[0].to_string(); | ||||
|                     let ten_l = d.lines().collect::<Vec<_>>().len(); | ||||
|                     println!("handlev {}", handlev); | ||||
|                     println!("ten_l {}", ten_l); | ||||
|                     if ten_l == 3 { | ||||
|                         ten_p = d.lines().collect::<Vec<_>>()[1]; | ||||
|                         println!("ten_p {}", ten_p); | ||||
|                     } | ||||
|                     if ten_p != "true" { | ||||
|                         link = "https://card.syui.ai/".to_owned() + &handlev; | ||||
|                         e = link.chars().count(); | ||||
|                         let str_rep = reply_link::post_request( | ||||
|                             text_limit.to_string(), | ||||
|                             link.to_string(), | ||||
|                             s, | ||||
|                             e.try_into().unwrap(), | ||||
|                             cid.to_string(), | ||||
|                             uri.to_string(), | ||||
|                             cid_root.to_string(), | ||||
|                             uri_root.to_string(), | ||||
|                         ) | ||||
|                             .await; | ||||
|                         println!("{}", str_rep); | ||||
|                     } | ||||
|                     w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                 } else if com == "coin" || com == "/coin" { | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"coin") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let dd = "\n".to_owned() + &d.to_string(); | ||||
|                     let text_limit = c_char(dd); | ||||
|                     handlev = d.lines().collect::<Vec<_>>()[0].to_string(); | ||||
|                     link = "https://card.syui.ai/".to_owned() + &handlev; | ||||
|                     println!("{}", e); | ||||
|                     e = link.chars().count(); | ||||
|                     if text_limit.len() > 3 { | ||||
|                         let str_rep = reply_link::post_request( | ||||
|                             text_limit.to_string(), | ||||
|                             link.to_string(), | ||||
|                             s, | ||||
|                             e.try_into().unwrap(), | ||||
|                             cid.to_string(), | ||||
|                             uri.to_string(), | ||||
|                             cid_root.to_string(), | ||||
|                             uri_root.to_string(), | ||||
|                         ) | ||||
|                             .await; | ||||
|                         println!("{}", str_rep); | ||||
|                         w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                     } | ||||
|                 } else if { com == "sh" || com == "/sh" } && handle == &admin { | ||||
|                     println!("admin:{}", admin); | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"sh") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let d = d.to_string(); | ||||
|                     let text_limit = c_char(d); | ||||
|                     let str_rep = reply::post_request( | ||||
|                         text_limit.to_string(), | ||||
|                         cid.to_string(), | ||||
|                         uri.to_string(), | ||||
|                         cid_root.to_string(), | ||||
|                         uri_root.to_string(), | ||||
|                     ) | ||||
|                         .await; | ||||
|                     println!("{}", str_rep); | ||||
|                     w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                 } else if com == "mitractl" && handle == &admin { | ||||
|                     println!("admin:{}", admin); | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"mitra") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&prompt) | ||||
|                         .arg(&prompt_sub) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let d = "\n".to_owned() + &d.to_string(); | ||||
|                     let text_limit = c_char(d); | ||||
|                     link = "https://m.syu.is".to_string(); | ||||
|                     e = link.chars().count(); | ||||
|                     if text_limit.len() > 3 { | ||||
|                         let str_rep = reply_link::post_request( | ||||
|                             text_limit.to_string(), | ||||
|                             link.to_string(), | ||||
|                             s, | ||||
|                             e.try_into().unwrap(), | ||||
|                             cid.to_string(), | ||||
|                             uri.to_string(), | ||||
|                             cid_root.to_string(), | ||||
|                             uri_root.to_string(), | ||||
|                         ) | ||||
|                             .await; | ||||
|                         println!("{}", str_rep); | ||||
|                         w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                     } | ||||
|                 } else if uri_root == &manga_uri { | ||||
|                     println!("manga_uri:{}", manga_uri); | ||||
|                     let output = Command::new(data_scpt(&"ai")) | ||||
|                         .arg(&"atproto").arg(&"manga") | ||||
|                         .arg(&handle) | ||||
|                         .arg(&did) | ||||
|                         .arg(&cid) | ||||
|                         .arg(&uri) | ||||
|                         .arg(&cid_root) | ||||
|                         .arg(&uri_root) | ||||
|                         .arg(&host) | ||||
|                         .arg(&avatar) | ||||
|                         .arg(&prompt_chat) | ||||
|                         .output() | ||||
|                         .expect("zsh"); | ||||
|                     let d = String::from_utf8_lossy(&output.stdout); | ||||
|                     let d = d.to_string(); | ||||
|                     let text_limit = c_char(d); | ||||
|                     let str_rep = reply::post_request( | ||||
|                         text_limit.to_string(), | ||||
|                         cid.to_string(), | ||||
|                         uri.to_string(), | ||||
|                         cid_root.to_string(), | ||||
|                         uri_root.to_string(), | ||||
|                     ) | ||||
|                         .await; | ||||
|                     println!("{}", str_rep); | ||||
|                     w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                 } else { | ||||
|                     // openai | ||||
|                     let str_openai = openai::post_request(prompt_chat.to_string()).await; | ||||
|                     let text_limit = c_char(str_openai); | ||||
|                     let str_rep = reply::post_request( | ||||
|                         text_limit.to_string(), | ||||
|                         cid.to_string(), | ||||
|                         uri.to_string(), | ||||
|                         cid_root.to_string(), | ||||
|                         uri_root.to_string(), | ||||
|                     ) | ||||
|                         .await; | ||||
|                     println!("{}", str_rep); | ||||
|                     w_cid(cid.to_string(), log_file(&"n1"), true); | ||||
|                 } | ||||
|                 let str_notify = notify_read::post_request(time.to_string()).await; | ||||
|                 println!("{}", str_notify); | ||||
|                 println!("---"); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|     let res = tokio::runtime::Runtime::new().unwrap().block_on(h); | ||||
|     return res; | ||||
| } | ||||
|   | ||||
| @@ -123,6 +123,7 @@ pub struct BaseUrl { | ||||
|     pub follow: String, | ||||
|     pub follows: String, | ||||
|     pub followers: String, | ||||
|     pub feed_get: String, | ||||
| } | ||||
|  | ||||
| pub fn url(s: &str) -> String { | ||||
| @@ -148,6 +149,7 @@ pub fn url(s: &str) -> String { | ||||
|         session_refresh: "com.atproto.server.refreshSession".to_string(), | ||||
|         session_get: "com.atproto.server.getSession".to_string(), | ||||
|         timeline_get: "app.bsky.feed.getTimeline".to_string(), | ||||
|         feed_get: "app.bsky.feed.getFeed".to_string(), | ||||
|         timeline_author: "app.bsky.feed.getAuthorFeed".to_string(), | ||||
|         like: "app.bsky.feed.like".to_string(), | ||||
|         repost: "app.bsky.feed.repost".to_string(), | ||||
| @@ -187,6 +189,7 @@ pub fn url(s: &str) -> String { | ||||
|         "follow" => t.to_string() + &baseurl.follow, | ||||
|         "follows" => t.to_string() + &baseurl.follows, | ||||
|         "followers" => t.to_string() + &baseurl.followers, | ||||
|         "feed_get" => t.to_string() + &baseurl.feed_get, | ||||
|         _ => s, | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										33
									
								
								src/feed_get.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/feed_get.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| extern crate reqwest; | ||||
| use crate::data_refresh; | ||||
| use crate::url; | ||||
|  | ||||
| pub async fn get_request(feed: String) -> String { | ||||
|     let token = data_refresh(&"access"); | ||||
|     let url = url(&"feed_get"); | ||||
|     let feed = feed.to_string(); | ||||
|     //let col = "app.bsky.feed.generator".to_string(); | ||||
|  | ||||
|     let client = reqwest::Client::new(); | ||||
|     let res = client | ||||
|         .get(url) | ||||
|         .query(&[("feed", feed)]) | ||||
|         //.query(&[("feed", feed), ("collection", col)]) | ||||
|         .header("Authorization", "Bearer ".to_owned() + &token) | ||||
|         .send() | ||||
|         .await | ||||
|         .unwrap(); | ||||
|   | ||||
|     let status_ref = res.error_for_status_ref(); | ||||
|  | ||||
|     match status_ref { | ||||
|         Ok(_) => { | ||||
|             return res.text().await.unwrap(); | ||||
|         } | ||||
|         Err(_e) => { | ||||
|             let e = "err".to_string(); | ||||
|             return e; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										26
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -3,6 +3,7 @@ use std::env; | ||||
|  | ||||
| use crate::ascii::c_ascii; | ||||
| use crate::bot::c_bot; | ||||
| use crate::bot::c_bot_feed; | ||||
| use crate::data::c_follow_all; | ||||
| use crate::data::c_openai_key; | ||||
| use crate::data::data_toml; | ||||
| @@ -37,6 +38,7 @@ pub mod repost; | ||||
| pub mod session; | ||||
| pub mod timeline_author; | ||||
| pub mod token; | ||||
| pub mod feed_get; | ||||
|  | ||||
| fn main() { | ||||
|     let args: Vec<String> = env::args().collect(); | ||||
| @@ -98,6 +100,12 @@ fn main() { | ||||
|             .alias("t") | ||||
|             .action(timeline), | ||||
|         ) | ||||
|         .command( | ||||
|             Command::new("feed") | ||||
|             .description("feed <feed-uri>") | ||||
|             .alias("f") | ||||
|             .action(feed) | ||||
|             ) | ||||
|         .command( | ||||
|             Command::new("did") | ||||
|             .description("did <handle>") | ||||
| @@ -274,6 +282,7 @@ fn bot(c: &Context) { | ||||
|     refresh(c); | ||||
|     loop { | ||||
|         c_bot(c); | ||||
|         c_bot_feed(c); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -337,6 +346,23 @@ fn notify(c: &Context) { | ||||
|     return res; | ||||
| } | ||||
|  | ||||
| fn feed(c: &Context) { | ||||
|     refresh(c); | ||||
|     //let feed_d = "at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot".to_string(); | ||||
|     let feed_d = "at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.generator/aaangd4aqzqgu".to_string(); | ||||
|     let h = async { | ||||
|         if c.args.len() == 0 { | ||||
|             let j = feed_get::get_request(feed_d).await; | ||||
|             println!("{}", j); | ||||
|         } else { | ||||
|             let j = feed_get::get_request(c.args[0].to_string()).await; | ||||
|             println!("{}", j); | ||||
|         } | ||||
|     }; | ||||
|     let res = tokio::runtime::Runtime::new().unwrap().block_on(h); | ||||
|     return res; | ||||
| } | ||||
|  | ||||
| fn did(c: &Context) { | ||||
|     refresh(c); | ||||
|     let h = async { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user