Version-1 : Configuring bridge

Structure of Config File

  bot_id: qaul-bot
  bot_password: not-gonna-tell

  last_index: 25

Here the most important part is with the last_index. It helps in two ways. One is while we run our ticker which looks for new messages then on restarting it is not 0. So, We actually only send newer messages. Another benefit is that we can avoid the duplication of the matrix message. Since the incoming message from matrix is stored inside the qaul feed we increase the index so that message is not sent back into our feed.

Again use follow the same approach to store the configuration inside of a Storage object and then use it globally across the binary.

fn main() {
pub static MATRIX_CONFIG: state::Storage<RwLock<MatrixConfiguration>> = state::Storage::new();

pub async fn connect() -> Result<(), matrix_sdk::Error> {
    println!("Connecting to Matrix Bot");

    // Configuration for starting of the bot
    let path_string = Storage::get_path();
    let path = Path::new(path_string.as_str());
    let config_path = path.join("matrix.yaml");
    let config: MatrixConfiguration = match Config::builder()
        Err(_) => {
            log::error!("no configuration file found, creating one.");
        Ok(c) => c.try_deserialize::<MatrixConfiguration>().unwrap(),


and we can now use this matrix configuration to take care of last_index and feed messages

#request_feed_list Implementation

fn main() {
let mut config = MATRIX_CONFIG.get().write().unwrap();
let last_index_matrix = config.feed.last_index;
// print all messages in the feed list.
for message in proto_feedlist.feed_message {
    print!{"[{}] ", message.index}; // This is what we are getting from ticker logic as can be seen below
    println!("Time Sent - {}", message.time_sent);
    println!("Timestamp Sent - {}", message.timestamp_sent);
    println!("Time Received - {}", message.time_received);
    println!("Timestamp Received - {}", message.timestamp_received);
    println!("Message ID {}", message.message_id_base58);
    println!("From {}", message.sender_id_base58);
    println!("\t{}", message.content);
    // Only send if the message index is greater than last known index.
    if message.index> last_index_matrix {
        config.feed.last_index = message.index;
        // save the configuration file locally.
// set the configuration back to object.

Ticker logic

fn main() {
let mut feed_ticker = Ticker::new(Duration::from_secs(2));
 loop {
        let evt = {
            let feed_fut =;
            select! {
                _feed_ticker = feed_fut => {
                    let config = MATRIX_CONFIG.get().read().unwrap();
                    let last_index = &config.feed.last_index;
                    // Check unread messages from Libqaul

The function request_feed_list allows us to know send messages to matrix and print in qaul. This is the logic which you can see in the above snippet.

By this time, We were able to close our communication completely and reliabaly from

  1. Matrix Room to Qaul Feed
  2. Qaul Feed to Matrix Room