fix(bot): prevent flood wait by caching bot session (#1082)
This stop bot from re-login every run.
This commit is contained in:
8
.github/workflows/build-kernel-a12.yml
vendored
8
.github/workflows/build-kernel-a12.yml
vendored
@@ -92,8 +92,12 @@ jobs:
|
|||||||
echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
|
echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Setup mutex for uploading
|
- name: Bot session cache
|
||||||
uses: ben-z/gh-action-mutex@v1.0-alpha-7
|
id: bot_session_cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: scripts/ksubot.session
|
||||||
|
key: ${{ runner.os }}-bot-session
|
||||||
|
|
||||||
- name: Build boot images
|
- name: Build boot images
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
8
.github/workflows/build-kernel-a13.yml
vendored
8
.github/workflows/build-kernel-a13.yml
vendored
@@ -115,8 +115,12 @@ jobs:
|
|||||||
echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
|
echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Setup mutex for uploading
|
- name: Bot session cache
|
||||||
uses: ben-z/gh-action-mutex@v1.0-alpha-7
|
id: bot_session_cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: scripts/ksubot.session
|
||||||
|
key: ${{ runner.os }}-bot-session
|
||||||
|
|
||||||
- name: Build boot images
|
- name: Build boot images
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
8
.github/workflows/build-kernel-a14.yml
vendored
8
.github/workflows/build-kernel-a14.yml
vendored
@@ -76,8 +76,12 @@ jobs:
|
|||||||
echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
|
echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Setup mutex for uploading
|
- name: Bot session cache
|
||||||
uses: ben-z/gh-action-mutex@v1.0-alpha-7
|
id: bot_session_cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: scripts/ksubot.session
|
||||||
|
key: ${{ runner.os }}-bot-session
|
||||||
|
|
||||||
- name: Build boot images
|
- name: Build boot images
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
8
.github/workflows/build-kernel-arcvm.yml
vendored
8
.github/workflows/build-kernel-arcvm.yml
vendored
@@ -115,6 +115,14 @@ jobs:
|
|||||||
name: kernel-ARCVM-${{ matrix.arch }}-${{ matrix.version }}
|
name: kernel-ARCVM-${{ matrix.arch }}-${{ matrix.version }}
|
||||||
path: "${{ env.file_path }}"
|
path: "${{ env.file_path }}"
|
||||||
|
|
||||||
|
- name: Bot session cache
|
||||||
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }}
|
||||||
|
id: bot_session_cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: scripts/ksubot.session
|
||||||
|
key: ${{ runner.os }}-bot-session
|
||||||
|
|
||||||
- name: Post to Telegram
|
- name: Post to Telegram
|
||||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }}
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }}
|
||||||
env:
|
env:
|
||||||
|
|||||||
8
.github/workflows/build-kernel-wsa.yml
vendored
8
.github/workflows/build-kernel-wsa.yml
vendored
@@ -109,6 +109,14 @@ jobs:
|
|||||||
name: kernel-WSA-${{ matrix.arch }}-${{ matrix.version }}
|
name: kernel-WSA-${{ matrix.arch }}-${{ matrix.version }}
|
||||||
path: "${{ env.file_path }}"
|
path: "${{ env.file_path }}"
|
||||||
|
|
||||||
|
- name: Bot session cache
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag'
|
||||||
|
id: bot_session_cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: scripts/ksubot.session
|
||||||
|
key: ${{ runner.os }}-bot-session
|
||||||
|
|
||||||
- name: Post to Telegram
|
- name: Post to Telegram
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag'
|
||||||
env:
|
env:
|
||||||
|
|||||||
8
.github/workflows/build-manager.yml
vendored
8
.github/workflows/build-manager.yml
vendored
@@ -102,9 +102,13 @@ jobs:
|
|||||||
name: manager
|
name: manager
|
||||||
path: manager/app/build/outputs/apk/release/*.apk
|
path: manager/app/build/outputs/apk/release/*.apk
|
||||||
|
|
||||||
- name: Setup mutex for uploading
|
- name: Bot session cache
|
||||||
uses: ben-z/gh-action-mutex@v1.0-alpha-7
|
|
||||||
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
|
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
|
||||||
|
id: bot_session_cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: scripts/ksubot.session
|
||||||
|
key: ${{ runner.os }}-bot-session
|
||||||
|
|
||||||
- name: Upload to telegram
|
- name: Upload to telegram
|
||||||
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
|
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
|
||||||
|
|||||||
8
.github/workflows/build-su.yml
vendored
8
.github/workflows/build-su.yml
vendored
@@ -37,9 +37,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: su
|
name: su
|
||||||
path: ./userspace/su/libs
|
path: ./userspace/su/libs
|
||||||
- name: Setup mutex for uploading
|
- name: Bot session cache
|
||||||
uses: ben-z/gh-action-mutex@v1.0-alpha-7
|
|
||||||
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
|
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
|
||||||
|
id: bot_session_cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: scripts/ksubot.session
|
||||||
|
key: ${{ runner.os }}-bot-session
|
||||||
- name: Upload to telegram
|
- name: Upload to telegram
|
||||||
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
|
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -73,7 +73,9 @@ async def main():
|
|||||||
print("[-] No files to upload")
|
print("[-] No files to upload")
|
||||||
exit(1)
|
exit(1)
|
||||||
print("[+] Logging in Telegram with bot")
|
print("[+] Logging in Telegram with bot")
|
||||||
async with await TelegramClient(session=None, api_id=API_ID, api_hash=API_HASH).start(bot_token=BOT_TOKEN) as bot:
|
script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||||
|
session_dir = os.path.join(script_dir, "ksubot.session")
|
||||||
|
async with await TelegramClient(session=session_dir, api_id=API_ID, api_hash=API_HASH).start(bot_token=BOT_TOKEN) as bot:
|
||||||
caption = [""] * len(files)
|
caption = [""] * len(files)
|
||||||
caption[-1] = get_caption()
|
caption[-1] = get_caption()
|
||||||
print("[+] Caption: ")
|
print("[+] Caption: ")
|
||||||
@@ -83,7 +85,6 @@ async def main():
|
|||||||
print("[+] Sending")
|
print("[+] Sending")
|
||||||
await bot.send_file(entity=CHAT_ID, file=files, caption=caption, reply_to=MESSAGE_THREAD_ID, parse_mode="markdown")
|
await bot.send_file(entity=CHAT_ID, file=files, caption=caption, reply_to=MESSAGE_THREAD_ID, parse_mode="markdown")
|
||||||
print("[+] Done!")
|
print("[+] Done!")
|
||||||
await bot.log_out()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user