Diff
Logged in as anonymous

Differences From Artifact [55d4d9b615]:

To Artifact [b3dd317a5f]:


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	pool: sqlx::Pool<sqlx::Postgres>,
	sources: Arc<Mutex<HashSet<Arc<i32>>>>,
}

impl Core {
	pub async fn new(settings: config::Config) -> Result<Arc<Core>> {
		let owner = settings.get_int("owner")?;
		let api_key = settings.get_str("api_key")?;
		let tg = telegram_bot::Api::new(&api_key);
		let core = Arc::new(Core {
			//owner,
			//api_key: api_key.clone(),
			my: tg.send(telegram_bot::GetMe).await?,
			tg,
			owner_chat: telegram_bot::UserId::new(owner),
			pool: PgPoolOptions::new()
				.max_connections(5)
				.connect_timeout(std::time::Duration::new(300, 0))
				.idle_timeout(std::time::Duration::new(60, 0))
				.connect_lazy(&settings.get_str("pg")?)?,
			sources: Arc::new(Mutex::new(HashSet::new())),
		});
		let clone = core.clone();
		tokio::spawn(async move {
			loop {
				let delay = match &clone.autofetch().await {
					Err(err) => {







|











|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	pool: sqlx::Pool<sqlx::Postgres>,
	sources: Arc<Mutex<HashSet<Arc<i32>>>>,
}

impl Core {
	pub async fn new(settings: config::Config) -> Result<Arc<Core>> {
		let owner = settings.get_int("owner")?;
		let api_key = settings.get_string("api_key")?;
		let tg = telegram_bot::Api::new(&api_key);
		let core = Arc::new(Core {
			//owner,
			//api_key: api_key.clone(),
			my: tg.send(telegram_bot::GetMe).await?,
			tg,
			owner_chat: telegram_bot::UserId::new(owner),
			pool: PgPoolOptions::new()
				.max_connections(5)
				.connect_timeout(std::time::Duration::new(300, 0))
				.idle_timeout(std::time::Duration::new(60, 0))
				.connect_lazy(&settings.get_string("pg")?)?,
			sources: Arc::new(Mutex::new(HashSet::new())),
		});
		let clone = core.clone();
		tokio::spawn(async move {
			loop {
				let delay = match &clone.autofetch().await {
					Err(err) => {