from multiprocessing import Process
class BotProcess:
def __init__(self):
self.process = None
def get(self) -> Process:
return self.process
def is_alive(self) -> bool:
if self.process is not None and self.process.is_alive():
return True
else:
return False
def stop(self) -> None:
self.process.terminate()
self.process = None
def start(self, process: Process) -> None:
self.process = process
self.process.start()
bot_process = BotProcess()
@app.route("/bot-start", methods=["GET"])
def bot_start():
if not bot_process.is_alive():
bot_process.start(Process(target=start_bot))
return "Bot started"
else:
return "Bot is already running"
@app.route("/bot-restart", methods=["GET"])
def bot_restart():
if bot_process.is_alive():
bot_process.stop()
bot_process.start(Process(target=start_bot))
return "Bot restarted"
else:
return "Bot is not running"
@app.route("/bot-stop", methods=["GET"])
def bot_stop():
if bot_process.is_alive():
bot_process.stop()
return "Bot stopped"
else:
return "Bot is not running"
def setup(handler, bot, app):
@handler.on_message()
def do_stuff(event):
pass
@app.route('/stuff')
def route_stuff():
return "stuff"
import my_module
my_module.setup(handler, bot, app)
document.getElementsByName("answer")[0].value = data;
<input class="answer" type="text" name="answer" size="16" value="<?php echo (isset(($_POST["answer"] )) ? htmlspecialchars($_POST["answer"]) : '' ?>" autocomplete="off">
<?php echo (isset(($_POST["answer"] )) ? htmlspecialchars($_POST["answer"]) : '' ?>
$.ajax({
url: '../php/action.php',
type: 'POST',
success: function(data) {
$('.answer').test(data);
});
import requests
user_id = 121495485
token = ''
files = {'document': open('files.zip', 'rb')}
response = requests.post(f'https://api.telegram.org/bot{token}/sendDocument?chat_id={user_id}',files=files)
print(response.text)
function test(a, b) {
console.log(a,b);
}
// вызов
test(5,10);
function test(obj) {
console.log(obj.a, obj.b);
}
// вызов
test({'a':5, 'b' :10});
function f({ a, b }) { console.log(a, b); }
f({ a: 5, b: 10 });
from dataclasses import dataclass
@dataclass
class Summoner:
id: str = ''
accountId: str = ''
puuid: str = ''
name: str = ''
profileIconId: str = ''
revisionDate: str = ''
summonerLevel: str = ''
async def SummonerByName(self, region, summonerName):
response = await self.fetch(
await self.summoner_v4.SummonerByName(
region=region,
summonerName=summonerName,
)
)
return Summoner(**response)
let embed = new Discord.MessageEmbed()
.setColor('#ff414d')
.addFields({
name: 'okey',
value: 'okey',
inline: true
}, {
name: '\u200b',
value: '\u200b',
inline: true
}, {
name: 'okey',
value: ':okey',
inline: true
})
message.channel.send(embed)