bitbot-3.11-fork/modules/signals.py

59 lines
3.6 KiB
Python
Raw Normal View History

2016-03-29 11:56:58 +00:00
import signal
from random import randint
QUOTES = {
"You can build a throne with bayonets, but it's difficult to sit on it." : "Boris Yeltsin",
"We don't appreciate what we have until it's gone. Freedom is like that. It's like air. When you have it, you don't notice it." : "Boris Yeltsin",
"Storm clouds of terror and dictatorship are gathering over the whole country... They must not be allowed to bring eternal night." : "Boris Yeltsin",
"They accused us of suppressing freedom of expression. This was a lie and we could not let them publish it." : "Nelba Blandon, as director of censorship, Nicaragua",
"Death solves all problems - no man, no problem." : "Joseph Stalin",
"Make the lie big, make it simple, keep saying it, and eventually they will believe it." : "Adolf Hitler",
"If we don't end war, war will end us." : "H.G. Wells",
"All that is necessary for evil to succeed is for good men to do nothing." : "Edmund Burke",
"Live well. It is the greatest revenge." : "The Talmud",
"To improve is to change, so to be perfect is to have changed often." : "Winston Churchill",
"I believe it is peace for our time." : "Neville Chamberlain",
"Orbiting Earth in the spaceship, I saw how beautiful our planet is. People, let us preserve and increase this beauty, not destroy it!" : "Yuri Gagarin",
"Science is not everything, but science is very beautiful." : "Robert Oppenheimer",
"We choose to go to the Moon! We choose to go to the Moon in this decade and do the other things, not because they are easy, but because they are hard." : "",
"You teach a child to read, and he or her will be able to pass a literacy test." : "George W Bush",
"I know the human being and fish can coexist peacefully." : "George W Bush",
"They misunderestimated me." : "George W Bush",
"I'm an Internet expert too." : "Kim Jong Il",
"So long, and thanks for all the fish" : "",
"It is a lie that I made the people starve." : "Nicolae Ceaușescu",
2016-05-04 13:31:45 +00:00
"As far as I know - effective immediately, without delay." : "Günter Schabowski",
"Not all those who wander are lost." : "J.R.R. Tolkien",
"Life would be tragic if it weren't funny." : "Stephen Hawking",
"We are such stuff as dreams are made on; and our little life is rounded with a sleep." : "",
"Do androids dream of electric sheep?" : "",
"Love all, trust a few, do wrong to none." : "William Shakespeare",
"Patriotism is not enough. I must have no hatred or bitterness towards any one." : "Edith Cavell",
2016-05-09 12:35:52 +00:00
"The monuments of wit survive the monuments of power." : "Francis Bacon",
2016-06-25 21:12:06 +00:00
"Human ingenuity cannot concoct a cipher which human ingenuity cannot resolve" : "Edgar Allan Poe",
"Nobody has the intention to erect a wall" : "Walter Ulbricht",
"We're all completely fucked. I'm fucked. You're fucked. [...] It has been the biggest cock-up ever and we're all completely fucked" : "Richard Mottram"
2016-03-29 11:56:58 +00:00
}
class Module(object):
def __init__(self, bot):
self.bot = bot
signal.signal(signal.SIGINT, self.SIGINT)
signal.signal(signal.SIGUSR1, self.SIGUSR1)
def SIGINT(self, signum, frame):
print()
for server in self.bot.servers.values():
server.send_quit(self.random_quote())
self.bot.register_write(server)
self.bot.running = False
def SIGUSR1(self, signum, frame):
print("Reloading config file")
self.bot.config_object.load_config()
def random_quote(self):
quote = list(QUOTES)[randint(0, len(QUOTES)-1)]
return (" - " if QUOTES[quote] else "").join([quote,
QUOTES[quote]])