Skip to content

Instantly share code, notes, and snippets.

View MihaZupan's full-sized avatar
🍉
Genocide = bad

Miha Zupan MihaZupan

🍉
Genocide = bad
View GitHub Profile
// using System;
// using System.Text;
// using System.Security.Cryptography;
static bool CheckAuthorization(Dictionary<string, string> fields, string token, string hash)
{
int allowedTimeOffset = 30; // Or whatever you choose
if (!fields.ContainsKey("auth_date")) return false;
if (long.TryParse(fields["auth_date"], out long timestamp))
{
using System;
using System.Text;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace MihaZupan
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace MihaZupan
{
/// <summary>
/// A simple request scheduler to help you conform to rate limiting
/// </summary>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace MihaZupan
{
// Block the caller of WaitOne as long as necesarry
public class RequestScheduler
using System;
using System.Net;
using System.IO;
using Newtonsoft.Json;
using Telegram.Bot.Types;
namespace StackExBot
{
class WebHook
{
@MihaZupan
MihaZupan / Scary telegram link
Created July 27, 2018 17:57
Link that crashes Swift Telegram clients
@MihaZupan
MihaZupan / Even scarrier Telegram link
Last active March 27, 2023 18:20
This link will crash all Telegram Desktop clients
@MihaZupan
MihaZupan / NotifyingInputOnlineFile.cs
Last active August 7, 2018 20:15
InputOnlineFile with progress updates
using System;
using System.IO;
namespace Telegram.Bot.Types.InputFiles
{
public class NotifyingInputOnlineFile : InputOnlineFile
{
private readonly NotifyingStream _notifyingStream;
public NotifyingInputOnlineFile(Stream content, long size)
@MihaZupan
MihaZupan / HelloBot.cs
Created August 11, 2018 17:22
Sample Telegram bot for Telegram.Bot wiki (https://github.com/TelegramBots/Telegram.Bot/wiki)
using System;
using Telegram.Bot;
using Telegram.Bot.Args;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
namespace HelloBot
{
class Program
{
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;