|  |  |  | @ -68,7 +68,7 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  |         let mut admins = self.config.get_admins().collect::<Vec<_>>(); | 
			
		
	
		
			
				
					|  |  |  |  |         admins.sort(); | 
			
		
	
		
			
				
					|  |  |  |  |         for a in admins { | 
			
		
	
		
			
				
					|  |  |  |  |             self.replies.push(a.to_string()); | 
			
		
	
		
			
				
					|  |  |  |  |             self.replies.push(format!("- {}", a)); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -80,9 +80,9 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  |         members.dedup(); | 
			
		
	
		
			
				
					|  |  |  |  |         for m in members { | 
			
		
	
		
			
				
					|  |  |  |  |             self.replies.push(if admins.contains(&m) { | 
			
		
	
		
			
				
					|  |  |  |  |                 format!("{} [admin]", m) | 
			
		
	
		
			
				
					|  |  |  |  |                 format!("- {} [admin]", m) | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 m.to_string() | 
			
		
	
		
			
				
					|  |  |  |  |                 format!("- {}", m) | 
			
		
	
		
			
				
					|  |  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  |  | @ -133,12 +133,12 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  |             .log_error("Failed to reblog status") | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     fn add_reply(&mut self, line: impl ToString) { | 
			
		
	
		
			
				
					|  |  |  |  |         self.replies.push(line.to_string()) | 
			
		
	
		
			
				
					|  |  |  |  |     fn add_reply(&mut self, line: impl AsRef<str>) { | 
			
		
	
		
			
				
					|  |  |  |  |         self.replies.push(line.as_ref().trim().to_string()) | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     fn add_announcement(&mut self, line: impl ToString) { | 
			
		
	
		
			
				
					|  |  |  |  |         self.announcements.push(line.to_string()) | 
			
		
	
		
			
				
					|  |  |  |  |     fn add_announcement<'t>(&mut self, line: impl AsRef<str>) { | 
			
		
	
		
			
				
					|  |  |  |  |         self.announcements.push(line.as_ref().trim().to_string()) | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     async fn handle(mut self) -> Result<(), GroupError> { | 
			
		
	
	
		
			
				
					|  |  |  | @ -239,18 +239,21 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if !self.replies.is_empty() { | 
			
		
	
		
			
				
					|  |  |  |  |             debug!("replies={:?}", self.replies); | 
			
		
	
		
			
				
					|  |  |  |  |             let r = self.replies.join("\n"); | 
			
		
	
		
			
				
					|  |  |  |  |             debug!("r={}", r); | 
			
		
	
		
			
				
					|  |  |  |  |             let mut msg = self.replies.join("\n"); | 
			
		
	
		
			
				
					|  |  |  |  |             debug!("r={}", msg); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if self.want_markdown { | 
			
		
	
		
			
				
					|  |  |  |  |                 apply_trailing_hashtag_pleroma_bug_workaround(&mut msg); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if let Ok(post) = StatusBuilder::new() | 
			
		
	
		
			
				
					|  |  |  |  |                 .status(format!("@{user}\n{msg}", user = self.status_acct, msg = r)) | 
			
		
	
		
			
				
					|  |  |  |  |                 .status(format!("@{user} {msg}", user = self.status_acct, msg = msg)) | 
			
		
	
		
			
				
					|  |  |  |  |                 .content_type(if self.want_markdown { | 
			
		
	
		
			
				
					|  |  |  |  |                     "text/markdown" | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     "text/plain" | 
			
		
	
		
			
				
					|  |  |  |  |                 }) | 
			
		
	
		
			
				
					|  |  |  |  |                 .visibility(self.status.visibility) // Copy visibility
 | 
			
		
	
		
			
				
					|  |  |  |  |                 .visibility(Visibility::Direct) | 
			
		
	
		
			
				
					|  |  |  |  |                 .build() | 
			
		
	
		
			
				
					|  |  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  |  |                 let _ = self.client.new_status(post) | 
			
		
	
	
		
			
				
					|  |  |  | @ -259,7 +262,13 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if !self.announcements.is_empty() { | 
			
		
	
		
			
				
					|  |  |  |  |             let msg = self.announcements.join("\n"); | 
			
		
	
		
			
				
					|  |  |  |  |             let mut msg = self.announcements.join("\n"); | 
			
		
	
		
			
				
					|  |  |  |  |             debug!("a={}", msg); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if self.want_markdown { | 
			
		
	
		
			
				
					|  |  |  |  |                 apply_trailing_hashtag_pleroma_bug_workaround(&mut msg); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             let post = StatusBuilder::new() | 
			
		
	
		
			
				
					|  |  |  |  |                 .status(format!("**📢 Group announcement**\n{msg}", msg = msg)) | 
			
		
	
		
			
				
					|  |  |  |  |                 .content_type("text/markdown") | 
			
		
	
	
		
			
				
					|  |  |  | @ -445,8 +454,12 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     async fn cmd_add_tag(&mut self, tag: String) { | 
			
		
	
		
			
				
					|  |  |  |  |         if self.is_admin { | 
			
		
	
		
			
				
					|  |  |  |  |             self.config.add_tag(&tag); | 
			
		
	
		
			
				
					|  |  |  |  |             self.add_reply(format!("Tag #{} added to the group!", tag)); | 
			
		
	
		
			
				
					|  |  |  |  |             if self.config.is_tag_followed(&tag) { | 
			
		
	
		
			
				
					|  |  |  |  |                 self.add_reply(format!("Tag \"{}\" added to the group!", tag)); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 self.config.add_tag(&tag); | 
			
		
	
		
			
				
					|  |  |  |  |                 self.add_reply(format!("Tag \"{}\" was already in group!", tag)); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             self.add_reply("Only admins can manage group tags"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  |  | @ -454,8 +467,12 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     async fn cmd_remove_tag(&mut self, tag: String) { | 
			
		
	
		
			
				
					|  |  |  |  |         if self.is_admin { | 
			
		
	
		
			
				
					|  |  |  |  |             self.config.remove_tag(&tag); | 
			
		
	
		
			
				
					|  |  |  |  |             self.add_reply(format!("Tag #{} removed from the group!", tag)); | 
			
		
	
		
			
				
					|  |  |  |  |             if self.config.is_tag_followed(&tag) { | 
			
		
	
		
			
				
					|  |  |  |  |                 self.config.remove_tag(&tag); | 
			
		
	
		
			
				
					|  |  |  |  |                 self.add_reply(format!("Tag \"{}\" removed from the group!", tag)); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 self.add_reply(format!("Tag \"{}\" was not in group!", tag)); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             self.add_reply("Only admins can manage group tags"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  |  | @ -551,8 +568,7 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         self.add_reply("\n\ | 
			
		
	
		
			
				
					|  |  |  |  |             To share a post, @ the group user or use a group hashtag. \ | 
			
		
	
		
			
				
					|  |  |  |  |             Replies and mentions with commands won't be shared.\n\ | 
			
		
	
		
			
				
					|  |  |  |  |             To share a post, @ the group user or use a group hashtag.\n\ | 
			
		
	
		
			
				
					|  |  |  |  |             \n\ | 
			
		
	
		
			
				
					|  |  |  |  |             **Supported commands:**\n\ | 
			
		
	
		
			
				
					|  |  |  |  |             `/boost`, `/b` - boost the replied-to post into the group\n\ | 
			
		
	
	
		
			
				
					|  |  |  | @ -591,6 +607,7 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     async fn cmd_list_members(&mut self) { | 
			
		
	
		
			
				
					|  |  |  |  |         self.want_markdown = true; | 
			
		
	
		
			
				
					|  |  |  |  |         if self.is_admin { | 
			
		
	
		
			
				
					|  |  |  |  |             self.add_reply("Group members:"); | 
			
		
	
		
			
				
					|  |  |  |  |             self.append_member_list_to_reply(); | 
			
		
	
	
		
			
				
					|  |  |  | @ -602,10 +619,11 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     async fn cmd_list_tags(&mut self) { | 
			
		
	
		
			
				
					|  |  |  |  |         self.add_reply("Group tags:"); | 
			
		
	
		
			
				
					|  |  |  |  |         self.want_markdown = true; | 
			
		
	
		
			
				
					|  |  |  |  |         let mut tags = self.config.get_tags().collect::<Vec<_>>(); | 
			
		
	
		
			
				
					|  |  |  |  |         tags.sort(); | 
			
		
	
		
			
				
					|  |  |  |  |         for t in tags { | 
			
		
	
		
			
				
					|  |  |  |  |             self.replies.push(format!("#{}", t).to_string()); | 
			
		
	
		
			
				
					|  |  |  |  |             self.replies.push(format!("- {}", t).to_string()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -671,3 +689,11 @@ impl<'a> ProcessMention<'a> { | 
			
		
	
		
			
				
					|  |  |  |  |         Ok(()) | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | fn apply_trailing_hashtag_pleroma_bug_workaround(msg: &mut String) { | 
			
		
	
		
			
				
					|  |  |  |  |     if crate::command::RE_HASHTAG_TRIGGERING_PLEROMA_BUG.is_match(&msg) { | 
			
		
	
		
			
				
					|  |  |  |  |         // if a status ends with a hashtag, pleroma will fuck it up
 | 
			
		
	
		
			
				
					|  |  |  |  |         debug!("Adding \" .\" to fix pleroma hashtag eating bug!"); | 
			
		
	
		
			
				
					|  |  |  |  |         msg.push_str(" ."); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |