Browse Source

feat: Envoi d'informations sur flux RSS

Martin Passard 6 years ago
parent
commit
fe4755762d
1 changed files with 30 additions and 2 deletions
  1. 30 2
      src/main/java/bot/irc/socials/MastodonBot.java

+ 30 - 2
src/main/java/bot/irc/socials/MastodonBot.java

@@ -235,9 +235,37 @@ public class MastodonBot implements Bot, Runnable,Observer {
 	}
 	@Override
 	public void sendRSSMessage(List<String> messages) {
-		// TODO Auto-generated method stub
 		
-	}
+		
+		Response r = client.post("statuses", new RequestBody() {
+			
+			@Override
+			public void writeTo(BufferedSink sink) throws IOException {
+				String aff = "";
+				for(String s : messages) {
+					aff += s+"\n";
+				}
+				JSONObject jo = new JSONObject();
+					jo.put("status", aff);
+					jo.put("visibility", "public");
+					sink.writeUtf8(jo.toString());
+					sink.flush();
+				}
+				
+			
+			
+			@Override
+			public MediaType contentType() {
+				return MediaType.parse("application/json");
+			}
+		});
+		if(Main.isDebug()) {
+			System.out.println(r.networkResponse());
+		}
+		
+		
+
+		}