Skip to content

Instantly share code, notes, and snippets.

View aahnik's full-sized avatar
🏠
something's happening!

Aahnik Daw aahnik

🏠
something's happening!
View GitHub Profile
@aahnik
aahnik / #clean-pip.md
Last active May 17, 2021 08:03
A script to uninstall all python packages via pip and clear cache. (For Unix based systems only. Ditch Windows today.)

Run this script directly

curl -Lks bit.ly/pipclear | python
@aahnik
aahnik / bash_string_to_array.sh
Created May 13, 2021 10:04
Convert a bash string to an array of words. Using the IFS (internal field seperator).
export IFS=" "
str="hello world what is happening"
arr=( $str )
echo first word: ${arr[0]}
echo second word: ${arr[1]}
echo third word: ${arr[2]}
@aahnik
aahnik / bot.py
Last active February 1, 2022 20:25
A simple button creator bot using python-telegram-bot #telegram #python
# pip install python-dotenv python-telegram-bot
# create a .env file with
# BOT_TOKEN=...
# in the same dir as of this script
import logging
from dotenv import load_dotenv
from telegram.ext.filters import Filters
from telegram import ParseMode
import os
@aahnik
aahnik / partize.py
Created May 1, 2021 15:56
Create part subfolders from a folder containing large no of files
# AAHNIK 2021
# ditch windows, may fail there
# for my personal use, i dont care to write a more detailed docs
import os
path = os.getcwd()
path = "/home/aahnik/Downloads/Telegram Desktop/dharmic_cause_ChatExport_2021-04-30/files"
@aahnik
aahnik / #poetry-docker.md
Last active May 26, 2021 04:11
Python package manager poetry, in a docker image. Base your docker image on this, to get poetry out of the box. https://hub.docker.com/r/aahnik/poetry-docker

How to use?

[warning] aahnik/poetry-docker is no longer maintained. Build and publish your own image

interactively

$ docker run -it aahnik/poetry-docker
# will open bash shell inside the container
# run poetry --version to check
@aahnik
aahnik / locorg.py
Last active April 3, 2022 16:26
organize files of loconotion output https://github.com/leoncvlt/loconotion/issues/36
# MIT License
# Aahnik 2021
# a script to organize the files in loconotion output
# also updates html and css files
# unix (linux / mac) style file paths are used in the program,
# will fail inevitably if run on windows
# ditch windows
import logging
import os
@aahnik
aahnik / #run_multi.md
Last active August 5, 2022 14:51
Run multiple bot telegram bot clients using gnu-screen (terminal-multiplexer). Supply bot tokens via bots.yml to this script. [telethon,telegram,bots.gnu-screen,screen,multiples]

First of all you make a bot whose multiple instances are to be run from the same server.

Suppose the bot is run by invoking main.py with the bot_name and token as command line arguments.

Syntax:

[PYTHON] [ENTRY_POINT] [bot_name] [token]

Example:

python main.py mysamplebot "173453434:42jhs894_13234jsjgasjs"

@aahnik
aahnik / #get_session_string.md
Last active March 12, 2024 01:56
A python script to get Telegram session string after logging into user account. Using Telethon.

You must ensure that you have Telethon installed. Run pip install telethon to install.

[optional]

You can can create file called .env in the directory from which you are running the script.

.env

@aahnik
aahnik / #channel joiner.md
Last active October 22, 2022 19:54
Telethon , telegram , join telegram channels from a list

Here is an example of .env file you need to use:

Screenshot from 2021-01-15 17-21-41

Make sure to have telethon and python-dotenv installed.

@aahnik
aahnik / get_chat_info.py
Last active January 8, 2021 15:47
Telegram Chat info. Telethon. Python.
import asyncio
from settings import API_ID, API_HASH
from telethon import TelegramClient
from utils import _
async def get_chat_id(ref=None):
async with TelegramClient('tg_session', API_ID, API_HASH) as client:
if not ref:
ref = input('Enter link/phone/username/id to get chat info: ')