Skip to content

Commit

Permalink
added userge updater (beta)
Browse files Browse the repository at this point in the history
fixed .ub

fix welcome

fixed memes

fixed .type

fixed thumb

add .repo command

updated requirements

updated config vars

added userge updater ;P

Signed-off-by: rking32 <[email protected]>
  • Loading branch information
rking32 committed Apr 13, 2020
1 parent f61f457 commit 3f65610
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 95 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def testing(message: Message):

await message.edit("testing...", del_in=5) # this will be automatically deleted after 5 sec

CHANNEL.log("testing completed!") # log to channel
await CHANNEL.log("testing completed!") # log to channel
```

## Requirements
Expand Down
8 changes: 8 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
"LOG_CHANNEL_ID": {
"description": "Telegram Log Channel ID",
"required": false
},
"HEROKU_APP_NAME": {
"description": "given app name to the heroku app",
"required": false
},
"HEROKU_API_KEY": {
"description": "get a Heroku API key from http://dashboard.heroku.com/account",
"required": false
}
},
"addons": [
Expand Down
13 changes: 12 additions & 1 deletion config.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,15 @@ G_DRIVE_PARENT_ID = ""


# Telegram Log Channel ID
LOG_CHANNEL_ID = ""
LOG_CHANNEL_ID = ""


# ----------- Only If Using Heroku ----------- #


# get a Heroku API key from http://dashboard.heroku.com/account
HEROKU_API_KEY = ""


# given app name to the heroku app
HEROKU_APP_NAME = ""
78 changes: 25 additions & 53 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,53 +1,25 @@
aiohttp==3.6.2
async-generator==1.10
async-lru==1.0.1
async-timeout==3.0.1
attrs==19.3.0
beautifulsoup4==4.8.2
cachetools==4.0.0
certifi==2019.11.28
chardet==3.0.4
coverage==5.0.4
dnspython==1.16.0
emoji==0.5.4
google-api-core==1.16.0
google-api-python-client==1.8.0
google-auth==1.12.0
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.4.1
googleapis-common-protos==1.51.0
googletrans==2.4.0
hachoir==3.1.1
httplib2==0.17.0
idna==2.9
lxml==4.5.0
multidict==4.7.5
nest-asyncio==1.3.0
oauth2client==4.1.3
oauthlib==3.1.0
Pillow==7.0.0
protobuf==3.11.3
pyaes==1.6.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pymongo==3.10.1
Pyrogram===0.17.0-asyncio
pySmartDL==1.3.3
PySocks==1.7.1
python-dotenv==0.12.0
pytz==2019.3
requests==2.23.0
requests-oauthlib==1.3.0
rsa==4.0
search-engine-parser==0.5.4
selenium==3.141.0
six==1.14.0
soupsieve==2.0
speedtest-cli==2.1.2
TgCrypto==1.2.0
urbandict==0.6.1
uritemplate==3.0.1
urllib3==1.25.8
wget==3.2
wikipedia==1.4.0
yarl==1.4.2
https://github.com/pyrogram/pyrogram/archive/asyncio.zip
python-dotenv
tgcrypto
pymongo
dnspython
hachoir
Pillow
urbandict
googletrans
search-engine-parser
wikipedia
speedtest-cli
emoji
wget
nest_asyncio
requests
pySmartDL
selenium
google-api-python-client
google-auth-httplib2
google-auth-oauthlib
oauth2client
cowpy
gitpython
heroku3
3 changes: 0 additions & 3 deletions userge/core/_userge/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ def getCLogger(self, name: str) -> CLogger:
This will return new channel logger object.
"""

LOG.info(
LOG_STR.format(f"Creating CLogger => {name}"))

return CLogger(self, name)

@staticmethod
Expand Down
5 changes: 1 addition & 4 deletions userge/core/_userge/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class Message(BaseMessage):
"""
Moded Message Class For Userge
Modded Message Class For Userge
"""

def __init__(self,
Expand Down Expand Up @@ -119,9 +119,6 @@ def cancel_the_process(self) -> None:

def __msg_to_dict(self, message: BaseMessage) -> Dict[str, object]:

LOG.info(
LOG_STR.format("Creating moded message object"))

kwargs_ = vars(message)
del message

Expand Down
22 changes: 13 additions & 9 deletions userge/plugins/fun/memes.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
"(ノಠ ∩ಠ)ノ彡( \\o°o)\\", "“ヽ(´▽`)ノ”",)


@userge.on_cmd(":/$", about="__Check yourself ;)__", name="kek", trigger='')
@userge.on_cmd(":/$", about="__Check yourself, hint: `:/`__", name="kek", trigger='')
async def kek_(message: Message):
"""kek"""
kek = ["/", "\\"]
Expand All @@ -267,20 +267,24 @@ async def kek_(message: Message):
await message.edit(":" + kek[i % 2])


@userge.on_cmd("-_-$", about="__Ok...__", name="lol", trigger='')
@userge.on_cmd("-_-$", about="__Check yourself, hint: `-_-`__", name="lol", trigger='')
async def lol_(message: Message):
"""lol"""
lol = "-_ "
for _ in range(10):
for i in range(15):
if i % 3 == 0:
lol = "-_ "
lol = lol[:-1] + "_-"
await message.edit(lol, parse_mode="html")


@userge.on_cmd(";_;$", about="__Like `-_-` but crying__", name="fun", trigger='')
@userge.on_cmd(";_;$", about="__Like `-_-` but crying, hint: `;_;`__", name="fun", trigger='')
async def fun_(message: Message):
"""fun"""
fun = ";_ "
for _ in range(10):
for i in range(15):
if i % 3 == 0:
fun = ";_ "
fun = fun[:-1] + "_;"
await message.edit(fun, parse_mode="html")

Expand Down Expand Up @@ -400,7 +404,7 @@ async def moon_(message: Message):
deq.rotate(1)

except Exception:
return
await message.delete()


@userge.on_cmd("clock$", about="__kensar clock animation__")
Expand All @@ -415,7 +419,7 @@ async def clock_(message: Message):
deq.rotate(1)

except Exception:
return
await message.delete()


@userge.on_cmd("bt$", about="""\
Expand Down Expand Up @@ -478,7 +482,7 @@ async def clap_(message: Message):
`.[any cowacter]say [text]`
__cowacters:__ {['`' + x + '`' for x in cow.COWACTERS]}""", name="cowsay")
__cowacters:__ `{'`, `'.join(cow.COWACTERS)}`""", name="cowsay")
async def cowsay_(message: Message):
"""cowsay"""
arg = message.matches[0].group(1).lower()
Expand Down Expand Up @@ -869,4 +873,4 @@ async def scam_(message: Message):
count += 5

except Exception:
return
await message.delete()
12 changes: 5 additions & 7 deletions userge/plugins/fun/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
`.type [text | reply to msg]`""")
async def type_(message: Message):
text = message.input_str
if message.reply_to_message:
text = message.reply_to_message.text
text = message.input_or_reply_str

if not text:
await message.err("input not found")
Expand All @@ -41,11 +39,11 @@ async def type_(message: Message):
typing_text = old_text + typing_symbol

try:
await message.edit(typing_text)
await message.try_to_edit(typing_text)
time.sleep(s_t)

await message.edit(old_text)
await message.try_to_edit(old_text)
time.sleep(s_t)

except FloodWait as x:
time.sleep(x.x)
except FloodWait as x_e:
time.sleep(x_e.x)
18 changes: 8 additions & 10 deletions userge/plugins/misc/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import os
import time
from datetime import datetime
from PIL import Image
from userge import userge, Config, Message
from userge.utils import progress

Expand All @@ -29,18 +28,16 @@ async def save_thumb_nail(message: Message):
start_t = datetime.now()
c_time = time.time()

d_f_name = await userge.download_media(message=message.reply_to_message,
file_name=Config.DOWN_PATH,
progress=progress,
progress_args=(
"trying to download", message, c_time))
await userge.download_media(message=message.reply_to_message,
file_name=Config.DOWN_PATH,
progress=progress,
progress_args=(
"trying to download", userge, message, c_time))

Image.open(d_f_name).convert("RGB").save(THUMB_PATH, 'JPEG')
os.remove(d_f_name)
end_t = datetime.now()
ms = (end_t - start_t).seconds
m_s = (end_t - start_t).seconds

await message.edit(f"thumbnail saved in {ms} seconds.", del_in=3)
await message.edit(f"thumbnail saved in {m_s} seconds.", del_in=3)

else:
await message.edit("Reply to a photo to save custom thumbnail", del_in=3)
Expand All @@ -49,6 +46,7 @@ async def save_thumb_nail(message: Message):
@userge.on_cmd('dthumb', about="__Delete thumbnail__")
async def clear_thumb_nail(message: Message):
await message.edit("`processing ...`")

if os.path.exists(THUMB_PATH):
os.remove(THUMB_PATH)

Expand Down
4 changes: 2 additions & 2 deletions userge/plugins/misc/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ async def raw_say(message: Message, name, collection):
kwargs = {
**user_dict,
'chat': message.chat.title if message.chat.title else "this group",
'mention': f"<a href='tg://user?id={user.id}'>\
{user_dict['uname'] or user_dict['flname']}</a>",
'mention': f"<a href='tg://user?id={user.id}'>" + \
f"{user_dict['uname'] or user_dict['flname']}</a>",
}

await message.reply(
Expand Down
15 changes: 15 additions & 0 deletions userge/plugins/tools/repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.


from userge import userge, Message, Config


@userge.on_cmd("repo", about="__get repo link__")
async def getplugins(message: Message):
await message.edit(f"**Hey**, __I am using__ 🥳 [Userge]({Config.OFFICIAL_REPO_LINK}) 😎")
6 changes: 3 additions & 3 deletions userge/plugins/utils/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
@userge.on_cmd('restart', about="__Restarts the bot and reload all plugins__")
async def restart_cmd_handler(m: Message):
await m.edit("Restarting Userge Services")
LOG.info(f"USERGE Services - Restart initiated")
LOG.info("USERGE Services - Restart initiated")
asyncio.create_task(restart(userge, m))


async def restart(c: userge, m: Message):
await c.restart()
await m.edit(f"USERGE Services have been Restarted!")
LOG.info(f"USERGE - Restarted")
await m.edit("USERGE Services have been Restarted!")
LOG.info("USERGE - Restarted")
7 changes: 5 additions & 2 deletions userge/plugins/utils/ub.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ async def urban_dict(message: Message):
await message.err(text=f"No result found for **{query}**")
return

meaning = '\n'.join([i['def'] for i in mean])
example = '\n'.join([i['example'] for i in mean])

output = f"**Query:** `{query}`\n\n\
**Meaning:** __{mean[0]['def']}__\n\n\
**Example:**\n__{mean[0]['example']}__"
**Meaning:**\n__{meaning}__\n\n\
**Example:**\n__{example}__"

await message.edit_or_send_as_file(text=output, caption=query)
Loading

0 comments on commit 3f65610

Please sign in to comment.