mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-22 11:04:21 +00:00
Wrap DatabaseInterface
in an Arc
This commit is contained in:
parent
25c28cf079
commit
1275f1e361
2 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
// See the following link for an example of how to use this file:
|
||||
// https://github.com/teloxide/teloxide/blob/master/crates/teloxide/examples/dispatching_features.rs
|
||||
|
||||
use std::sync::Arc;
|
||||
use anyhow::{Context, Error, Result};
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::SendMessageSetters;
|
||||
|
@ -59,7 +60,7 @@ impl Command {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn handle(self, bot: Bot, message: Message, database: &DatabaseInterface) -> CommandResult {
|
||||
pub async fn handle(self, bot: Bot, message: Message, database: Arc<DatabaseInterface>) -> CommandResult {
|
||||
log::trace!("Handling command: {self:?}");
|
||||
|
||||
let result = match self {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::sync::Arc;
|
||||
use anyhow::Context;
|
||||
use teloxide::prelude::*;
|
||||
use teloxide::types::{Me, ParseMode};
|
||||
|
@ -105,7 +106,7 @@ impl TelegramService {
|
|||
let regex = Regex::new(&format!(r"^/[a-z0-9_]+(?:@{bot_name})?(?:\s+.*)?$")).unwrap();
|
||||
log::trace!("Pseudo-command regex is: {regex:?}");
|
||||
|
||||
let database = DatabaseInterface::new(self.database_url.clone());
|
||||
let database = Arc::new(DatabaseInterface::new(self.database_url.clone()));
|
||||
|
||||
log::trace!("Building dispatcher...");
|
||||
Dispatcher::builder(
|
||||
|
|
Loading…
Reference in a new issue