This commit is contained in:
Sarah Jamie Lewis 2023-04-27 12:01:10 -07:00
parent 223842a32b
commit b56877e03d
2 changed files with 66 additions and 5 deletions

View File

@ -1,5 +1,5 @@
---
title: Cwtch Developer Documentation
title: Cwtch Developer Documentation, Cwtchbot v0.1.0 and New Nightly.
description: "In this development log we take a look at the new Cwtch developer docs!"
slug: cwtch-developer-documentation
tags: [cwtch, cwtch-stable, developer-documentation]
@ -12,9 +12,9 @@ authors:
image_url: /img/sarah.jpg
---
One of the larger remaining goals outlined in our [Cwtch Stable roadmap update](/blog/cwtch-stable-roadmap-update) is comprehensive developer documentation. We have recently spent some time writing the foundation for these documents. In this devlog we will introduce some of them, and outline the next steps.
One of the larger remaining goals outlined in our [Cwtch Stable roadmap update](/blog/cwtch-stable-roadmap-update) is comprehensive developer documentation. We have recently spent some time writing the foundation for these documents. In this devlog we will introduce some of them, and outline the next steps. We also have a new nightly Cwtch release available for testing!
We are very interested in getting feedback on these documents, and we encourage anyone who is excited to build a Cwtch Bot, or even an alteratrive UI, to read them over and reach out to us with comments, questions, and suggestions!
We are very interested in getting feedback on these documents, and we encourage anyone who is excited to build a Cwtch Bot, or even an alternative UI, to read them over and reach out to us with comments, questions, and suggestions!
As a reminder, the Open Privacy Research Society have [also announced they are want to raise $60,000 in 2023](https://openprivacy.ca/discreet-log/38-march-2023/) to help move forward projects like Cwtch. Please help support projects like
ours with a [one-off donations](https://openprivacy.ca/donate) or [recurring support via Patreon](https://www.patreon.com/openprivacy).
@ -31,10 +31,22 @@ We have created a new documentation section, [the developers handbook](/developi
The new handbook features a breakdown of [Cwtch release processes](/developing/release) - describing what, and how, build artifacts are created; the difference between nightly and official builds; how the official release process works; and how reproducible build scripts are created.
### Cwtch Application Development
### Cwtch Application Development and Cwtchbot v0.1.0!
For the first time ever we now have [comprehensive documentation on how to build a Cwtch Application](/developing/category/building-a-cwtch-app). This section of the development handbook covers everything from [choosing a Cwtch library](/developing/building-a-cwtch-app/intro#choosing-a-cwtch-library), to [building your first application](/developing/building-a-cwtch-app/building-an-echobot).
Together with this new documentation we have also [released version 0.1 of the Cwtchbot framework](https://git.openprivacy.ca/sarah/cwtchbot), updating calls to use the [new Cwtch Stable API](/blog/cwtch-stable-api-design).
### New Nightly
There is a [new Nightly build](https://docs.cwtch.im/docs/contribute/testing#cwtch-nightlies) are available from our build server. The latest nightly we recommend testing is [2023-04-26-20-57-v1.11.0-33-gb4371(https://build.openprivacy.ca/files/flwtch-2023-04-26-20-57-v1.11.0-33-gb4371/).
This version has a number of fixes and updates to the file sharing and image previews/profile pictures experiment, and an update to the [in-development Tails support](/docs/platforms/tails).
In addition, this nightly also includes a number of performance improvements that should fix reported rendering issues on less powerful devices.
Please see the contribution documentation for advice on [submitting feedback](/docs/contribute/testing#submitting-feedback)
## Help us go further!
We couldn't do what we do without all the wonderful community support we get, from [one-off donations](https://openprivacy.ca/donate) to [recurring support via Patreon](https://www.patreon.com/openprivacy).

View File

@ -70,7 +70,56 @@ func main() {
:::info Imp (Rust) Bot Framework
This tutorial uses the Imp Cwtch Bot framework (Rust).
This tutorial uses the Imp Cwtch Bot framework (Rust). This framework is currently a work-in-progress and the API design is subject to change. IMP is also based on libcwtch-rs which is currently based on an older pre-stable API version of Cwtch. We are planning in updating libcwtch-rs in Summer 2023.
:::
```rust
use std::borrow::BorrowMut;
use std::thread;
use chrono::{DateTime, FixedOffset};
use libcwtch;
use libcwtch::CwtchLib;
use libcwtch::structs::*;
use libcwtch::event::*;
use cwtch_imp::imp;
use cwtch_imp::behaviour::*;
use cwtch_imp::imp::Imp;
const BOT_HOME: &str = "~/.cwtch/bots/echobot";
const PASSWORD: &str = "be gay do crime";
const BOT_NAME: &str = "echobot";
struct Echobot {}
fn main() {
let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).new_contact_policy(NewContactPolicy::Accept).build();
let event_loop_handle = thread::spawn(move || {
let mut echobot = Echobot {};
let mut bot = Imp::spawn(behaviour, PASSWORD.to_string(), BOT_HOME.to_string());
bot.event_loop::<Echobot>(echobot.borrow_mut());
});
event_loop_handle.join().expect("Error running event loop");
}
impl imp::EventHandler for Echobot {
fn on_new_message_from_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, conversation_id: ConversationID, handle: String, timestamp_received: DateTime<FixedOffset>, message: Message) {
let response = Message {
o: MessageType::TextMessage,
d: message.d,
};
cwtch.send_message(&profile.profile_id, conversation_id, &response);
}
fn handle(&mut self, cwtch: &dyn CwtchLib, profile_opt: Option<&Profile>, event: &Event) {
match event {
Event::NewPeer { profile_id, tag, created, name, default_picture, picture, online, profile_data } => {
println!(
"\n***** {} at {} *****\n",
name, profile_id.as_str()
);
}
_ => (),
};
}
}
```