193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
.with_context(|| format!("Enable fetch conn:\n{:?}", &self.pool))?;
match sqlx::query("update rsstg_source set enabled = true where source_id = $1 and owner = $2")
.bind(source_id)
.bind(owner)
.execute(&mut conn).await
.with_context(|| format!("Enable source:\n{:?}", &self.pool))?
.rows_affected() {
1 => { Ok("Source disabled\\.") },
0 => { Ok("Source not found\\.") },
_ => { Err(anyhow!("Database error.")) },
}
}
async fn disable<S>(&self, source_id: &i32, owner: S) -> Result<&str>
where S: Into<i64> {
|
|
|
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
.with_context(|| format!("Enable fetch conn:\n{:?}", &self.pool))?;
match sqlx::query("update rsstg_source set enabled = true where source_id = $1 and owner = $2")
.bind(source_id)
.bind(owner)
.execute(&mut conn).await
.with_context(|| format!("Enable source:\n{:?}", &self.pool))?
.rows_affected() {
1 => { Ok("Source enabled\\.") },
0 => { Ok("Source not found\\.") },
_ => { Err(anyhow!("Database error.")) },
}
}
async fn disable<S>(&self, source_id: &i32, owner: S) -> Result<&str>
where S: Into<i64> {
|
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
let mut settings = config::Config::default();
settings.merge(config::File::with_name("rsstg"))?;
let core = Core::new(settings).await?;
let mut stream = core.stream();
while let Some(update) = stream.next().await {
if let Err(err) = handle(update?, &core).await {
core.debug(&format!("🛑 {:?}", err))?;
};
}
Ok(())
}
async fn handle(update: telegram_bot::Update, core: &Core) -> Result<()> {
lazy_static! {
static ref RE_USERNAME: Regex = Regex::new(r"^@[a-zA-Z][a-zA-Z0-9_]+$").unwrap();
static ref RE_LINK: Regex = Regex::new(r"^https?://[a-zA-Z.0-9-]+/[-_a-zA-Z.0-9/?=]+$").unwrap();
static ref RE_IV_HASH: Regex = Regex::new(r"^[a-f0-9]{14}$").unwrap();
|
>
|
>
|
|
>
>
>
>
>
|
|
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
let mut settings = config::Config::default();
settings.merge(config::File::with_name("rsstg"))?;
let core = Core::new(settings).await?;
let mut stream = core.stream();
loop {
match stream.next().await {
Some(update) => {
if let Err(err) = handle(update?, &core).await {
core.debug(&format!("🛑 {:?}", err))?;
};
},
None => {
core.debug(&format!("🛑 None error."))?;
}
};
}
//Ok(())
}
async fn handle(update: telegram_bot::Update, core: &Core) -> Result<()> {
lazy_static! {
static ref RE_USERNAME: Regex = Regex::new(r"^@[a-zA-Z][a-zA-Z0-9_]+$").unwrap();
static ref RE_LINK: Regex = Regex::new(r"^https?://[a-zA-Z.0-9-]+/[-_a-zA-Z.0-9/?=]+$").unwrap();
static ref RE_IV_HASH: Regex = Regex::new(r"^[a-f0-9]{14}$").unwrap();
|