réplica de
				https://gitlab.com/ceda_ei/Quadnite-Bot
				synced 2025-10-31 09:10:05 +01:00 
			
		
		
		
	Merge branch 'node_port' into 'master'
Node port See merge request ceda_ei/Quadnite-Bot!3
Este commit está contenido en:
		
							
								
								
									
										29
									
								
								.eslintrc.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										29
									
								
								.eslintrc.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,29 @@ | |||||||
|  | module.exports = { | ||||||
|  | 	"parserOptions": { | ||||||
|  | 		"ecmaVersion": 2018 | ||||||
|  | 	}, | ||||||
|  | 	"env": { | ||||||
|  | 		"node": true, | ||||||
|  | 		"es6": true | ||||||
|  | 	}, | ||||||
|  | 	"extends": "eslint:recommended", | ||||||
|  | 	"rules": { | ||||||
|  | 		"indent": [ "error", "tab" ], | ||||||
|  | 		"operator-linebreak": [ "error", "before" ], | ||||||
|  | 		"semi": [ "error", "always" ], | ||||||
|  | 		"comma-dangle": [ "error", "only-multiline" ], | ||||||
|  | 		"quotes": [ "error", "double" ], | ||||||
|  | 		"no-tabs": [ "error", { "allowIndentationTabs": true } ], | ||||||
|  | 		"padded-blocks": 2, | ||||||
|  | 		"space-before-blocks": 2, | ||||||
|  | 		"comma-style": 2, | ||||||
|  | 		"no-console": 0, | ||||||
|  | 		"valid-typeof": 0, | ||||||
|  | 		"arrow-parens": 0, | ||||||
|  | 		"generator-star-spacing": 0, | ||||||
|  | 		"space-before-function-paren": 0, | ||||||
|  | 		"object-property-newline": 0, | ||||||
|  | 		"new-cap": 0, | ||||||
|  | 		"no-eval": 0 | ||||||
|  | 	} | ||||||
|  | }; | ||||||
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendido
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendido
									
									
								
							| @@ -1 +1 @@ | |||||||
| api_key.php | node_modules | ||||||
|   | |||||||
| @@ -1 +0,0 @@ | |||||||
| <?php return 'xxxxxxxxxx:xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxx'; ?> |  | ||||||
							
								
								
									
										24
									
								
								bot.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										24
									
								
								bot.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,24 @@ | |||||||
|  | const Telegraf = require("telegraf"); | ||||||
|  | const { BOT_API_KEY, FEEDBACK_ID } = process.env; | ||||||
|  | const fs = require("fs").promises; | ||||||
|  | const commands = require("./commands"); | ||||||
|  | const axios = require("axios"); | ||||||
|  |  | ||||||
|  | const bot = new Telegraf(BOT_API_KEY); | ||||||
|  |  | ||||||
|  | const data = [ | ||||||
|  | 	"questions", | ||||||
|  | 	"kys", | ||||||
|  | 	"insults", | ||||||
|  | 	"commands_list", | ||||||
|  | 	"words" | ||||||
|  | ].map(file => | ||||||
|  | 	fs.readFile(file + ".txt", "utf-8") | ||||||
|  | 		.then(list => | ||||||
|  | 			list.split("\n"))); | ||||||
|  |  | ||||||
|  | Promise.all(data) | ||||||
|  | 	.then(data => | ||||||
|  | 		commands(bot, data, FEEDBACK_ID, axios)); | ||||||
|  |  | ||||||
|  | bot.launch(); | ||||||
							
								
								
									
										27
									
								
								commands/absurdify.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										27
									
								
								commands/absurdify.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,27 @@ | |||||||
|  | function absurdify(text) { | ||||||
|  |  | ||||||
|  | 	const text_array = text.split(""); | ||||||
|  | 	return text_array.map((character) => | ||||||
|  | 		Math.random() > 0.5 ? character.toLowerCase(): character.toUpperCase()) | ||||||
|  | 		.join(""); | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | module.exports = () => (ctx) => { | ||||||
|  |  | ||||||
|  | 	const message = ctx.message.text.replace(/^[^ ]+/, ""); | ||||||
|  | 	if (message) { | ||||||
|  |  | ||||||
|  | 		return absurdify(message); | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  |  | ||||||
|  | 		if (ctx.message.reply_to_message) | ||||||
|  | 			return absurdify(ctx.message.reply_to_message.text); | ||||||
|  | 		else | ||||||
|  | 			return "Need text to absurdify. Send /absurdify text or reply to a" | ||||||
|  | 			+ "message with /absurdify"; | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										15
									
								
								commands/feedback.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										15
									
								
								commands/feedback.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | module.exports = (feedback_id) => (ctx) => { | ||||||
|  |  | ||||||
|  | 	const message = ctx.message.text.replace(/^[^ ]+/, ""); | ||||||
|  | 	if (message) { | ||||||
|  |  | ||||||
|  | 		ctx.forwardMessage(feedback_id); | ||||||
|  | 		return "Thanks for the feedback"; | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  |  | ||||||
|  | 		return "To send feedback type in /feedback followed by the feedback"; | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										64
									
								
								commands/index.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										64
									
								
								commands/index.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,64 @@ | |||||||
|  | const random = require("./random"); | ||||||
|  | const insults_fun = require("./insult"); | ||||||
|  | const words_fun = require("./words"); | ||||||
|  | const is = require("./is"); | ||||||
|  | const weebify = require("./weebify"); | ||||||
|  | const absurdify = require("./absurdify"); | ||||||
|  | const feedback = require("./feedback"); | ||||||
|  | const media_wiki = require("./media_wiki"); | ||||||
|  | const info = require("./info"); | ||||||
|  |  | ||||||
|  | module.exports = (bot, [ questions, kys, insults, commands_list, words ], | ||||||
|  | 	feedback_id, axios) => { | ||||||
|  |  | ||||||
|  | 	bot.command("question", (ctx) => ctx.reply(random(questions)())); | ||||||
|  | 	bot.command("word", (ctx) => ctx.reply(random(words)())); | ||||||
|  | 	bot.command("words", (ctx) => ctx.reply(words_fun(random, words)(ctx))); | ||||||
|  | 	bot.telegram.getMe() | ||||||
|  | 		.then(bot_user => { | ||||||
|  |  | ||||||
|  | 			const default_text = (command, text) => `Do you want to ${text} ` | ||||||
|  | 				+ `yourself?\nIf no, reply to someone with /${command} to kill` | ||||||
|  | 				+ ` them or run /${command} username/name.\nYou can suggest ` | ||||||
|  | 				+ `more /${command} replies using /feedback`; | ||||||
|  |  | ||||||
|  | 			bot.command("insult", (ctx) => ctx.reply(insults_fun(random, | ||||||
|  | 				insults, default_text("insult", "insult"), "Watch who you talk" | ||||||
|  | 				+ " to.", ["@" + bot_user.username, bot_user.firstName])(ctx))); | ||||||
|  |  | ||||||
|  | 			bot.command("kys", (ctx) => ctx.reply(insults_fun(random, kys, | ||||||
|  | 				default_text("kys", "kill"), "I can't be killed.", | ||||||
|  | 				["@" + bot_user.username, bot_user.firstName])(ctx))); | ||||||
|  |  | ||||||
|  | 		}); | ||||||
|  |  | ||||||
|  | 	bot.command("commands", (ctx) => ctx.reply(commands_list.join("\n"))); | ||||||
|  | 	bot.command("is", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("are", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("can", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("will", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("shall", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("was", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("do", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("does", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("did", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("should", (ctx) => ctx.reply(is(random)(ctx))); | ||||||
|  | 	bot.command("coin", (ctx) => ctx.reply(random(["Heads", "Tails"])())); | ||||||
|  | 	bot.command("help", (ctx) => ctx.reply("You can either check /commands " | ||||||
|  | 		+ "for a short overview or check the [Help Page]" | ||||||
|  | 		+ "(https://t.me/quadnite/9).", {parse_mode: "Markdown"})); | ||||||
|  | 	bot.command("rate", (ctx) => ctx.reply("[Vote for me on Telegram " | ||||||
|  | 		+ "Directory!](https://t.me/tgdrbot?start=quadnite_bot)", {parse_mode: | ||||||
|  | 			"Markdown"})); | ||||||
|  | 	bot.command("weebify", (ctx) => ctx.reply(weebify()(ctx))); | ||||||
|  | 	bot.command("absurdify", (ctx) => ctx.reply(absurdify()(ctx))); | ||||||
|  | 	bot.command("feedback", (ctx) => ctx.reply(feedback(feedback_id)(ctx))); | ||||||
|  | 	bot.command("wiki", (ctx) => media_wiki(axios, | ||||||
|  | 		"https://en.wikipedia.org/w/api.php")(ctx).then(x => ctx.reply(x, | ||||||
|  | 		{parse_mode: "HTML"}))); | ||||||
|  | 	bot.command("arch_wiki", (ctx) => media_wiki(axios, | ||||||
|  | 		"https://wiki.archlinux.org/api.php")(ctx).then(x => ctx.reply(x, | ||||||
|  | 		{parse_mode: "HTML"}))); | ||||||
|  | 	bot.command("info", (ctx) => ctx.reply(info()(ctx), {parse_mode: "Markdown"})); | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										36
									
								
								commands/info.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										36
									
								
								commands/info.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,36 @@ | |||||||
|  | module.exports = () => (ctx) => { | ||||||
|  |  | ||||||
|  | 	let text = ""; | ||||||
|  | 	const msg = ctx.message; | ||||||
|  | 	text += `Message ID: \`${msg.message_id}\`\n`; | ||||||
|  | 	text += `Chat ID: \`${msg.chat.id}\`\n`; | ||||||
|  | 	text += `User ID: \`${msg.from.id}\`\n`; | ||||||
|  | 	if (msg.reply_to_message) { | ||||||
|  |  | ||||||
|  | 		const reply = msg.reply_to_message; | ||||||
|  | 		text += "\n*Reply to*\n"; | ||||||
|  | 		text += `Message ID: \`${reply.message_id}\`\n`; | ||||||
|  | 		text += `Chat ID: \`${reply.chat.id}\`\n`; | ||||||
|  | 		text += `User ID: \`${reply.from.id}\`\n`; | ||||||
|  |  | ||||||
|  | 		if (reply.forward_from || reply.forward_from_chat) { | ||||||
|  |  | ||||||
|  | 			const forward = reply.forward_from ? reply.forward_from | ||||||
|  | 				:reply.forward_from_chat; | ||||||
|  | 			text += "\n*Forward from*\n"; | ||||||
|  | 			if (reply.forward_from) | ||||||
|  | 				text += "User ID: "; | ||||||
|  | 			else | ||||||
|  | 				text += "Channel ID: "; | ||||||
|  | 			text += `\`${forward.id}\`\n`; | ||||||
|  | 			text += "Message Date: `"; | ||||||
|  | 			const date = new Date(reply.forward_date); | ||||||
|  | 			text += date.toUTCString(); | ||||||
|  | 			text += "`"; | ||||||
|  |  | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  | 	return text; | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										28
									
								
								commands/insult.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										28
									
								
								commands/insult.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,28 @@ | |||||||
|  | module.exports = (random, kys, default_text, bot_text, excluded_names) => (ctx) => { | ||||||
|  |  | ||||||
|  | 	if (ctx.message.reply_to_message) { | ||||||
|  |  | ||||||
|  | 		const { from } = ctx.message.reply_to_message; | ||||||
|  | 		const name = from.username ? "@" + from.username : from.firstName; | ||||||
|  | 		if (name == excluded_names[0]) | ||||||
|  | 			return bot_text; | ||||||
|  | 		return random(kys)().replace(/##name##/g, name); | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  |  | ||||||
|  | 		const text_array = ctx.message.text.split(" "); | ||||||
|  | 		if (text_array.length > 1) { | ||||||
|  |  | ||||||
|  | 			const name = text_array[1]; | ||||||
|  | 			if (excluded_names.includes(name) | ||||||
|  | 				|| excluded_names.includes("@" + name)) | ||||||
|  | 				return bot_text; | ||||||
|  |  | ||||||
|  | 			return random(kys)().replace(/##name##/g, name); | ||||||
|  |  | ||||||
|  | 		} else | ||||||
|  | 			return default_text; | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										12
									
								
								commands/is.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										12
									
								
								commands/is.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | module.exports = (random) => (ctx) => | ||||||
|  | { | ||||||
|  |  | ||||||
|  | 	const text_array = ctx.message.text.split(" "); | ||||||
|  | 	if (text_array.length == 1) | ||||||
|  | 		return "You know, you also have to ask the question."; | ||||||
|  |  | ||||||
|  | 	return random([["Yes", "Yep", "Yeah", "Yus", "Ja", "Ya", "Aye", "Ay", "Oui"], | ||||||
|  | 		["No", "Nopes", "Nu", "Nah", "Nein", "Naw", "Nay", "Yesn't"]][Math.round( | ||||||
|  | 		Math.random())])(); | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										22
									
								
								commands/media_wiki.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										22
									
								
								commands/media_wiki.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | module.exports = (axios, url) => (ctx) => { | ||||||
|  |  | ||||||
|  | 	const message = ctx.message.text.replace(/^[^ ]+/, ""); | ||||||
|  | 	if (message) { | ||||||
|  |  | ||||||
|  | 		return axios.get(`${url}?action=opensearch&format=json&search=` | ||||||
|  | 			+ `${encodeURIComponent(message)}`) | ||||||
|  | 			.then((res) => { | ||||||
|  |  | ||||||
|  | 				const names = res.data[1]; | ||||||
|  | 				const urls = res.data[3]; | ||||||
|  | 				if (names.length == 0) | ||||||
|  | 					return "No results found"; | ||||||
|  | 				return "Results\n\n" + names.map((val, index) => | ||||||
|  | 					`<a href="${urls[index]}">${val}</a>`).join("\n"); | ||||||
|  |  | ||||||
|  | 			}); | ||||||
|  |  | ||||||
|  | 	} else | ||||||
|  | 		return Promise.resolve("Missing search query."); | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										5
									
								
								commands/random.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										5
									
								
								commands/random.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | module.exports = (list = []) => (n = 1) => | ||||||
|  | 	Array(n) | ||||||
|  | 		.fill(0) | ||||||
|  | 		.map(() => list[Math.floor(Math.random() * list.length)]) | ||||||
|  | 		.join("\n"); | ||||||
							
								
								
									
										55
									
								
								commands/weebify.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										55
									
								
								commands/weebify.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,55 @@ | |||||||
|  | function weebify(text) { | ||||||
|  |  | ||||||
|  | 	const dict = { | ||||||
|  | 		a : "卂", | ||||||
|  | 		b : "乃", | ||||||
|  | 		c : "匚", | ||||||
|  | 		d : "刀", | ||||||
|  | 		e : "乇", | ||||||
|  | 		f : "下", | ||||||
|  | 		g : "厶", | ||||||
|  | 		h : "卄", | ||||||
|  | 		i : "工", | ||||||
|  | 		j : "丁", | ||||||
|  | 		k : "长", | ||||||
|  | 		l : "乚", | ||||||
|  | 		m : "从", | ||||||
|  | 		n : "𠘨", | ||||||
|  | 		o : "口", | ||||||
|  | 		p : "尸", | ||||||
|  | 		q : "㔿", | ||||||
|  | 		r : "尺", | ||||||
|  | 		s : "丂", | ||||||
|  | 		t : "丅", | ||||||
|  | 		u : "凵", | ||||||
|  | 		v : "リ", | ||||||
|  | 		w : "山", | ||||||
|  | 		x : "乂", | ||||||
|  | 		y : "丫", | ||||||
|  | 		z : "乙" | ||||||
|  | 	}; | ||||||
|  | 	const text_array = text.toLowerCase().split(""); | ||||||
|  | 	return text_array.map((character) => | ||||||
|  | 		dict[character] ? dict[character] : character) | ||||||
|  | 		.join(""); | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | module.exports = () => (ctx) => { | ||||||
|  |  | ||||||
|  | 	const message = ctx.message.text.replace(/^[^ ]+/, ""); | ||||||
|  | 	if (message) { | ||||||
|  |  | ||||||
|  | 		return weebify(message); | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  |  | ||||||
|  | 		if (ctx.message.reply_to_message) | ||||||
|  | 			return weebify(ctx.message.reply_to_message.text); | ||||||
|  | 		else | ||||||
|  | 			return "Need text to weebify. Send /weebify text or reply to a " | ||||||
|  | 			+ "message with /weebify"; | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										21
									
								
								commands/words.js
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										21
									
								
								commands/words.js
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | module.exports = (random, words) => (ctx) => { | ||||||
|  |  | ||||||
|  | 	const text_array = ctx.message.text.split(" "); | ||||||
|  | 	if (text_array.length == 1) { | ||||||
|  |  | ||||||
|  | 		return random(words)(10); | ||||||
|  |  | ||||||
|  | 	} else { | ||||||
|  |  | ||||||
|  | 		const input = parseInt(text_array[1]); | ||||||
|  | 		if (input && input > 0) | ||||||
|  | 			if (input < 50) | ||||||
|  | 				return random(words)(input); | ||||||
|  | 			else | ||||||
|  | 				return "Too many words."; | ||||||
|  | 		else | ||||||
|  | 			return "Not a valid number."; | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | }; | ||||||
							
								
								
									
										28
									
								
								package.json
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										28
									
								
								package.json
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,28 @@ | |||||||
|  | { | ||||||
|  |   "name": "quadnite-bot", | ||||||
|  |   "version": "1.0.0", | ||||||
|  |   "description": "A Telegram bot that makes chats in group more fun.", | ||||||
|  |   "main": "bot.js", | ||||||
|  |   "scripts": { | ||||||
|  |     "test": "echo \"Error: no test specified\" && exit 1" | ||||||
|  |   }, | ||||||
|  |   "repository": { | ||||||
|  |     "type": "git", | ||||||
|  |     "url": "git+ssh://git@gitlab.com/ceda_ei/Quadnite-Bot.git" | ||||||
|  |   }, | ||||||
|  |   "keywords": [ | ||||||
|  |     "bot", | ||||||
|  |     "telegram", | ||||||
|  |     "telegram-bot" | ||||||
|  |   ], | ||||||
|  |   "author": "Ceda EI", | ||||||
|  |   "license": "GPL-3.0", | ||||||
|  |   "bugs": { | ||||||
|  |     "url": "https://gitlab.com/ceda_ei/Quadnite-Bot/issues" | ||||||
|  |   }, | ||||||
|  |   "homepage": "https://gitlab.com/ceda_ei/Quadnite-Bot#readme", | ||||||
|  |   "dependencies": { | ||||||
|  |     "axios": "^0.18.0", | ||||||
|  |     "telegraf": "^3.27.1" | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										81
									
								
								shrinkwrap.yaml
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										81
									
								
								shrinkwrap.yaml
									
									
									
									
									
										Archivo normal
									
								
							| @@ -0,0 +1,81 @@ | |||||||
|  | dependencies: | ||||||
|  |   axios: 0.18.0 | ||||||
|  |   telegraf: 3.27.1 | ||||||
|  | packages: | ||||||
|  |   /@types/node/10.12.24: | ||||||
|  |     dev: false | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-GWWbvt+z9G5otRBW8rssOFgRY87J9N/qbhqfjMZ+gUuL6zoL+Hm6gP/8qQBG4jjimqdaNLCehcVapZ/Fs2WjCQ== | ||||||
|  |   /axios/0.18.0: | ||||||
|  |     dependencies: | ||||||
|  |       follow-redirects: 1.6.1 | ||||||
|  |       is-buffer: 1.1.6 | ||||||
|  |     dev: false | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI= | ||||||
|  |   /debug/3.1.0: | ||||||
|  |     dependencies: | ||||||
|  |       ms: 2.0.0 | ||||||
|  |     dev: false | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== | ||||||
|  |   /debug/4.1.1: | ||||||
|  |     dependencies: | ||||||
|  |       ms: 2.1.1 | ||||||
|  |     dev: false | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== | ||||||
|  |   /follow-redirects/1.6.1: | ||||||
|  |     dependencies: | ||||||
|  |       debug: 3.1.0 | ||||||
|  |     dev: false | ||||||
|  |     engines: | ||||||
|  |       node: '>=4.0' | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-t2JCjbzxQpWvbhts3l6SH1DKzSrx8a+SsaVf4h6bG4kOXUuPYS/kg2Lr4gQSb7eemaHqJkOThF1BGyjlUkO1GQ== | ||||||
|  |   /is-buffer/1.1.6: | ||||||
|  |     dev: false | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== | ||||||
|  |   /ms/2.0.0: | ||||||
|  |     dev: false | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= | ||||||
|  |   /ms/2.1.1: | ||||||
|  |     dev: false | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== | ||||||
|  |   /node-fetch/2.3.0: | ||||||
|  |     dev: false | ||||||
|  |     engines: | ||||||
|  |       node: 4.x || >=6.0.0 | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA== | ||||||
|  |   /sandwich-stream/2.0.2: | ||||||
|  |     dev: false | ||||||
|  |     engines: | ||||||
|  |       node: '>= 0.10' | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ== | ||||||
|  |   /telegraf/3.27.1: | ||||||
|  |     dependencies: | ||||||
|  |       '@types/node': 10.12.24 | ||||||
|  |       debug: 4.1.1 | ||||||
|  |       node-fetch: 2.3.0 | ||||||
|  |       sandwich-stream: 2.0.2 | ||||||
|  |       telegram-typings: 3.6.1 | ||||||
|  |     dev: false | ||||||
|  |     engines: | ||||||
|  |       node: '>=6.2.0' | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-RQUnuNAEEWcLhRap81qwGUUqAy1KcvqANnA0G3pzZqFkhMe6LrTk5lVi9tdOaF0Ud/yOx5fdx0rNPYfiB27Z+w== | ||||||
|  |   /telegram-typings/3.6.1: | ||||||
|  |     dev: false | ||||||
|  |     resolution: | ||||||
|  |       integrity: sha512-njVv1EAhIZnmQVLocZEADYUyqA1WIXuVcDYlsp+mXua/XB0pxx+PKtMSPeZ/EE4wPWTw9h/hA9ASTT6yQelkiw== | ||||||
|  | registry: 'https://registry.npmjs.org/' | ||||||
|  | shrinkwrapMinorVersion: 9 | ||||||
|  | shrinkwrapVersion: 3 | ||||||
|  | specifiers: | ||||||
|  |   axios: ^0.18.0 | ||||||
|  |   telegraf: ^3.27.1 | ||||||
							
								
								
									
										564
									
								
								webhook.php
									
									
									
									
									
								
							
							
						
						
									
										564
									
								
								webhook.php
									
									
									
									
									
								
							| @@ -1,564 +0,0 @@ | |||||||
| <?php |  | ||||||
| # vim: set tabstop=2 shiftwidth=2 expandtab: |  | ||||||
| $bot_name = "quadnite_bot"; |  | ||||||
| $bot_api = require('api_key.php'); |  | ||||||
|  |  | ||||||
| // Checks whether the given command is the same as the entered command |  | ||||||
| function check_command($command) { |  | ||||||
|   global $bot_name; |  | ||||||
|   global $decoded; |  | ||||||
|   $command_list = explode(" ", $decoded->{"message"}->{"text"}); |  | ||||||
|   if ($command_list[0] == $command || $command_list[0] == $command . "@" . $bot_name) { |  | ||||||
|     return True; |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     return False; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Send code back to the sender. |  | ||||||
| function send_code($post_message, $reply=false) { |  | ||||||
|   global $decoded; |  | ||||||
|   global $bot_api; |  | ||||||
|   global $chat_id; |  | ||||||
|   $url = 'https://api.telegram.org/bot' . $bot_api . '/sendMessage'; |  | ||||||
|   $post_msg = array('chat_id' => $chat_id, 'text' => '```\n ' . $post_message . '```', 'parse_mode' => 'markdown' ); |  | ||||||
|   if ($reply != false) { |  | ||||||
|     if ($reply === true){ |  | ||||||
|       $post_msg['reply_to_message_id'] = $decoded->{'message'}->{'message_id'}; |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $post_msg['reply_to_message_id'] = $reply; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   $options = array( |  | ||||||
|     'http' => array( |  | ||||||
|       'header' => "Content-type: application/x-www-form-urlencoded\r\n", |  | ||||||
|       'method' => 'POST', |  | ||||||
|       'content' => http_build_query($post_msg) |  | ||||||
|     ) |  | ||||||
|   ); |  | ||||||
|   $context = stream_context_create($options); |  | ||||||
|   $result = file_get_contents($url, false, $context); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Send text back to the sender. |  | ||||||
| function send_text($post_message, $reply=false) { |  | ||||||
|   global $decoded; |  | ||||||
|   global $bot_api; |  | ||||||
|   global $chat_id; |  | ||||||
|   $url = 'https://api.telegram.org/bot' . $bot_api . '/sendMessage'; |  | ||||||
|   $post_msg = array('chat_id' => $chat_id, 'text' =>$post_message ); |  | ||||||
|   if ($reply != false) { |  | ||||||
|     if ($reply === true){ |  | ||||||
|       $post_msg['reply_to_message_id'] = $decoded->{'message'}->{'message_id'}; |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $post_msg['reply_to_message_id'] = $reply; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   $options = array( |  | ||||||
|     'http' => array( |  | ||||||
|       'header' => "Content-type: application/x-www-form-urlencoded\r\n", |  | ||||||
|       'method' => 'POST', |  | ||||||
|       'content' => http_build_query($post_msg) |  | ||||||
|     ) |  | ||||||
|   ); |  | ||||||
|   $context = stream_context_create($options); |  | ||||||
|   $result = file_get_contents($url, false, $context); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Send html back to the sender. |  | ||||||
| function send_html($post_message, $reply=false) { |  | ||||||
|   global $decoded; |  | ||||||
|   global $bot_api; |  | ||||||
|   global $chat_id; |  | ||||||
|   $url = 'https://api.telegram.org/bot' . $bot_api . '/sendMessage'; |  | ||||||
|   $post_msg = array('chat_id' => $chat_id, 'text' =>$post_message, 'parse_mode' => 'html'); |  | ||||||
|   if ($reply != false) { |  | ||||||
|     if ($reply === true){ |  | ||||||
|       $post_msg['reply_to_message_id'] = $decoded->{'message'}->{'message_id'}; |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $post_msg['reply_to_message_id'] = $reply; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   $options = array( |  | ||||||
|     'http' => array( |  | ||||||
|       'header' => "Content-type: application/x-www-form-urlencoded\r\n", |  | ||||||
|       'method' => 'POST', |  | ||||||
|       'content' => http_build_query($post_msg) |  | ||||||
|     ) |  | ||||||
|   ); |  | ||||||
|   $context = stream_context_create($options); |  | ||||||
|   $result = file_get_contents($url, false, $context); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Send gif back to the sender. |  | ||||||
| function send_gif($gif_url, $reply=false) { |  | ||||||
|   global $decoded; |  | ||||||
|   global $bot_api; |  | ||||||
|   global $chat_id; |  | ||||||
|   $url = 'https://api.telegram.org/bot' . $bot_api . '/sendAnimation'; |  | ||||||
|   $post_msg = array('chat_id' => $chat_id, 'animation' => $gif_url ); |  | ||||||
|   if ($reply != false) { |  | ||||||
|     if ($reply === true){ |  | ||||||
|       $post_msg['reply_to_message_id'] = $decoded->{'message'}->{'message_id'}; |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $post_msg['reply_to_message_id'] = $reply; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   $options = array( |  | ||||||
|     'http' => array( |  | ||||||
|       'header' => "Content-type: application/x-www-form-urlencoded\r\n", |  | ||||||
|       'method' => 'POST', |  | ||||||
|       'content' => http_build_query($post_msg) |  | ||||||
|     ) |  | ||||||
|   ); |  | ||||||
|   $context = stream_context_create($options); |  | ||||||
|   $result = file_get_contents($url, false, $context); |  | ||||||
|   return $result; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function forward_message($to_chat_id) { |  | ||||||
|   global $decoded; |  | ||||||
|   global $bot_api; |  | ||||||
|   global $chat_id; |  | ||||||
|   $message_id = $decoded->{"message"}->{"message_id"}; |  | ||||||
|   $url = 'https://api.telegram.org/bot' . $bot_api . '/forwardMessage'; |  | ||||||
|   $post_msg = array('chat_id' => $to_chat_id, 'message_id' => $message_id, 'from_chat_id' => $chat_id); |  | ||||||
|   $options = array( |  | ||||||
|     'http' => array( |  | ||||||
|       'header' => "Content-type: application/x-www-form-urlencoded\r\n", |  | ||||||
|       'method' => 'POST', |  | ||||||
|       'content' => http_build_query($post_msg) |  | ||||||
|     ) |  | ||||||
|   ); |  | ||||||
|   $context = stream_context_create($options); |  | ||||||
|   $result = file_get_contents($url, false, $context); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Generates random words |  | ||||||
| function rand_words($onewordmode) { |  | ||||||
|   global $command_list; |  | ||||||
|   if($onewordmode == 1){ |  | ||||||
|     $num = 1; |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     if (isset($command_list[1])) { |  | ||||||
|       $num = $command_list[1]; |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $num = 10; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   $num++; |  | ||||||
|   $words = array(); |  | ||||||
|   if (is_integer($num)) { |  | ||||||
|     if ($num > 50) { |  | ||||||
|       send_text("Too many words.", true); |  | ||||||
|       return; |  | ||||||
|     } |  | ||||||
|     $wordlist = file("/usr/share/dict/words"); |  | ||||||
|     for ($word=1; $word < $num; $word++) { |  | ||||||
|       $words[] = $wordlist[rand(0,count($wordlist))]; |  | ||||||
|     } |  | ||||||
|     send_text(implode(' ', $words)); |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     send_text("Ever heard of numbers?", true); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function rand_question() { |  | ||||||
|   $questions = file('rand_questions.txt'); |  | ||||||
|   $question = $questions[rand(0,count($questions))]; |  | ||||||
|   send_text($question); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function media_wiki($base_url) { |  | ||||||
|   global $command_list; |  | ||||||
|   $search_query = ""; |  | ||||||
|   for ($i=1; $i < count($command_list); $i++) { |  | ||||||
|     $search_query .= $command_list[$i]; |  | ||||||
|     if ($i < count($command_list) - 1) { |  | ||||||
|       $search_query .= " "; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   if (preg_match('/^\s*$/', $search_query)) { |  | ||||||
|     send_text('Missing search query'); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|   $url = $base_url . "?action=opensearch&format=json&search=" . urlencode($search_query); |  | ||||||
|   $a = json_decode(file_get_contents($url)); |  | ||||||
|   $names = $a[1]; |  | ||||||
|   $urls = $a[3]; |  | ||||||
|   if (count($names) == 0) { |  | ||||||
|     send_text("No result found", true); |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|   $text = "Results\n"; |  | ||||||
|   for ($i = 0 ; $i < count($names) ; $i++){ |  | ||||||
|     $text .= "<a href='" . $urls[$i] . "'>" . $names[$i] . "</a>\n"; |  | ||||||
|   } |  | ||||||
|   send_html($text); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function coin() { |  | ||||||
|   $random = rand(0,1); |  | ||||||
|   if ($random == 1) { |  | ||||||
|     send_text('Heads', true); |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     send_text('Tails', true); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function get_gif($force) { |  | ||||||
|   if ($force){ |  | ||||||
|     $param = "yes"; |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     $param = "no"; |  | ||||||
|   } |  | ||||||
|   $url = "https://yesno.wtf/api?force=" . $param; |  | ||||||
|   $result = file_get_contents($url); |  | ||||||
|   $json = json_decode($result); |  | ||||||
|   $image_url = $json->{"image"}; |  | ||||||
|   return $image_url; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function yes_or_no() { |  | ||||||
|   global $command_list; |  | ||||||
|   if (!isset($command_list[1])){ |  | ||||||
|     send_text('You know, you also have to ask the question.', true); |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|   $yes_replies = array("Yes", "Yep", "Yeah", "Yus", "Ja", "Ya", "Aye", "Ay", "Oui"); |  | ||||||
|   $no_replies = array("No", "Nopes", "Nu", "Nah", "Nein", "Naw", "Nay", "Yesn't"); |  | ||||||
|   $random = rand(0,1); |  | ||||||
|   $random2 = rand(0, 10); |  | ||||||
|   if ($random == 1) { |  | ||||||
|     $yes = $yes_replies[array_rand($yes_replies)]; |  | ||||||
|     send_text($yes, true); |  | ||||||
|     if ($random2 == 5){ |  | ||||||
|       send_gif(get_gif(True)); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     $no = $no_replies[array_rand($no_replies)]; |  | ||||||
|     send_text($no, true); |  | ||||||
|     if ($random2 == 33){ |  | ||||||
|       send_gif(get_gif(False)); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Kill yourself |  | ||||||
| function kys() { |  | ||||||
|   global $decoded; |  | ||||||
|   global $bot_name; |  | ||||||
|   global $command_list; |  | ||||||
|   $kys = file('kys.txt'); |  | ||||||
|   $random_kys = $kys[rand(0,count($kys)-1)]; |  | ||||||
|   if ($decoded->{'message'}->{'reply_to_message'}->{'from'}->{'username'} == $bot_name){ |  | ||||||
|     send_text("I can't be killed.", true); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|   if (isset($decoded->{'message'}->{'reply_to_message'})) { |  | ||||||
|     if (isset($decoded->{'message'}->{'reply_to_message'}->{'from'}->{'username'})){ |  | ||||||
|       $username = '@' . $decoded->{'message'}->{'reply_to_message'}->{'from'}->{'username'}; |  | ||||||
|       $random_kys = preg_replace('/##name##/', $username, $random_kys); |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $first_name = $decoded->{'message'}->{'reply_to_message'}->{'from'}->{'first_name'}; |  | ||||||
|       $random_kys = preg_replace('/##name##/', $first_name, $random_kys); |  | ||||||
|     } |  | ||||||
|     send_text($random_kys); |  | ||||||
|   } |  | ||||||
|   elseif (isset($command_list[1])){ |  | ||||||
|     $username = $command_list[1]; |  | ||||||
|     if ($username == "@quadnite_bot" || $username == "Quadnite" || $username == "quadnite"){ |  | ||||||
|       send_text("I can't be killed.", true); |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $random_kys = preg_replace('/##name##/', $username, $random_kys); |  | ||||||
|       send_text($random_kys); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     send_text("Do you want to kill yourself?\nIf no, reply to someone with /kys to kill them or run /kys username/name.\nYou can suggest more /kys replies using /feedback", true); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Insult |  | ||||||
| function send_insult() { |  | ||||||
|   global $decoded; |  | ||||||
|   global $bot_name; |  | ||||||
|   global $command_list; |  | ||||||
|   $insults = file('insults.txt'); |  | ||||||
|   $random_insult = $insults[rand(0,count($insults)-1)]; |  | ||||||
|   if ($decoded->{'message'}->{'reply_to_message'}->{'from'}->{'username'} == $bot_name){ |  | ||||||
|     send_text("Watch who you talk to.", true); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|   if (isset($decoded->{'message'}->{'reply_to_message'})) { |  | ||||||
|     if (isset($decoded->{'message'}->{'reply_to_message'}->{'from'}->{'username'})){ |  | ||||||
|       $username = '@' . $decoded->{'message'}->{'reply_to_message'}->{'from'}->{'username'}; |  | ||||||
|       $random_insult = preg_replace('/##name##/', $username, $random_insult); |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $first_name = $decoded->{'message'}->{'reply_to_message'}->{'from'}->{'first_name'}; |  | ||||||
|       $random_insult = preg_replace('/##name##/', $first_name, $random_insult); |  | ||||||
|     } |  | ||||||
|     send_text($random_insult); |  | ||||||
|   } |  | ||||||
|   elseif (isset($command_list[1])){ |  | ||||||
|     $username = $command_list[1]; |  | ||||||
|     if ($username == "@quadnite_bot" || $username == "Quadnite" || $username == "quadnite"){ |  | ||||||
|       send_text("Watch who you talk to.", true); |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $random_insult = preg_replace('/##name##/', $username, $random_insult); |  | ||||||
|       send_text($random_insult); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     send_text("Do you want to insult yourself?\nIf no, reply to someone with /insult to insult them or run /insult username/name.\nYou can suggest more /kys replies using /feedback", true); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function feedback(){ |  | ||||||
|   global $command_list; |  | ||||||
|   if (isset($command_list[1])){ |  | ||||||
|     forward_message(-1001168939936); |  | ||||||
|     send_text("Thank you for the feedback"); |  | ||||||
|   } |  | ||||||
|   else { |  | ||||||
|     send_text("To send feedback type in /feedback followed by the feedback", true); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Sends back JSON |  | ||||||
| function json() { |  | ||||||
|   global $var; |  | ||||||
|   $pretty_json = json_encode(json_decode($var), JSON_PRETTY_PRINT); |  | ||||||
|   send_text($pretty_json); |  | ||||||
| } |  | ||||||
| // Start Message |  | ||||||
| function start() { |  | ||||||
|   send_text('Hi, I am Quadnite. If you are chatting with me in private, you are most likely doing it wrong. Add me to a group for fun. To give feedback, use /feedback'); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function rate() { |  | ||||||
|   send_html('<a href="https://t.me/tgdrbot?start=quadnite_bot">Vote for me on Telegram Directory!</a>'); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function help() { |  | ||||||
|   send_html('You can either check /commands for a short overview or check the <a href="https://t.me/quadnite/9">Help Page</a>.'); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function commands() { |  | ||||||
|   send_text(file_get_contents('command_list.txt')); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function weebify() { |  | ||||||
|   global $decoded; |  | ||||||
|   global $command_list; |  | ||||||
|   if(count($command_list) <= 1){ |  | ||||||
|     send_text("Need text to weebify. Send /weebify text", true); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|   $letters = array( |  | ||||||
|     "a" => "卂", |  | ||||||
|     "b" => "乃", |  | ||||||
|     "c" => "匚", |  | ||||||
|     "d" => "刀", |  | ||||||
|     "e" => "乇", |  | ||||||
|     "f" => "下", |  | ||||||
|     "g" => "厶", |  | ||||||
|     "h" => "卄", |  | ||||||
|     "i" => "工", |  | ||||||
|     "j" => "丁", |  | ||||||
|     "k" => "长", |  | ||||||
|     "l" => "乚", |  | ||||||
|     "m" => "从", |  | ||||||
|     "n" => "𠘨", |  | ||||||
|     "o" => "口", |  | ||||||
|     "p" => "尸", |  | ||||||
|     "q" => "㔿", |  | ||||||
|     "r" => "尺", |  | ||||||
|     "s" => "丂", |  | ||||||
|     "t" => "丅", |  | ||||||
|     "u" => "凵", |  | ||||||
|     "v" => "リ", |  | ||||||
|     "w" => "山", |  | ||||||
|     "x" => "乂", |  | ||||||
|     "y" => "丫", |  | ||||||
|     "z" => "乙" |  | ||||||
|   ); |  | ||||||
|   $chars = str_split(preg_replace('/^\/[^ ]+ /', '', strtolower($decoded->{"message"}->{"text"}))); |  | ||||||
|   $text = ""; |  | ||||||
|   foreach($chars as $char){ |  | ||||||
|     if(key_exists($char, $letters)) { |  | ||||||
|       $text .= $letters[$char]; |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $text .= $char; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   send_text($text, true); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function absurdify() { |  | ||||||
|   global $decoded; |  | ||||||
|   global $command_list; |  | ||||||
|   if(count($command_list) <= 1){ |  | ||||||
|     send_text("Need text to absurdify. Send /absurdify text", true); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|   $chars = str_split(preg_replace('/^\/[^ ]+ /', '', strtolower($decoded->{"message"}->{"text"}))); |  | ||||||
|   $text = ""; |  | ||||||
|   foreach($chars as $char){ |  | ||||||
|     if (rand(0,1) == 0){ |  | ||||||
|       $text .= strtolower($char); |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|       $text .= strtoupper($char); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   send_text($text, true); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Get JSON from post, store it and decode it. |  | ||||||
| $var = file_get_contents('php://input'); |  | ||||||
| $decoded = json_decode($var); |  | ||||||
|  |  | ||||||
| // Store the chat ID |  | ||||||
| $chat_id = $decoded->{"message"}->{"chat"}->{"id"}; |  | ||||||
|  |  | ||||||
| $modules = array( |  | ||||||
|   array( |  | ||||||
|     "command" => "/start", |  | ||||||
|     "function" => "start();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/word", |  | ||||||
|     "function" => "rand_words(1);" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/words", |  | ||||||
|     "function" => "rand_words(0);" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/question", |  | ||||||
|     "function" => "rand_question();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/arch_wiki", |  | ||||||
|     "function" => "media_wiki('https://wiki.archlinux.org/api.php');" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/wiki", |  | ||||||
|     "function" => "media_wiki('https://en.wikipedia.org/w/api.php');" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/coin", |  | ||||||
|     "function" => "coin();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/is", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/are", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/can", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/will", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/shall", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/was", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/does", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/did", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/should", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/do", |  | ||||||
|     "function" => "yes_or_no();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/kys", |  | ||||||
|     "function" => "kys();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/json", |  | ||||||
|     "function" => "json();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/help", |  | ||||||
|     "function" => "help();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/insult", |  | ||||||
|     "function" => "send_insult();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/feedback", |  | ||||||
|     "function" => "feedback();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/rate", |  | ||||||
|     "function" => "rate();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/commands", |  | ||||||
|     "function" => "commands();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/weebify", |  | ||||||
|     "function" => "weebify();" |  | ||||||
|   ), |  | ||||||
|   array( |  | ||||||
|     "command" => "/absurdify", |  | ||||||
|     "function" => "absurdify();" |  | ||||||
|   ) |  | ||||||
| ); |  | ||||||
|  |  | ||||||
| if (!isset($decoded->{"message"}->{"text"})){ |  | ||||||
|   exit(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| if (isset($decoded->{"message"}->{"pinned_message"})){ |  | ||||||
|   exit(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| $command_list = explode(" ", $decoded->{"message"}->{"text"}); |  | ||||||
|  |  | ||||||
| foreach ($modules as $module ) { |  | ||||||
|   if (check_command($module["command"])) { |  | ||||||
|     eval($module["function"]); |  | ||||||
|     exit(); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| ?> |  | ||||||
							
								
								
									
										123115
									
								
								words.txt
									
									
									
									
									
										Archivo normal
									
								
							
							
						
						
									
										123115
									
								
								words.txt
									
									
									
									
									
										Archivo normal
									
								
							
										
											
												La diferencia del archivo ha sido suprimido porque es demasiado grande
												Cargar Diff
											
										
									
								
							
		Referencia en una nueva incidencia
	
	Block a user