mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-25 20:44: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:
|
// 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
|
// https://github.com/teloxide/teloxide/blob/master/crates/teloxide/examples/dispatching_features.rs
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
use anyhow::{Context, Error, Result};
|
use anyhow::{Context, Error, Result};
|
||||||
use teloxide::Bot;
|
use teloxide::Bot;
|
||||||
use teloxide::payloads::SendMessageSetters;
|
use teloxide::payloads::SendMessageSetters;
|
||||||
|
@ -59,7 +60,7 @@ impl Command {
|
||||||
Ok(())
|
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:?}");
|
log::trace!("Handling command: {self:?}");
|
||||||
|
|
||||||
let result = match self {
|
let result = match self {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::sync::Arc;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use teloxide::prelude::*;
|
use teloxide::prelude::*;
|
||||||
use teloxide::types::{Me, ParseMode};
|
use teloxide::types::{Me, ParseMode};
|
||||||
|
@ -105,7 +106,7 @@ impl TelegramService {
|
||||||
let regex = Regex::new(&format!(r"^/[a-z0-9_]+(?:@{bot_name})?(?:\s+.*)?$")).unwrap();
|
let regex = Regex::new(&format!(r"^/[a-z0-9_]+(?:@{bot_name})?(?:\s+.*)?$")).unwrap();
|
||||||
log::trace!("Pseudo-command regex is: {regex:?}");
|
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...");
|
log::trace!("Building dispatcher...");
|
||||||
Dispatcher::builder(
|
Dispatcher::builder(
|
||||||
|
|
Loading…
Reference in a new issue