Skip to content

Commit

Permalink
core: add typehits to config
Browse files Browse the repository at this point in the history
Signed-off-by: Sayan Biswas <sayan@pokurt.me>
  • Loading branch information
Dank-del committed Oct 21, 2021
1 parent f7561bd commit 599cf7c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 54 deletions.
63 changes: 32 additions & 31 deletions tg_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import sys
import time
from typing import List
import spamwatch
import telegram.ext as tg
from telethon import TelegramClient
Expand Down Expand Up @@ -48,42 +49,42 @@ def get_user_list(key):
class KigyoINIT:
def __init__(self, parser: ConfigParser):
self.parser = parser
self.SYS_ADMIN = self.parser.getint('SYS_ADMIN', 0)
self.OWNER_ID = self.parser.getint('OWNER_ID')
self.OWNER_USERNAME = self.parser.get('OWNER_USERNAME', None)
self.APP_ID = self.parser.getint("APP_ID")
self.API_HASH = self.parser.get("API_HASH")
self.WEBHOOK = self.parser.getboolean('WEBHOOK', False)
self.URL = self.parser.get('URL', None)
self.CERT_PATH = self.parser.get('CERT_PATH', None)
self.PORT = self.parser.getint('PORT', None)
self.INFOPIC = self.parser.getboolean('INFOPIC', False)
self.DEL_CMDS = self.parser.getboolean("DEL_CMDS", False)
self.STRICT_GBAN = self.parser.getboolean("STRICT_GBAN", False)
self.ALLOW_EXCL = self.parser.getboolean("ALLOW_EXCL", False)
self.CUSTOM_CMD = ['/', '!']
self.BAN_STICKER = self.parser.get("BAN_STICKER", None)
self.TOKEN = self.parser.get("TOKEN")
self.DB_URI = self.parser.get("SQLALCHEMY_DATABASE_URI")
self.SYS_ADMIN: int = self.parser.getint('SYS_ADMIN', 0)
self.OWNER_ID: int = self.parser.getint('OWNER_ID')
self.OWNER_USERNAME: str = self.parser.get('OWNER_USERNAME', None)
self.APP_ID: str = self.parser.getint("APP_ID")
self.API_HASH: str = self.parser.get("API_HASH")
self.WEBHOOK: bool = self.parser.getboolean('WEBHOOK', False)
self.URL: str = self.parser.get('URL', None)
self.CERT_PATH: str = self.parser.get('CERT_PATH', None)
self.PORT: int = self.parser.getint('PORT', None)
self.INFOPIC: bool = self.parser.getboolean('INFOPIC', False)
self.DEL_CMDS: bool = self.parser.getboolean("DEL_CMDS", False)
self.STRICT_GBAN: bool = self.parser.getboolean("STRICT_GBAN", False)
self.ALLOW_EXCL: bool = self.parser.getboolean("ALLOW_EXCL", False)
self.CUSTOM_CMD: List[str] = ['/', '!']
self.BAN_STICKER: str = self.parser.get("BAN_STICKER", None)
self.TOKEN: str = self.parser.get("TOKEN")
self.DB_URI: str = self.parser.get("SQLALCHEMY_DATABASE_URI")
self.LOAD = self.parser.get("LOAD").split()
self.LOAD = list(map(str, self.LOAD))
self.MESSAGE_DUMP = self.parser.getint('MESSAGE_DUMP', None)
self.GBAN_LOGS = self.parser.getint('GBAN_LOGS', None)
self.LOAD: List[str] = list(map(str, self.LOAD))
self.MESSAGE_DUMP: int = self.parser.getint('MESSAGE_DUMP', None)
self.GBAN_LOGS: int = self.parser.getint('GBAN_LOGS', None)
self.NO_LOAD = self.parser.get("NO_LOAD").split()
self.NO_LOAD = list(map(str, self.NO_LOAD))
self.spamwatch_api = self.parser.get('spamwatch_api', None)
self.CASH_API_KEY = self.parser.get('CASH_API_KEY', None)
self.TIME_API_KEY = self.parser.get('TIME_API_KEY', None)
self.WALL_API = self.parser.get('WALL_API', None)
self.LASTFM_API_KEY = self.parser.get('LASTFM_API_KEY', None)
self.CF_API_KEY = self.parser.get("CF_API_KEY", None)
self.NO_LOAD: List[str] = list(map(str, self.NO_LOAD))
self.spamwatch_api: str = self.parser.get('spamwatch_api', None)
self.CASH_API_KEY: str = self.parser.get('CASH_API_KEY', None)
self.TIME_API_KEY: str = self.parser.get('TIME_API_KEY', None)
self.WALL_API: str = self.parser.get('WALL_API', None)
self.LASTFM_API_KEY: str = self.parser.get('LASTFM_API_KEY', None)
self.CF_API_KEY: str = self.parser.get("CF_API_KEY", None)
self.bot_id = 0 #placeholder
self.bot_name = "Kigyo" #placeholder
self.bot_username = "KigyoRobot" #placeholder
self.DEBUG = self.parser.getboolean("IS_DEBUG", False)
self.DROP_UPDATES = self.parser.getboolean("DROP_UPDATES", True)
self.BOT_API_URL = self.parser.get('BOT_API_URL', "https://api.telegram.org/bot")
self.BOT_API_FILE_URL = self.parser.get('BOT_API_FILE_URL', "https://api.telegram.org/file/bot")
self.DEBUG: bool = self.parser.getboolean("IS_DEBUG", False)
self.DROP_UPDATES: bool = self.parser.getboolean("DROP_UPDATES", True)
self.BOT_API_URL: str = self.parser.get('BOT_API_URL', "https://api.telegram.org/bot")
self.BOT_API_FILE_URL: str = self.parser.get('BOT_API_FILE_URL', "https://api.telegram.org/file/bot")


def init_sw(self):
Expand Down
39 changes: 16 additions & 23 deletions tg_bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,14 @@ def test(update: Update, context: CallbackContext):
update: Update -
context: CallbackContext -
'''

# pprint(ast.literal_eval(str(update)))
# update.effective_message.reply_text("Hola tester! _I_ *have* `markdown`", parse_mode=ParseMode.MARKDOWN)
update.effective_message.reply_text("This person edited a message")
print(update.effective_message)

@kigcallback(pattern=r'start_back')
@kigcmd(command='start', pass_args=True)
def start(update: Update, context: CallbackContext): # sourcery no-metrics
def start(update: Update, context: CallbackContext): # sourcery no-metrics
'''#TODO
Params:
Expand All @@ -137,7 +136,7 @@ def start(update: Update, context: CallbackContext): # sourcery no-metrics
args = context.args

if hasattr(update, 'callback_query'):
query = update.callback_query
query = update.callback_query
if hasattr(query, 'id'):
first_name = update.effective_user.first_name
update.effective_message.edit_text(
Expand All @@ -152,7 +151,7 @@ def start(update: Update, context: CallbackContext): # sourcery no-metrics
[
InlineKeyboardButton(
text=gs(chat.id, "support_chat_link_btn"),
url=f"https://t.me/YorktownEagleUnion",
url='https://t.me/YorktownEagleUnion',
),
InlineKeyboardButton(
text=gs(chat.id, "updates_channel_link_btn"),
Expand All @@ -162,30 +161,27 @@ def start(update: Update, context: CallbackContext): # sourcery no-metrics
text=gs(chat.id, "src_btn"),
url="https://github.com/Dank-del/EnterpriseALRobot",
),

],

[

InlineKeyboardButton(
text="Try inline",
switch_inline_query_current_chat="",
),
InlineKeyboardButton(
text="Help",
callback_data="help_back",
),
),
InlineKeyboardButton(
text=gs(chat.id, "add_bot_to_group_btn"),
url="t.me/{}?startgroup=true".format(
context.bot.username
),
),
]

],
]
),
)

context.bot.answer_callback_query(query.id)
return

Expand Down Expand Up @@ -223,7 +219,7 @@ def start(update: Update, context: CallbackContext): # sourcery no-metrics
[
InlineKeyboardButton(
text=gs(chat.id, "support_chat_link_btn"),
url=f"https://t.me/YorktownEagleUnion",
url='https://t.me/YorktownEagleUnion',
),
InlineKeyboardButton(
text=gs(chat.id, "updates_channel_link_btn"),
Expand All @@ -233,33 +229,30 @@ def start(update: Update, context: CallbackContext): # sourcery no-metrics
text=gs(chat.id, "src_btn"),
url="https://github.com/Dank-del/EnterpriseALRobot",
),

],

[

InlineKeyboardButton(
text="Try inline",
switch_inline_query_current_chat="",
),
InlineKeyboardButton(
InlineKeyboardButton(
text="Try inline",
switch_inline_query_current_chat="",
),
InlineKeyboardButton(
text="Help",
callback_data="help_back",
),
),
InlineKeyboardButton(
text=gs(chat.id, "add_bot_to_group_btn"),
url="t.me/{}?startgroup=true".format(
context.bot.username
),
),
]

],
]
),
)

else:
update.effective_message.reply_text(gs(chat.id, "grp_start_text"))

if hasattr(update, 'callback_query'):
query = update.callback_query
if hasattr(query, 'id'):
Expand Down

0 comments on commit 599cf7c

Please sign in to comment.