Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions ElisBot/ElisBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,16 @@ def handle(msg):
corso = response['Corso']
cell = response['Num_tel']
email = response['E_mail_1_Value']
data = emoji.emojize(":boy: "+ nome + " " + cognome + "\n" + ":envelope: " + email + "\n" + ":telephone_receiver: " + cell + "\n" + ":books: " +corso + "\n" + ":hotel: " + stanza + "\n\n")
face = ":boy:"

if response['Capo_Nucleo'] == "Y":
face = u"\U0001F9D4"
stanza += " - Capo Nucleo"
elif response['Capo_Stanza'] == "Y":
face = ":man:"
stanza += " - Capo Stanza"

data = emoji.emojize(face + " " + nome + " " + cognome + "\n" + ":envelope: " + email + "\n" + ":telephone_receiver: " + cell + "\n" + ":books: " +corso + "\n" + ":hotel: " + stanza + "\n\n")
bot.sendChatAction(chat_id,'typing')
bot.sendMessage(chat_id,data)
else:
Expand All @@ -148,8 +157,16 @@ def handle(msg):
course = user['Corso']
stanza = user['Stanza']
sigla = user['Sigla']
face = ":boy:"

if user['Capo_Nucleo'] == "Y":
face = u"\U0001F9D4"
stanza += " - Capo Nucleo"
elif user['Capo_Stanza'] == "Y":
face = ":man:"
stanza += " - Capo Stanza"

data += emoji.emojize(":boy: "+ nome + " " + cognome + "\n" + ":envelope: " + email + "\n" + ":telephone_receiver: " + cell + "\n" + ":books: " + course + "\n" + ":hotel: " + stanza + "\n" + ":ticket: " +sigla + "\n\n")
data += emoji.emojize(face + " " + nome + " " + cognome + "\n" + ":envelope: " + email + "\n" + ":telephone_receiver: " + cell + "\n" + ":books: " + course + "\n" + ":hotel: " + stanza + "\n" + ":ticket: " +sigla + "\n\n")

if data == "":
bot.sendMessage(chat_id,"Residente non trovato!")
Expand All @@ -169,15 +186,15 @@ def handle(msg):
for user in response:
nome = user['Nome']
cognome = user['Cognome']
cs = user["Capo_Stanza"]
capoNucleo = user["Capo_Nucleo"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questa sintassi non va bene per Python, bisogna usare lo snake_case, quindi capo_nucleo in caso di parole "composte"

capoStanza = user["Capo_Stanza"]

if cognome == "Paciolla" and cs == "Y":
data+=emoji.emojize(u"\U0001f466\U0001f3ff" + nome + " " + cognome + " *- Capo Stanza*"+"\n")
if capoNucleo == "Y":
data+=emoji.emojize(u"\U0001F9D4 *" + nome + " " + cognome + " - Capo Nucleo*\n")
elif capoStanza == "Y":
data+=emoji.emojize(":man: *" + nome + " " + cognome + " - Capo Stanza*\n")
else:
if cs == "Y":
data+=emoji.emojize(":man: " + "*" + nome + "*" + " " + "*"+ cognome + " - Capo Stanza*" +"\n")
else:
data+=emoji.emojize(":boy: " + nome + " " + cognome +"\n")
data+=emoji.emojize(":boy: " + nome + " " + cognome +"\n")
if data == "":
bot.sendMessage(chat_id,"Stanza non trovata!")
else:
Expand All @@ -197,11 +214,7 @@ def handle(msg):
for user in response:
nome = user['Nome']
cognome = user['Cognome']

if nome == "Carlo" or cognome == "Longo":
data+=emoji.emojize(u"\U0001f466\U0001f3ff" + nome + " " + cognome + "\n")
else:
data+=emoji.emojize(":boy: " + nome + " " + cognome + "\n")
data+=emoji.emojize(":boy: " + nome + " " + cognome + "\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serve uno spazio tra += e gli oggetti in causa

if data == "":
bot.sendMessage(chat_id,"Incaricato non trovato!",reply_markup=ReplyKeyboardRemove())
else:
Expand Down
81 changes: 81 additions & 0 deletions ElisBot/databases/ElisBot_Database_Schema_February_2020.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+01:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Current Database: `ElisBot`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `ElisBot` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `ElisBot`;

--
-- Table structure for table `Incarichi`
--

DROP TABLE IF EXISTS `Incarichi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Incarichi` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Nome` varchar(30) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `Residence_DB`
--

DROP TABLE IF EXISTS `Residence_DB`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Residence_DB` (
`Nome` varchar(30) DEFAULT NULL,
`Cognome` varchar(30) DEFAULT NULL,
`E_mail_1_Value` varchar(60) DEFAULT NULL,
`Seconda_mail` varchar(28) CHARACTER SET utf8 DEFAULT NULL,
`Tipo_tel` varchar(9) CHARACTER SET utf8 DEFAULT NULL,
`Corso` varchar(5) CHARACTER SET utf8 DEFAULT NULL,
`Sigla` varchar(3) CHARACTER SET utf8 DEFAULT NULL,
`Stanza` varchar(14) CHARACTER SET utf8 DEFAULT NULL,
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Num_tel` varchar(30) DEFAULT NULL,
`Capo_Stanza` set('Y','N') NOT NULL DEFAULT 'N',
`Capo_Nucleo` set('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=606 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `Incaricato`
--

DROP TABLE IF EXISTS `Incaricato`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Incaricato` (
`ID_Residente` int(11) NOT NULL,
`ID_Incarico` int(11) NOT NULL,
PRIMARY KEY (`ID_Residente`,`ID_Incarico`),
KEY `ID_Incarico` (`ID_Incarico`),
CONSTRAINT `Incaricato_ibfk_1` FOREIGN KEY (`ID_Residente`) REFERENCES `Residence_DB` (`ID`) ON DELETE CASCADE,
CONSTRAINT `Incaricato_ibfk_2` FOREIGN KEY (`ID_Incarico`) REFERENCES `Incarichi` (`ID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
2 changes: 1 addition & 1 deletion ElisBot/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def getUsersFromRoom(self,room):

with self.connection.cursor() as cursor:

queryForUserInfo = 'select Nome,Cognome,Capo_Stanza from Residence_DB where Stanza like %s'
queryForUserInfo = 'select Nome,Cognome,Capo_Stanza,Capo_Nucleo from Residence_DB where Stanza like %s'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem qui, probabilmente era un mio errore iniziale, snake_case anche qui

cursor.execute(queryForUserInfo,(room + "%"))
result = cursor.fetchall()
#print(result)
Expand Down