Skip to content

Instantly share code, notes, and snippets.

View immmdreza's full-sized avatar
🪐
Traveling through codes

MohammadReza immmdreza

🪐
Traveling through codes
View GitHub Profile
@immmdreza
immmdreza / CompareAsciiWords.cpp
Created January 6, 2023 11:59
Alphabetically compare 2 words. 0 if they're equal, 1 if the first one should come sooner else 2.
#include <iostream>
using namespace std;
char getVerChar(char target)
{
if (target >= 97 && target <= 122)
{
return target - 32;
}
// Parse string initData from telegram.
var data = HttpUtility.ParseQueryString(initData);
// Put data in a alphabetically sorted dict.
var dataDict = new SortedDictionary<string, string>(
data.AllKeys.ToDictionary(x => x!, x => data[x]!),
StringComparer.Ordinal);
// Constant key to genrate secret key.
var constantKey = "WebAppData";
@immmdreza
immmdreza / Program.vb
Created March 3, 2022 09:12
VB example of telegram bot,
Imports System.Threading
Imports Telegram.Bot
Imports Telegram.Bot.Extensions.Polling
Imports Telegram.Bot.Types
Imports Telegram.Bot.Types.Enums
Module Program
Sub Main()
Dim bot = New TelegramBotClient("BOT_TOKEN")
@immmdreza
immmdreza / generator.py
Created August 20, 2021 07:39
Generate nice looking comments for your code
import os
import textwrap
class Generator:
def __init__(self, file_name):
self.filename, self.file_extension = os.path.splitext(file_name)
if not self.file_extension:
self.file_extension = '.py'
@immmdreza
immmdreza / ImBusy.cs
Last active March 27, 2021 17:24
C# Telegram.Bot ImBusy code to answer only if you send message with more than 10s wait
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Types;
namespace RateLimiter
{
class Program
{
@immmdreza
immmdreza / bot.cs
Created January 14, 2021 07:38
Modern Telegram.Bot Usage example
using System.Collections.Generic;
using System.Threading.Tasks;
using Telegram.Attributes;
using Telegram.Attributes.Filters;
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Filters;
using Telegram.Handlers;
namespace TestPackage
def getClock(second: int):
Second = 0
Minute = 0
Hours = 0
Day = 0
Month = 0
Year = 0
while(second > 0):
if(second < 60):
@immmdreza
immmdreza / clock.py
Created August 23, 2020 19:00
noooo
class Clock:
_Second : int = 0
_Minutes : int = 0
_Hours : int = 0
def FillMe(self, totalSeconds: int):
if(totalSeconds >= 60):
if(totalSeconds >= 3600):
self._Hours = totalSeconds//3600
hoursRemaning = totalSeconds%3600
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
from typing import List
from enum import Enum, auto
class RotationDir(Enum):
X_ROTATE = auto()
Y_ROTATE = auto()
Z_ROTATE = auto()
class Rotation: