Diff
Logged in as anonymous

Differences From Artifact [20a887e7dc]:

To Artifact [7cb5076465]:


1
2
3
4
5


6
7
8

9
10
11
12
13

14
15
16
17
18


19
20
21
22
23
24
25
26
27
28
29
30
31














32
33
34
35
36
37
38
1
2
3

4
5
6
7


8
9
10
11
12

13
14
15
16

17
18
19













20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40



-

+
+

-
-
+




-
+



-

+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+







mod command;
mod core;

use futures::StreamExt;
use anyhow::Result;
use async_std::task;
use futures::StreamExt;

#[tokio::main]
async fn main() -> Result<()> {
fn main() -> Result<()> {
	let settings = config::Config::builder()
		.add_source(config::File::with_name("rsstg"))
		.build()?;

	let core = core::Core::new(settings).await?;
	let core = core::Core::new(settings)?;

	let mut stream = core.stream();
	stream.allowed_updates(&[telegram_bot::AllowedUpdate::Message]);
	let mut reply_to: Option<telegram_bot::UserId>;

	task::block_on(async {
		let mut reply_to: Option<telegram_bot::UserId>;
	loop {
		reply_to = None;
		match stream.next().await {
			Some(update) => {
				if let Err(err) = handle(update?, &core, &reply_to).await {
					core.send(&format!("🛑 {:?}", err), reply_to, None).await?;
				};
			},
			None => {
				core.send("🛑 None error.", None, None).await?;
			}
		};
	}
		loop {
			reply_to = None;
			match stream.next().await {
				Some(update) => {
					if let Err(err) = handle(update?, &core, &reply_to).await {
						core.send(&format!("🛑 {:?}", err), reply_to, None).await?;
					};
				},
				None => {
					core.send("🛑 None error.", None, None).await?;
				}
			};
		}
	})
}

async fn handle(update: telegram_bot::Update, core: &core::Core, mut _reply_to: &Option<telegram_bot::UserId>) -> Result<()> {
	if let telegram_bot::UpdateKind::Message(message) = update.kind {
		if let telegram_bot::MessageKind::Text { ref data, .. } = message.kind {
			let sender = message.from.id;
			let words: Vec<&str> = data.split_whitespace().collect();