forked from uniborg/uniborg
Merge branch 'master' of https://github.com/uniborg/uniborg
This commit is contained in:
commit
b6b262f93d
|
@ -1,16 +1,14 @@
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
from telethon import events, utils
|
|
||||||
from telethon.tl import types, functions
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import asyncio
|
|
||||||
import random
|
import random
|
||||||
import json
|
import json
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
|
from telethon import events
|
||||||
|
|
||||||
pats = []
|
pats = []
|
||||||
oops = "OOPSIE WOOPSIE!! Uwu We madea fucky wucky!! A wittle fucko boingo! " \
|
oops = "OOPSIE WOOPSIE!! Uwu We madea fucky wucky!! A wittle fucko boingo! " \
|
||||||
"The code monkeys at our headquarters are working VEWY HAWD to fix " \
|
"The code monkeys at our headquarters are working VEWY HAWD to fix " \
|
||||||
|
|
|
@ -109,7 +109,7 @@ async def reparse(event):
|
||||||
message, msg_entities = await borg._parse_message_text(event.text, parse)
|
message, msg_entities = await borg._parse_message_text(event.text, parse)
|
||||||
# filter out entities that we don't generate
|
# filter out entities that we don't generate
|
||||||
old_entities = []
|
old_entities = []
|
||||||
for entity in (event.message.entities or []):
|
for entity in event.message.entities or []:
|
||||||
if isinstance(entity, PARSED_ENTITIES):
|
if isinstance(entity, PARSED_ENTITIES):
|
||||||
old_entities.append(entity)
|
old_entities.append(entity)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import uuid
|
|
||||||
from telethon import events, utils
|
from telethon import events, utils
|
||||||
from telethon.tl import types, functions
|
from telethon.tl import types
|
||||||
|
|
||||||
|
|
||||||
TYPE_TEXT = 0
|
TYPE_TEXT = 0
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
FILE_NAME = 'data.json'
|
FILE_NAME = 'data.json'
|
||||||
|
@ -21,11 +21,11 @@ class Storage:
|
||||||
self._storage._save()
|
self._storage._save()
|
||||||
|
|
||||||
def __init__(self, root):
|
def __init__(self, root):
|
||||||
self._root = root
|
self._root = Path(root)
|
||||||
self._autosave = True
|
self._autosave = True
|
||||||
self._guard = self._Guard(self)
|
self._guard = self._Guard(self)
|
||||||
if os.path.isfile(os.path.join(self._root, FILE_NAME)):
|
if (self._root / FILE_NAME).is_file():
|
||||||
with open(os.path.join(self._root, FILE_NAME)) as fp:
|
with open(self._root / FILE_NAME) as fp:
|
||||||
self._data = json.load(fp)
|
self._data = json.load(fp)
|
||||||
else:
|
else:
|
||||||
self._data = {}
|
self._data = {}
|
||||||
|
@ -47,7 +47,7 @@ class Storage:
|
||||||
self._save()
|
self._save()
|
||||||
|
|
||||||
def _save(self):
|
def _save(self):
|
||||||
if not os.path.isdir(self._root):
|
if not self._root.is_dir():
|
||||||
os.makedirs(self._root, exist_ok=True)
|
self._root(parents=True, exist_ok=True)
|
||||||
with open(os.path.join(self._root, FILE_NAME), 'w') as fp:
|
with open(self._root / FILE_NAME, 'w') as fp:
|
||||||
json.dump(self._data, fp)
|
json.dump(self._data, fp)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
import os
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import logging
|
import logging
|
||||||
|
@ -24,15 +23,15 @@ class Uniborg(TelegramClient):
|
||||||
# storage should be a callable accepting plugin name -> Storage object.
|
# storage should be a callable accepting plugin name -> Storage object.
|
||||||
# This means that using the Storage type as a storage would work too.
|
# This means that using the Storage type as a storage would work too.
|
||||||
self._name = session
|
self._name = session
|
||||||
self.storage = storage or (lambda n: Storage(os.path.join('data', n)))
|
self.storage = storage or (lambda n: Storage(Path("data") / n))
|
||||||
self._logger = logging.getLogger(session)
|
self._logger = logging.getLogger(session)
|
||||||
self._plugins = {}
|
self._plugins = {}
|
||||||
self._plugin_path = plugin_path
|
self._plugin_path = plugin_path
|
||||||
|
|
||||||
super().__init__(
|
kwargs = {
|
||||||
session,
|
"api_id": 6, "api_hash": "eb06d4abfb49dc3eeb1aeb98ae0f581e",
|
||||||
6, "eb06d4abfb49dc3eeb1aeb98ae0f581e", # yarr
|
**kwargs}
|
||||||
**kwargs)
|
super().__init__(session, **kwargs)
|
||||||
|
|
||||||
# This is a hack, please avert your eyes
|
# This is a hack, please avert your eyes
|
||||||
# We want this in order for the most recently added handler to take
|
# We want this in order for the most recently added handler to take
|
||||||
|
|
Loading…
Reference in New Issue