mirror of
https://github.com/Nick80835/microbot
synced 2025-09-03 16:05:49 +00:00
move shit
This commit is contained in:
@@ -1 +1,91 @@
|
||||
import ubot.micro_bot
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import sys
|
||||
from logging import INFO, basicConfig, getLogger
|
||||
|
||||
import telethon as tt
|
||||
from telethon.errors.rpcerrorlist import PhoneNumberInvalidError
|
||||
from telethon.network.connection.tcpabridged import \
|
||||
ConnectionTcpAbridged as CTA
|
||||
|
||||
from .loader import Loader
|
||||
from .settings import Settings
|
||||
|
||||
if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 6):
|
||||
print("This program requires at least Python 3.6.0 to work correctly, exiting.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class MicroBot():
|
||||
client = None
|
||||
settings = Settings()
|
||||
logger = None
|
||||
loader = None
|
||||
|
||||
def __init__(self):
|
||||
self.start_logger()
|
||||
self.start_client()
|
||||
self.start_loader()
|
||||
|
||||
def run_until_done(self):
|
||||
self.loader.load_all_modules()
|
||||
self.logger.info("Client successfully started.")
|
||||
self.client.run_until_disconnected()
|
||||
self.client.loop.run_until_complete(self.loader.aioclient.close())
|
||||
|
||||
def start_loader(self):
|
||||
self.loader = Loader(self.client, self.logger, self.settings)
|
||||
|
||||
def start_logger(self):
|
||||
basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=INFO)
|
||||
self.logger = getLogger(__name__)
|
||||
|
||||
def _check_config(self):
|
||||
session_name = self.settings.get_config("session_name")
|
||||
api_key = self.settings.get_config("api_key")
|
||||
api_hash = self.settings.get_config("api_hash")
|
||||
|
||||
while not api_key:
|
||||
api_key = input("Enter your API key: ")
|
||||
|
||||
self.settings.set_config("api_key", api_key)
|
||||
|
||||
while not api_hash:
|
||||
api_hash = input("Enter your API hash: ")
|
||||
|
||||
self.settings.set_config("api_hash", api_hash)
|
||||
|
||||
if not session_name:
|
||||
session_name = "user0"
|
||||
self.settings.set_config("session_name", session_name)
|
||||
|
||||
return api_key, api_hash, session_name
|
||||
|
||||
def start_client(self):
|
||||
api_key, api_hash, session_name = self._check_config()
|
||||
|
||||
self.client = tt.TelegramClient(session_name, api_key, api_hash, connection=CTA)
|
||||
|
||||
try:
|
||||
self.client.start()
|
||||
except PhoneNumberInvalidError:
|
||||
self.logger.error("The phone number provided is invalid, exiting.")
|
||||
sys.exit(2)
|
||||
|
||||
async def stop_client(self, reason=None):
|
||||
if reason:
|
||||
self.logger.info("Stopping client for reason: %s", reason)
|
||||
else:
|
||||
self.logger.info("Stopping client.")
|
||||
|
||||
await self.loader.aioclient.close()
|
||||
await self.client.disconnect()
|
||||
|
||||
|
||||
micro_bot = MicroBot()
|
||||
ldr = micro_bot.loader
|
||||
|
||||
try:
|
||||
micro_bot.run_until_done()
|
||||
except:
|
||||
micro_bot.client.loop.run_until_complete(micro_bot.stop_client())
|
||||
|
@@ -1,91 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import sys
|
||||
from logging import INFO, basicConfig, getLogger
|
||||
|
||||
import telethon as tt
|
||||
from telethon.errors.rpcerrorlist import PhoneNumberInvalidError
|
||||
from telethon.network.connection.tcpabridged import \
|
||||
ConnectionTcpAbridged as CTA
|
||||
|
||||
from .loader import Loader
|
||||
from .settings import Settings
|
||||
|
||||
if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 6):
|
||||
print("This program requires at least Python 3.6.0 to work correctly, exiting.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class MicroBot():
|
||||
client = None
|
||||
settings = Settings()
|
||||
logger = None
|
||||
loader = None
|
||||
|
||||
def __init__(self):
|
||||
self.start_logger()
|
||||
self.start_client()
|
||||
self.start_loader()
|
||||
|
||||
def run_until_done(self):
|
||||
self.loader.load_all_modules()
|
||||
self.logger.info("Client successfully started.")
|
||||
self.client.run_until_disconnected()
|
||||
self.client.loop.run_until_complete(self.loader.aioclient.close())
|
||||
|
||||
def start_loader(self):
|
||||
self.loader = Loader(self.client, self.logger, self.settings)
|
||||
|
||||
def start_logger(self):
|
||||
basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=INFO)
|
||||
self.logger = getLogger(__name__)
|
||||
|
||||
def _check_config(self):
|
||||
session_name = self.settings.get_config("session_name")
|
||||
api_key = self.settings.get_config("api_key")
|
||||
api_hash = self.settings.get_config("api_hash")
|
||||
|
||||
while not api_key:
|
||||
api_key = input("Enter your API key: ")
|
||||
|
||||
self.settings.set_config("api_key", api_key)
|
||||
|
||||
while not api_hash:
|
||||
api_hash = input("Enter your API hash: ")
|
||||
|
||||
self.settings.set_config("api_hash", api_hash)
|
||||
|
||||
if not session_name:
|
||||
session_name = "user0"
|
||||
self.settings.set_config("session_name", session_name)
|
||||
|
||||
return api_key, api_hash, session_name
|
||||
|
||||
def start_client(self):
|
||||
api_key, api_hash, session_name = self._check_config()
|
||||
|
||||
self.client = tt.TelegramClient(session_name, api_key, api_hash, connection=CTA)
|
||||
|
||||
try:
|
||||
self.client.start()
|
||||
except PhoneNumberInvalidError:
|
||||
self.logger.error("The phone number provided is invalid, exiting.")
|
||||
sys.exit(2)
|
||||
|
||||
async def stop_client(self, reason=None):
|
||||
if reason:
|
||||
self.logger.info("Stopping client for reason: %s", reason)
|
||||
else:
|
||||
self.logger.info("Stopping client.")
|
||||
|
||||
await self.loader.aioclient.close()
|
||||
await self.client.disconnect()
|
||||
|
||||
|
||||
micro_bot = MicroBot()
|
||||
ldr = micro_bot.loader
|
||||
|
||||
try:
|
||||
micro_bot.run_until_done()
|
||||
except:
|
||||
micro_bot.client.loop.run_until_complete(micro_bot.stop_client())
|
@@ -9,7 +9,7 @@ from platform import python_version
|
||||
import psutil
|
||||
from telethon import version
|
||||
|
||||
from ubot.micro_bot import ldr, micro_bot
|
||||
from ubot import ldr, micro_bot
|
||||
|
||||
|
||||
@ldr.add("eval", owner=True, hide_help=True)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
CAT_URL = 'http://api.thecatapi.com/v1/images/search'
|
||||
DOG_URL = 'http://api.thedogapi.com/v1/images/search'
|
||||
|
@@ -4,7 +4,7 @@ from time import time_ns
|
||||
|
||||
from telethon import Button
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
DAN_URL = "http://danbooru.donmai.us/posts.json"
|
||||
DAN_SAUCE_URL = "https://danbooru.donmai.us/posts/"
|
||||
|
@@ -30,7 +30,7 @@ from random import randint, uniform
|
||||
|
||||
from PIL import Image, ImageEnhance
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
|
||||
@ldr.add("deepfry", pattern_extra="(f|)", userlocking=True, help="Deepfries images, takes a number of passes as an argument.")
|
||||
|
@@ -5,7 +5,7 @@ import io
|
||||
from PIL import Image, ImageOps
|
||||
from speedtest import Speedtest
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
|
||||
@ldr.add("speed", owner=True, hide_help=True)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
from random import choice, shuffle
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
BOARD_URL = "https://a.4cdn.org/{0}/threads.json"
|
||||
POST_URL = "https://a.4cdn.org/{0}/thread/{1}.json"
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
from random import choice
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
bot_name = ldr.settings.get_config("bot_name") or "bot"
|
||||
|
||||
|
@@ -4,7 +4,7 @@ from time import time_ns
|
||||
|
||||
from telethon import Button
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
GEL_URL = "https://gelbooru.com/index.php"
|
||||
GEL_SAUCE_URL = "https://gelbooru.com/index.php?page=post&s=view&id="
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
from random import choice
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
emoji = list("😂😝🤪🤩😤🥵🤯🥶😱🤔😩🙄💀👻🤡😹👀👁👌💦🔥🌚🌝🌞🔫💯")
|
||||
b_emoji = "🅱️"
|
||||
|
@@ -4,7 +4,7 @@ import io
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
NEKO_URL = "https://nekos.life/api/v2/img/"
|
||||
NEKO_TYPES_NSFW = ['lewd', 'tits', 'trap', 'anal', 'gasm', 'spank', 'feet', 'blowjob']
|
||||
|
@@ -3,7 +3,7 @@
|
||||
import asyncpraw
|
||||
from asyncprawcore import exceptions as redex
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
REDDIT = asyncpraw.Reddit(client_id='-fmzwojFG6JkGg',
|
||||
client_secret=None,
|
||||
|
@@ -4,7 +4,7 @@ from time import time_ns
|
||||
|
||||
from telethon import Button
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
SAN_URL = "https://capi-v2.sankakucomplex.com/posts"
|
||||
SAN_SAUCE_URL = "https://beta.sankakucomplex.com/post/show/"
|
||||
|
@@ -13,7 +13,7 @@ from telethon.tl.types import DocumentAttributeVideo
|
||||
|
||||
from ubot.fixes.fast_telethon import upload_file
|
||||
from ubot.fixes.parallel_download import download
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
os.environ["HOWDOI_SEARCH_ENGINE"] = "bing"
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import io
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
|
||||
@ldr.add("color")
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
from time import time_ns
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
|
||||
@ldr.add("del", help="Deletes messages from this bot, it's a safety feature.")
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
import io
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
UD_QUERY_URL = 'http://api.urbandictionary.com/v0/define'
|
||||
UD_RANDOM_URL = 'http://api.urbandictionary.com/v0/random'
|
||||
|
@@ -4,7 +4,7 @@ from time import time_ns
|
||||
|
||||
from telethon import Button
|
||||
|
||||
from ubot.micro_bot import ldr
|
||||
from ubot import ldr
|
||||
|
||||
YAN_URL = "https://yande.re/post.json"
|
||||
YAN_SAUCE_URL = "https://yande.re/post/show/"
|
||||
|
Reference in New Issue
Block a user