Selaa lähdekoodia

Added inline calendar

TheHamkerCat 5 vuotta sitten
vanhempi
sitoutus
a898a6a6e7
4 muutettua tiedostoa jossa 28 lisäystä ja 21 poistoa
  1. 0 15
      .github/workflows/main.yml
  2. 12 3
      wbb/modules/inline.py
  3. 1 1
      wbb/modules/stickers.py
  4. 15 2
      wbb/utils/inlinefuncs.py

+ 0 - 15
.github/workflows/main.yml

@@ -1,15 +0,0 @@
-name: telegram message
-on: [push]
-jobs:
-
-  build:
-    name: Build
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@master
-    - name: send custom message with args
-      uses: appleboy/telegram-action@master
-      with:
-        to: ${{ secrets.TELEGRAM_TO }}
-        token: ${{ secrets.TELEGRAM_TOKEN }}
-        args: The ${{ github.event_name }} event triggered first step.

+ 12 - 3
wbb/modules/inline.py

@@ -5,13 +5,13 @@ from wbb.utils.inlinefuncs import (
     saavn_func, deezer_func, inline_help_func,
     torrent_func, youtube_func, lyrics_func,
     paste_func, eval_func, github_user_func,
-    github_repo_func
+    github_repo_func, calendar_func
 )
 from pyrogram import filters
 from pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid
 
 __MODULE__ = "Inline"
-__HELP__ = '''
+__HELP__ = '''```
 - alive - Check Bot's Stats.
 - tr [LANG] [QUERY] - Translate Text.
 - ud [QUERY] - Urban Dictionary Query.
@@ -24,11 +24,12 @@ __HELP__ = '''
 - yt [Query] - Youtube Search.
 - torrent [QUERY] - Torrent Search.
 - lyrics [QUERY] - Lyrics Search.
+- calendar - Get Current Month Calendar.
 - eval [CODE] - Execute Python Code.
 - paste [TEXT] - Paste Text On Pastebin. <=500
 - gh_user [USERNAME] - Search A Github User.
 - gh_repo [USERNAME/REPO] - Search A Github Repo. 
-'''
+```'''
 
 
 @app.on_message(filters.command("inline"))
@@ -180,5 +181,13 @@ async def inline_query_handler(client, query):
                 cache_time=2
             )
 
+        elif text.split()[0] == "calendar":
+            answerss = await calendar_func(answers)
+            await client.answer_inline_query(
+                query.id,
+                results=answerss,
+                cache_time=2
+            )
+
     except (IndexError, TypeError, KeyError, ValueError, QueryIdInvalid):
         return

+ 1 - 1
wbb/modules/stickers.py

@@ -115,6 +115,6 @@ async def kang(client, message):
     except (PeerIdInvalid, UserIsBlocked):
         keyboard = InlineKeyboardMarkup(
             [[InlineKeyboardButton(text="Start", url=f"t.me/{BOT_USERNAME}")]])
-        await msg.edit("Contact Me In Pm First", reply_markup=keyboard)
+        await msg.edit("You Need To Start A Private Chat With Me.", reply_markup=keyboard)
     except StickerPngNopng:
         await message.reply_text("Stickers must be png files but the provided image was not a png")

+ 15 - 2
wbb/utils/inlinefuncs.py

@@ -10,18 +10,20 @@ from pyrogram.types import (
 )
 from googletrans import Translator
 from search_engine_parser import GoogleSearch
-from time import time
 from wbb.modules.userbot import eval_executor_func
 from wbb.utils.fetch import fetch
 from wbb.utils.formatter import convert_seconds_to_minutes as time_convert
 from wbb.utils.pastebin import paste
 from pykeyboard import InlineKeyboard
 from sys import version as pyver
-import sys
 from motor import version as mongover
 from pyrogram import __version__ as pyrover
+from time import time
+from datetime import datetime
+import calendar
 import aiohttp
 import json
+import sys
 import asyncio
 
 
@@ -506,3 +508,14 @@ async def github_repo_func(answers, text):
         ))
     return answers
 
+
+async def calendar_func(answers):
+    year, month = str(datetime.now())[0:7].split("-")
+    calendarr = calendar.month(int(year), int(month))
+    msg = f"`{calendarr}`"
+    answers.append(
+        InlineQueryResultArticle(
+            title=f"Calendar For {month}/{year}",
+            input_message_content=InputTextMessageContent(msg)
+        ))
+    return answers