From e8b0bb92452409c0b8f9772c5ebaeb87f56a29a5 Mon Sep 17 00:00:00 2001
From: Wizou <11647984+wiz0u@users.noreply.github.com>
Date: Wed, 17 May 2023 11:45:06 +0200
Subject: [PATCH] ActiveUsernames helpers Github action telegram-api
---
.github/workflows/telegram-api.yml | 22 ++++++++++++++++++++++
src/TL.Helpers.cs | 12 ++++++++++++
2 files changed, 34 insertions(+)
create mode 100644 .github/workflows/telegram-api.yml
diff --git a/.github/workflows/telegram-api.yml b/.github/workflows/telegram-api.yml
new file mode 100644
index 0000000..19ade4b
--- /dev/null
+++ b/.github/workflows/telegram-api.yml
@@ -0,0 +1,22 @@
+name: 'Telegram API issues'
+
+on:
+ issues:
+ types: [labeled]
+
+permissions:
+ issues: write
+
+jobs:
+ action:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: dessant/support-requests@v3.0.0
+ with:
+ support-label: 'telegram api'
+ issue-comment: >
+ **Github Issues** should be used only for problems with the library itself.
+
+ Questions about Telegram API usage should be asked on **StackOverflow** so the whole community can help and benefit.
+ Click here to open a question: https://stackoverflow.com/questions/ask?tags=c%23+wtelegramclient+telegram-api
+ close-issue: true
diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs
index 8e99634..d2c888a 100644
--- a/src/TL.Helpers.cs
+++ b/src/TL.Helpers.cs
@@ -169,6 +169,18 @@ namespace TL
/// An estimation of the number of days ago the user was last seen (Online=0, Recently=1, LastWeek=5, LastMonth=20, LongTimeAgo=150)
public TimeSpan LastSeenAgo => status?.LastSeenAgo ?? TimeSpan.FromDays(150);
public bool IsBot => (flags & Flags.bot) != 0;
+ public IEnumerable ActiveUsernames
+ {
+ get
+ {
+ if (username != null)
+ yield return username;
+ if (usernames != null)
+ foreach (var un in usernames)
+ if (un.flags.HasFlag(Username.Flags.active))
+ yield return un.username;
+ }
+ }
}
/// a null value means userStatusEmpty = last seen a long time ago, more than a month (or blocked/deleted users)